]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- The "allow_column_override" flag from mapper() has rel_0_5beta2
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 14 Jul 2008 20:04:35 +0000 (20:04 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 14 Jul 2008 20:04:35 +0000 (20:04 +0000)
been removed.  This flag is virtually always misunderstood.
Its specific functionality is available via the
include_properties/exclude_properties mapper arguments.

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

diff --git a/CHANGES b/CHANGES
index 5e0d3146d65710652cb0c2167fd97e393c5a500c..28672f8a405dc98a37033fbed484bb1511f0b17f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -39,6 +39,11 @@ CHANGES
       columns-only clause and an SQL-expression 
       ON clause in the join.
       
+    - The "allow_column_override" flag from mapper() has
+      been removed.  This flag is virtually always misunderstood.
+      Its specific functionality is available via the 
+      include_properties/exclude_properties mapper arguments.
+      
     - Repaired `__str__()` method on Query. [ticket:1066]
 
     - Session.bind gets used as a default even when table/mapper
index 172b99558c399a94cd1208538a28c7e92c021ac0..03db7039417f623763cebc46baf09b8c2628e658 100644 (file)
@@ -82,7 +82,6 @@ class Mapper(object):
                  inherit_foreign_keys = None,
                  extension = None,
                  order_by = False,
-                 allow_column_override = False,
                  entity_name = None,
                  always_refresh = False,
                  version_id_col = None,
@@ -127,7 +126,6 @@ class Mapper(object):
         self.inherit_foreign_keys = inherit_foreign_keys
         self.extension = extension
         self._init_properties = properties or {}
-        self.allow_column_override = allow_column_override
         self.allow_null_pks = allow_null_pks
         self.delete_orphans = []
         self.batch = batch
@@ -717,10 +715,7 @@ class Mapper(object):
                     mapped_column.append(mc)
                 prop = ColumnProperty(*mapped_column)
             else:
-                if not self.allow_column_override:
-                    raise sa_exc.ArgumentError("WARNING: column '%s' not being added due to property '%s'.  Specify 'allow_column_override=True' to mapper() to ignore this condition." % (column.key, repr(prop)))
-                else:
-                    return
+                raise sa_exc.ArgumentError("WARNING: column '%s' conflicts with property '%s'.  To resolve this, map the column to the class under a different name in the 'properties' dictionary.  Or, to remove all awareness of the column entirely (including its availability as a foreign key), use the 'include_properties' or 'exclude_properties' mapper arguments to control specifically which table columns get mapped." % (column.key, repr(prop)))
 
         if isinstance(prop, ColumnProperty):
             col = self.mapped_table.corresponding_column(prop.columns[0])
index 8c3bd58c94c8046181f5c61bbb1bd28e6ba96af2..61ff8f250feac2f278a17c0b6fa3165434064941 100644 (file)
@@ -565,12 +565,15 @@ class MapperTest(_fixtures.FixtureTest):
 
     @testing.resolve_artifact_names
     def test_override_2(self):
-        """allow_column_override cancels the error."""
+        """exclude_properties cancels the error."""
+        
         mapper(User, users,
-               allow_column_override=True,
+               exclude_properties=['name'],
                properties=dict(
                    name=relation(mapper(Address, addresses))))
-
+        
+        assert bool(User.name)
+        
     @testing.resolve_artifact_names
     def test_override_3(self):
         """The column being named elsewhere also cancels the error,"""