mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-04 06:48:27 -04:00
- 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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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])
|
||||
|
||||
+6
-3
@@ -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,"""
|
||||
|
||||
Reference in New Issue
Block a user