diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-22 19:07:04 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-22 19:07:04 -0500 |
| commit | 73f2b37fc98aeb7c5ec5b4b9e624352042018686 (patch) | |
| tree | 7a1813eca263e74159d47c0542f9835fab4f693e | |
| parent | 993af53204a0e4378fbf65a0bbf9a617e34dede1 (diff) | |
| download | sqlalchemy-73f2b37fc98aeb7c5ec5b4b9e624352042018686.tar.gz | |
- remove OrderedSet usage from a critical area
| -rw-r--r-- | lib/sqlalchemy/schema.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 11 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/util.py | 11 | ||||
| -rw-r--r-- | test/aaa_profiling/test_orm.py | 2 | ||||
| -rw-r--r-- | test/aaa_profiling/test_resultset.py | 13 | ||||
| -rw-r--r-- | test/aaa_profiling/test_zoomark.py | 4 | ||||
| -rw-r--r-- | test/aaa_profiling/test_zoomark_orm.py | 2 | ||||
| -rw-r--r-- | test/ext/test_declarative.py | 2 |
8 files changed, 23 insertions, 28 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 4eff82333..8fd758d2d 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -229,7 +229,7 @@ class Table(SchemaItem, expression.TableClause): self.constraints = set() self._columns = expression.ColumnCollection() self._set_primary_key(PrimaryKeyConstraint()) - self.foreign_keys = util.OrderedSet() + self.foreign_keys = set() self._extra_dependencies = set() self.kwargs = {} if self.schema is not None: @@ -708,7 +708,7 @@ class Column(SchemaItem, expression.ColumnClause): self.onupdate = kwargs.pop('onupdate', None) self.autoincrement = kwargs.pop('autoincrement', True) self.constraints = set() - self.foreign_keys = util.OrderedSet() + self.foreign_keys = set() self._table_events = set() # check if this Column is proxying another column @@ -815,7 +815,7 @@ class Column(SchemaItem, expression.ColumnClause): if self.key in table._columns: col = table._columns.get(self.key) - for fk in col.foreign_keys: + for fk in list(col.foreign_keys): col.foreign_keys.remove(fk) table.foreign_keys.remove(fk) if fk.constraint in table.constraints: diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index bc36e888c..9e4804349 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2401,14 +2401,6 @@ class FromClause(Selectable): self.primary_key = ColumnSet() self.foreign_keys = set() - def _export_columns(self): - """Initialize column collections.""" - - self._columns = ColumnCollection() - self._primary_key = ColumnSet() - self._foreign_keys = set() - self._populate_column_collection() - def _populate_column_collection(self): pass @@ -3655,9 +3647,6 @@ class TableClause(_Immutable, FromClause): def _init_collections(self): pass - def _export_columns(self): - raise NotImplementedError() - @util.memoized_property def description(self): # Py3K diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index 757de37c4..997fedade 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -217,7 +217,9 @@ def join_condition(a, b, ignore_nonexistent_tables=False, a_subset=None): for left in (a_subset, a): if left is None: continue - for fk in b.foreign_keys: + for fk in sorted( + b.foreign_keys, + key=lambda fk:fk.parent._creation_order): try: col = fk.get_referent(left) except exc.NoReferencedTableError: @@ -230,7 +232,9 @@ def join_condition(a, b, ignore_nonexistent_tables=False, a_subset=None): crit.append(col == fk.parent) constraints.add(fk.constraint) if left is not b: - for fk in left.foreign_keys: + for fk in sorted( + left.foreign_keys, + key=lambda fk:fk.parent._creation_order): try: col = fk.get_referent(b) except exc.NoReferencedTableError: @@ -247,7 +251,8 @@ def join_condition(a, b, ignore_nonexistent_tables=False, a_subset=None): if len(crit) == 0: if isinstance(b, expression._FromGrouping): - hint = " Perhaps you meant to convert the right side to a subquery using alias()?" + hint = " Perhaps you meant to convert the right side to a "\ + "subquery using alias()?" else: hint = "" raise exc.ArgumentError( diff --git a/test/aaa_profiling/test_orm.py b/test/aaa_profiling/test_orm.py index 9f03b9cdd..519a29c29 100644 --- a/test/aaa_profiling/test_orm.py +++ b/test/aaa_profiling/test_orm.py @@ -79,7 +79,7 @@ class MergeTest(_base.MappedTest): # using sqlite3 the C extension took it back up to approx. 1257 # (py2.6) - @profiling.function_call_count(1067, + @profiling.function_call_count(1005, versions={'2.5':1050, '2.6':1050, '2.6+cextension':1041, '2.4': 763} diff --git a/test/aaa_profiling/test_resultset.py b/test/aaa_profiling/test_resultset.py index e46411bdb..dc4732cb8 100644 --- a/test/aaa_profiling/test_resultset.py +++ b/test/aaa_profiling/test_resultset.py @@ -34,16 +34,16 @@ class ResultSetTest(TestBase, AssertsExecutionResults): metadata.drop_all() @profiling.function_call_count(14416, versions={'2.4': 13214, - '2.6+cextension': 385, - '2.7+cextension':401}) + '2.6+cextension': 345, + '2.7+cextension':345}) def test_string(self): [tuple(row) for row in t.select().execute().fetchall()] # sqlite3 returns native unicode. so shouldn't be an increase here. @profiling.function_call_count(14396, versions={'2.4': 13214, - '2.6+cextension': 385, - '2.7+cextension':385}) + '2.6+cextension': 345, + '2.7+cextension':345}) def test_unicode(self): [tuple(row) for row in t2.select().execute().fetchall()] @@ -70,8 +70,9 @@ class ExecutionTest(TestBase): # ensure initial connect activities complete e.execute("select 1") - @profiling.function_call_count(59, versions={'2.4':41, '2.5':58, - '2.6':58, '3':57}, + @profiling.function_call_count(56, versions={'2.4':41, '2.5':58, + '2.6':58, '3':57, + '2.6+cextension':56}, variance=.05) def go(): e.execute("select 1") diff --git a/test/aaa_profiling/test_zoomark.py b/test/aaa_profiling/test_zoomark.py index 5fa9e7164..4c579f238 100644 --- a/test/aaa_profiling/test_zoomark.py +++ b/test/aaa_profiling/test_zoomark.py @@ -369,12 +369,12 @@ class ZooMarkTest(TestBase): def test_profile_2_insert(self): self.test_baseline_2_insert() - @profiling.function_call_count(3596, {'2.4': 2158}) + @profiling.function_call_count(3340, {'2.4': 2158, '2.7':3564, '2.6':3564}) def test_profile_3_properties(self): self.test_baseline_3_properties() @profiling.function_call_count(11624, {'2.4': 7963, '2.6+cextension' - : 12447, '2.7+cextension': 12447}, + : 10736, '2.7+cextension': 10736}, variance=0.10) def test_profile_4_expressions(self): self.test_baseline_4_expressions() diff --git a/test/aaa_profiling/test_zoomark_orm.py b/test/aaa_profiling/test_zoomark_orm.py index c4dd0ae9f..731d2d4c7 100644 --- a/test/aaa_profiling/test_zoomark_orm.py +++ b/test/aaa_profiling/test_zoomark_orm.py @@ -349,7 +349,7 @@ class ZooMarkTest(TestBase): '2.6': 6058, '2.7': 5922, '2.7+cextension': 5714, - '2.6+cextension': 6058, + '2.6+cextension': 5714, }) def test_profile_3_properties(self): self.test_baseline_3_properties() diff --git a/test/ext/test_declarative.py b/test/ext/test_declarative.py index 85692161b..3daf8c74a 100644 --- a/test/ext/test_declarative.py +++ b/test/ext/test_declarative.py @@ -1001,7 +1001,7 @@ class DeclarativeTest(DeclarativeTestBase): # case sa.orm.configure_mappers() - eq_(str(Address.user_id.property.columns[0].foreign_keys[0]), + eq_(str(list(Address.user_id.property.columns[0].foreign_keys)[0]), "ForeignKey('users.id')") Base.metadata.create_all() u1 = User(name='u1', addresses=[Address(email='one'), |
