Re: [Sqlalchemy-tickets] [sqlalchemy] #2843: Support for IF EXISTS/IF NOT EXISTS DDL constructs
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-10-17 18:46:43
|
#2843: Support for IF EXISTS/IF NOT EXISTS DDL constructs
------------------------------+-------------------------------
Reporter: remyroy | Owner: zzzeek
Type: enhancement | Status: new
Priority: medium | Milestone: 0.9.xx
Component: schema | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: in queue |
------------------------------+-------------------------------
Comment (by remyroy):
Would it make sense to merge the currently implemented checkfirst logic
with the IF EXISTS/IF NOT EXISTS implementation? What I mean is that for
dialects who supports IF EXISTS/IF NOT EXISTS for a specific object type,
no introspection would be done whenever checkfirst=True, only the CREATE
or DROP statement would be issued with the proper IF EXISTS/IF NOT EXISTS
vocabulary. That would save some roundtrip to the database for those who
support IF EXISTS/IF NOT EXISTS.
I would also rename "checkfirst" to "checkexists" and update the
documentation accordingly.
Would it be a good idea to include a long list of supports_[statement |
"[create|drop]_[object type]" ]_checkexists attributes for each dialect
class? I believe some DBMS have mixed IF EXISTS/IF NOT EXISTS support for
different object types and for CREATE or DROP and other statements. For
instance, PostgreSQL 8.2 supports DROP TABLE IF EXISTS but does not
support CREATE TABLE IF NOT EXISTS or ALTER TABLE DROP COLUMN IF EXISTS
while PostgreSQL 9.2 supports DROP TABLE IF EXISTS, CREATE TABLE IF NOT
EXISTS and ALTER TABLE DROP COLUMN IF EXISTS.
I might be able to work on this and get you a pull request with
documentation and tests.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2843#comment:3>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|