From 2063314232941834a1cde187e5b54fd9e898fb4d Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 12 Apr 2010 11:30:01 -0400 Subject: much more descriptive message for bind param name conflict, [ticket:1766] --- lib/sqlalchemy/sql/compiler.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 78c65771b..7a1821a70 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -548,9 +548,12 @@ class SQLCompiler(engine.Compiled): ) elif getattr(existing, '_is_crud', False): raise exc.CompileError( - "Bind parameter name '%s' is reserved " - "for the VALUES or SET clause of this insert/update statement." - % bindparam.key + "bindparam() name '%s' is reserved " + "for automatic usage in the VALUES or SET clause of this " + "insert/update statement. Please use a " + "name other than column name when using bindparam() " + "with insert() or update() (for example, 'b_%s')." + % (bindparam.key, bindparam.key) ) self.binds[bindparam.key] = self.binds[name] = bindparam @@ -906,9 +909,12 @@ class SQLCompiler(engine.Compiled): bindparam._is_crud = True if col.key in self.binds: raise exc.CompileError( - "Bind parameter name '%s' is reserved " - "for the VALUES or SET clause of this insert/update statement." - % col.key + "bindparam() name '%s' is reserved " + "for automatic usage in the VALUES or SET clause of this " + "insert/update statement. Please use a " + "name other than column name when using bindparam() " + "with insert() or update() (for example, 'b_%s')." + % (col.key, col.key) ) self.binds[col.key] = bindparam -- cgit v1.2.1 From 731ad9b0b956fb3b9d318576661ede51b3d4f596 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 12 Apr 2010 20:20:50 -0400 Subject: further testing reveals that cursor.rowcount is only called with update/delete and DDL, and also that FB's cursor.rowcount is a little expensive, but not dramatically. added a test to ensure cursor.rowcount is only called on update/delete. the current default for firebird enable_rowcount is now True, leaving all the options to turn it off etc.. --- lib/sqlalchemy/dialects/firebird/kinterbasdb.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/dialects/firebird/kinterbasdb.py b/lib/sqlalchemy/dialects/firebird/kinterbasdb.py index 890ba83fe..84963ba8b 100644 --- a/lib/sqlalchemy/dialects/firebird/kinterbasdb.py +++ b/lib/sqlalchemy/dialects/firebird/kinterbasdb.py @@ -19,15 +19,19 @@ Kinterbasedb backend specific keyword arguments are: * concurrency_level - set the backend policy with regards to threading issues: by default SQLAlchemy uses policy 1 (see details__). -* enable_rowcount - False by default, this enables the usage of "cursor.rowcount" with the - Kinterbasdb dialect. When disabled, SQLAlchemy's ResultProxy will - return -1 for result.rowcount. The rationale here is that Kinterbasdb - requires a second round trip to the database when .rowcount is called - - since SQLA's resultproxy automatically closes the cursor after a - non-result-returning statement, rowcount must be called, if at all, - before the result object is returned. The behavior can also be - controlled on a per-execution basis using the `enable_rowcount` - option with :meth:`execution_options()`:: +* enable_rowcount - True by default, setting this to False disables + the usage of "cursor.rowcount" with the + Kinterbasdb dialect, which SQLAlchemy ordinarily calls upon automatically + after any UPDATE or DELETE statement. When disabled, SQLAlchemy's + ResultProxy will return -1 for result.rowcount. The rationale here is + that Kinterbasdb requires a second round trip to the database when + .rowcount is called - since SQLA's resultproxy automatically closes + the cursor after a non-result-returning statement, rowcount must be + called, if at all, before the result object is returned. Additionally, + cursor.rowcount may not return correct results with older versions + of Firebird, and setting this flag to False will also cause the SQLAlchemy ORM + to ignore its usage. The behavior can also be controlled on a per-execution + basis using the `enable_rowcount` option with :meth:`execution_options()`:: conn = engine.connect().execution_options(enable_rowcount=True) r = conn.execute(stmt) @@ -77,7 +81,7 @@ class FBDialect_kinterbasdb(FBDialect): ) - def __init__(self, type_conv=200, concurrency_level=1, enable_rowcount=False, **kwargs): + def __init__(self, type_conv=200, concurrency_level=1, enable_rowcount=True, **kwargs): super(FBDialect_kinterbasdb, self).__init__(**kwargs) self.enable_rowcount = enable_rowcount self.type_conv = type_conv -- cgit v1.2.1