diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-24 11:24:23 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-24 11:24:23 -0400 |
| commit | 9b73e997b2325018555268e1f1069e88e80fdb85 (patch) | |
| tree | 6cd512b1a8395f8dd9edb5915323603ef108db70 /test | |
| parent | 3d4c6f68167d33b28e0c3b12032058ad0d807d58 (diff) | |
| download | sqlalchemy-9b73e997b2325018555268e1f1069e88e80fdb85.tar.gz | |
- [bug] The names of the columns on the
.c. attribute of a select().apply_labels()
is now based on <tablename>_<colkey> instead
of <tablename>_<colname>, for those columns
that have a distinctly named .key.
[ticket:2397]
Diffstat (limited to 'test')
| -rw-r--r-- | test/sql/test_compiler.py | 4 | ||||
| -rw-r--r-- | test/sql/test_query.py | 38 | ||||
| -rw-r--r-- | test/sql/test_selectable.py | 13 |
3 files changed, 12 insertions, 43 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index feb7405db..d5d5eaa2d 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -248,14 +248,12 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): "SELECT sum(lala(mytable.myid)) AS bar FROM mytable" ) - # changes with #2397 self.assert_compile( select([keyed]), "SELECT keyed.x, keyed.y" ", keyed.z FROM keyed" ) - # changes with #2397 self.assert_compile( select([keyed]).apply_labels(), "SELECT keyed.x AS keyed_x, keyed.y AS " @@ -316,7 +314,6 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): ) # using alternate keys. - # this will change with #2397 a, b, c = Column('a', Integer, key='b'), \ Column('b', Integer), \ Column('c', Integer, key='a') @@ -370,7 +367,6 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): 'AS anon_1') def test_nested_label_targeting_keyed(self): - # this behavior chagnes with #2397 s1 = keyed.select() s2 = s1.alias() s3 = select([s2], use_labels=True) diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 9f0c2dab0..f315d6621 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -1280,7 +1280,7 @@ class KeyTargetingTest(fixtures.TablesTest): keyed2 = self.tables.keyed2 row = testing.db.execute(select([keyed1, keyed2])).first() - # without #2397, row.b is unambiguous + # row.b is unambiguous eq_(row.b, "b2") # row.a is ambiguous assert_raises_message( @@ -1289,21 +1289,6 @@ class KeyTargetingTest(fixtures.TablesTest): getattr, row, "a" ) - @testing.fails_if(lambda: True, "Possible future behavior") - def test_keyed_accessor_composite_conflict_2397(self): - keyed1 = self.tables.keyed1 - keyed2 = self.tables.keyed2 - - row = testing.db.execute(select([keyed1, keyed2])).first() - # with #2397, row.a is unambiguous - eq_(row.a, "a2") - # row.b is ambiguous - assert_raises_message( - exc.InvalidRequestError, - "Ambiguous column name 'b'", - getattr, row, 'b' - ) - def test_keyed_accessor_composite_names_precedent(self): keyed1 = self.tables.keyed1 keyed4 = self.tables.keyed4 @@ -1328,17 +1313,6 @@ class KeyTargetingTest(fixtures.TablesTest): ) eq_(row.d, "d3") - @testing.fails_if(lambda: True, "Possible future behavior") - def test_keyed_accessor_composite_2397(self): - keyed1 = self.tables.keyed1 - keyed3 = self.tables.keyed3 - - row = testing.db.execute(select([keyed1, keyed3])).first() - eq_(row.b, "a1") - eq_(row.q, "c1") - eq_(row.a, "a3") - eq_(row.d, "d3") - def test_keyed_accessor_composite_labeled(self): keyed1 = self.tables.keyed1 keyed2 = self.tables.keyed2 @@ -1366,22 +1340,12 @@ class KeyTargetingTest(fixtures.TablesTest): assert sql.column('content_type') in row def test_column_label_overlap_fallback_2(self): - # this fails with #2397 content, bar = self.tables.content, self.tables.bar row = testing.db.execute(content.select(use_labels=True)).first() assert content.c.type in row assert bar.c.content_type not in row assert sql.column('content_type') not in row - @testing.fails_if(lambda: True, "Possible future behavior") - def test_column_label_overlap_fallback_3(self): - # this passes with #2397 - content, bar = self.tables.content, self.tables.bar - row = testing.db.execute(content.select(use_labels=True)).first() - assert content.c.type in row - assert bar.c.content_type not in row - assert sql.column('content_type') in row - class LimitTest(fixtures.TestBase): diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index dde832e7d..e3508f77d 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -100,8 +100,6 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled s = select([keyed]) eq_(s.c.colx.key, 'colx') - # this would change to 'colx' - # with #2397 eq_(s.c.colx.name, 'x') assert s.corresponding_column(keyed.c.colx) is s.c.colx @@ -113,6 +111,17 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled assert sel2.corresponding_column(keyed.c.coly) is sel2.c.coly assert sel2.corresponding_column(keyed.c.z) is sel2.c.z + def test_keyed_label_gen(self): + s = select([keyed]).apply_labels() + + assert s.corresponding_column(keyed.c.colx) is s.c.keyed_colx + assert s.corresponding_column(keyed.c.coly) is s.c.keyed_coly + assert s.corresponding_column(keyed.c.z) is s.c.keyed_z + + sel2 = s.alias() + assert sel2.corresponding_column(keyed.c.colx) is sel2.c.keyed_colx + assert sel2.corresponding_column(keyed.c.coly) is sel2.c.keyed_coly + assert sel2.corresponding_column(keyed.c.z) is sel2.c.keyed_z def test_distance_on_aliases(self): a1 = table1.alias('a1') |
