]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Modify the text of the message which occurs
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 5 Jun 2011 00:09:21 +0000 (20:09 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 5 Jun 2011 00:09:21 +0000 (20:09 -0400)
when the "identity" key isn't detected on
flush, to include the common cause that
the Column isn't set up to detect
auto-increment correctly; [ticket:2170].

CHANGES
lib/sqlalchemy/orm/session.py
test/orm/test_unitofwork.py

diff --git a/CHANGES b/CHANGES
index 7f9063a99037dd17ffd980161ab9d5d22c17a36d..545d79bc9a558dcfb420136d74f7234b362f7857 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -50,6 +50,12 @@ CHANGES
     alias would fail if logging were used, due to 
     unescaped % sign in the alias name.  [ticket:2171]
 
+  - Modify the text of the message which occurs
+    when the "identity" key isn't detected on 
+    flush, to include the common cause that
+    the Column isn't set up to detect
+    auto-increment correctly; [ticket:2170].
+
 - sql
   - Fixed bug whereby if FetchedValue was passed
     to column server_onupdate, it would not
index 610fc6362a763500a9634532ecc8b69b375ef4ad..61ceeeeb09c7e3580915b30a7c93eeb521558257 100644 (file)
@@ -1045,10 +1045,15 @@ class Session(object):
             if _none_set.issubset(instance_key[1]) and \
                 not mapper.allow_partial_pks or \
                 _none_set.issuperset(instance_key[1]):
-                raise exc.FlushError('Instance %s has a NULL identity '
-                        'key.  Check if this flush is occurring at an '
-                        'inappropriate time, such as during a load '
-                        'operation.' % mapperutil.state_str(state))
+                raise exc.FlushError(
+                    "Instance %s has a NULL identity key.  If this is an "
+                    "auto-generated value, check that the database table "
+                    "allows generation of new primary key values, and that "
+                    "the mapped Column object is configured to expect these "
+                    "generated values.  Ensure also that this flush() is "
+                    "not occurring at an inappropriate time, such as within "
+                    "a load() event." % mapperutil.state_str(state)
+                )
 
             if state.key is None:
                 state.key = instance_key
index 85c2c2516b78bd5f676672aebc3f75e33b019eb5..408810d1b9df7ca6b2cead09680d3a8ece15d7ac 100644 (file)
@@ -2320,10 +2320,10 @@ class DontAllowFlushOnLoadingObjectTest(_base.MappedTest):
         # the population process would continue after the erroneous flush
         # and thing would right themselves.
         assert_raises_message(sa.orm.exc.FlushError,
-                              'has a NULL identity key.  Check if this '
-                              'flush is occurring at an inappropriate '
-                              'time, such as during a load operation.',
-                              sess.query(T1).first)
+                        r"Instance \<T1 at .+?\> has a NULL "
+                        "identity key.  If this is an auto-generated value, "
+                        "check that the database table allows generation ",
+                      sess.query(T1).first)