Mike Bayer avatar Mike Bayer committed c71c870

- 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.

Comments (0)

Files changed (3)

       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

lib/sqlalchemy/orm/mapper.py

                  inherit_foreign_keys = None,
                  extension = None,
                  order_by = False,
-                 allow_column_override = False,
                  entity_name = None,
                  always_refresh = False,
                  version_id_col = None,
         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
                     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])

test/orm/mapper.py

 
     @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,"""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.