]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug where a column with a SQL or server side default
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 9 Feb 2011 20:14:54 +0000 (15:14 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 9 Feb 2011 20:14:54 +0000 (15:14 -0500)
that was excluded from a mapping with include_properties
or exclude_properties would result in UnmappedColumnError.
[ticket:1995]

CHANGES
lib/sqlalchemy/orm/mapper.py
test/orm/test_mapper.py

diff --git a/CHANGES b/CHANGES
index cf0c0eb0179dd051238e8145293396db5ada02ad..dec011438b5811760ec77cb26772b9735d4831a4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -218,6 +218,11 @@ CHANGES
     from that target. Also emits the correct WHERE criterion
     when using single table inheritance. [ticket:2038]
 
+ - Fixed bug where a column with a SQL or server side default
+   that was excluded from a mapping with include_properties
+   or exclude_properties would result in UnmappedColumnError.
+   [ticket:1995]
+
 - sql
   - Column.copy(), as used in table.tometadata(), copies the 
     'doc' attribute.  [ticket:2028]
index db445076c888f8e76fba99e35d9ecd20678b30aa..a6d2c95f51e4f37bb30bbdc30b2e5e616f6003c2 100644 (file)
@@ -1937,7 +1937,8 @@ class Mapper(object):
         if postfetch_cols:
             state.expire_attributes(state.dict, 
                                 [self._columntoproperty[c].key 
-                                for c in postfetch_cols]
+                                for c in postfetch_cols if c in 
+                                self._columntoproperty]
                             )
 
         # synchronize newly inserted ids from one table to the next
index 0ee5e44bd6a8752ea29345d4c891642a7a73f7ff..abef6ed18676af96d4a779631782ed47d94e0b3d 100644 (file)
@@ -533,6 +533,21 @@ class MapperTest(_fixtures.FixtureTest):
             Foo, inherits=Person, polymorphic_identity='foo',
             exclude_properties=('type', ),
             )
+    @testing.resolve_artifact_names
+    @testing.provide_metadata
+    def test_prop_filters_defaults(self):
+        t = Table('t', metadata,
+               Column('id', Integer(), primary_key=True, test_needs_autoincrement=True),
+               Column('x', Integer(), nullable=False, server_default='0')
+              )
+        t.create()
+        class A(object):
+            pass
+        mapper(A, t, include_properties=['id'])
+        s = Session()
+        s.add(A())
+        s.commit()
+
 
     @testing.resolve_artifact_names
     def test_mapping_to_join_raises(self):