From: Mike Bayer Date: Fri, 23 Oct 2009 01:08:02 +0000 (+0000) Subject: - insert() and update() constructs can now embed bindparam() X-Git-Tag: rel_0_6beta1~232 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a43a0e8b68c28b72404e85e4b4e8999443dd3fc5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - insert() and update() constructs can now embed bindparam() objects using names that match the keys of columns. These bind parameters will circumvent the usual route to those keys showing up in the VALUES or SET clause of the generated SQL. [ticket:1579] --- diff --git a/CHANGES b/CHANGES index 86baaa78a4..baa34e7896 100644 --- a/CHANGES +++ b/CHANGES @@ -191,6 +191,12 @@ CHANGES performed). This occurs if no end-user returning() was specified. + - insert() and update() constructs can now embed bindparam() + objects using names that match the keys of columns. These + bind parameters will circumvent the usual route to those + keys showing up in the VALUES or SET clause of the generated + SQL. [ticket:1579] + - Databases which rely upon postfetch of "last inserted id" to get at a generated sequence value (i.e. MySQL, MS-SQL) now work correctly when there is a composite primary key diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 8af28c8e53..689b518f1d 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -465,13 +465,13 @@ class OracleDDLCompiler(compiler.DDLCompiler): class OracleIdentifierPreparer(compiler.IdentifierPreparer): reserved_words = set([x.lower() for x in RESERVED_WORDS]) - illegal_initial_characters = re.compile(r'[0-9_$]') + illegal_initial_characters = set(xrange(0, 10)).union(["_", "$"]) def _bindparam_requires_quotes(self, value): """Return True if the given identifier requires quoting.""" lc_value = value.lower() return (lc_value in self.reserved_words - or self.illegal_initial_characters.match(value[0]) + or value[0] in self.illegal_initial_characters or not self.legal_characters.match(unicode(value)) ) diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 4c31308796..5f5b31c68a 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -47,7 +47,7 @@ RESERVED_WORDS = set([ 'using', 'verbose', 'when', 'where']) LEGAL_CHARACTERS = re.compile(r'^[A-Z0-9_$]+$', re.I) -ILLEGAL_INITIAL_CHARACTERS = re.compile(r'[0-9$]') +ILLEGAL_INITIAL_CHARACTERS = set(xrange(0, 10)).union(['$']) BIND_PARAMS = re.compile(r'(?