]> 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:04:29 +0000 (20:04 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 5 Jun 2011 00:04:29 +0000 (20:04 -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].
Also in 0.6.8.

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

diff --git a/CHANGES b/CHANGES
index 72c8c86a127e4c7715deac4a9ce2bbf1d84c7df5..505df6394fc5bfd8cf02e26881eee89e6028c343 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -18,6 +18,13 @@ CHANGES
     create multiple event listeners for 
     subclasses either.  [ticket:2180]
 
+  - 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].
+    Also in 0.6.8.
+
 - sql
   - Fixed bug whereby metadata.reflect(bind)
     would close a Connection passed as a
index 8f8770a3b9b4f679059cf9a8631c33194f619cf0..29353c4b7229bfc8fcc6c00d03154b9d1b7df23f 100644 (file)
@@ -1085,10 +1085,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 8b2787d12aaea94fb08d1548d1de27c714ade2c7..10d13ec8a754b252b14d7e87264a561847031f2f 100644 (file)
@@ -2469,7 +2469,7 @@ class PartialNullPKTest(fixtures.MappedTest):
         assert_raises_message(
             sa.exc.FlushError,
             r"Instance \<T1 at .+?\> has a NULL "
-            "identity key.  Check if this flush is occurring "
-            "at an inappropriate time, such as during a load operation.",
+            "identity key.  If this is an auto-generated value, "
+            "check that the database table allows generation ",
             s.commit
         )