diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-04-03 11:28:57 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-04-03 11:30:09 -0400 |
commit | c315c7401a2aa00a8a0fa0f7d4189a9976fd7962 (patch) | |
tree | 0a4b5c4195d15d1e7294cc39589060660f1d5930 /test/sql/test_from_linter.py | |
parent | 1dffb7cedeb009ca6c532db558bd0588dd846957 (diff) | |
download | sqlalchemy-c315c7401a2aa00a8a0fa0f7d4189a9976fd7962.tar.gz |
TableValuedAlias generation fixes
Fixed bug in newly implemented
:paramref:`.FunctionElement.table_valued.joins_implicitly` feature where
the parameter would not automatically propagate from the original
:class:`.TableValuedAlias` object to the secondary object produced when
calling upon :meth:`.TableValuedAlias.render_derived` or
:meth:`.TableValuedAlias.alias`.
Additionally repaired these issues in :class:`.TableValuedAlias`:
* repaired a potential memory issue which could occur when
repeatedly calling :meth:`.TableValuedAlias.render_derived` against
successive copies of the same object (for .alias(), we currently
have to still continue chaining from the previous element. not sure
if this can be improved but this is standard behavior for .alias()
elsewhere)
* repaired issue where the individual element types would be lost when
calling upon :meth:`.TableValuedAlias.render_derived` or
:meth:`.TableValuedAlias.alias`.
Fixes: #7890
Change-Id: Ie5120c7ff1e5c1bba5aaf77c782a51c637860208
Diffstat (limited to 'test/sql/test_from_linter.py')
-rw-r--r-- | test/sql/test_from_linter.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/test/sql/test_from_linter.py b/test/sql/test_from_linter.py index 4a4d907f9..1fa3aff36 100644 --- a/test/sql/test_from_linter.py +++ b/test/sql/test_from_linter.py @@ -165,8 +165,15 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): assert start is p3 assert froms == {p1} + @testing.combinations( + "render_derived", "alias", None, argnames="additional_transformation" + ) @testing.combinations(True, False, argnames="joins_implicitly") - def test_table_valued(self, joins_implicitly): + def test_table_valued( + self, + joins_implicitly, + additional_transformation, + ): """test #7845""" my_table = table( "tbl", @@ -175,9 +182,16 @@ class TestFindUnmatchingFroms(fixtures.TablesTest): ) sub_dict = my_table.c.data["d"] - tv = func.json_each(sub_dict).table_valued( - "key", joins_implicitly=joins_implicitly - ) + + tv = func.json_each(sub_dict) + + tv = tv.table_valued("key", joins_implicitly=joins_implicitly) + + if additional_transformation == "render_derived": + tv = tv.render_derived(name="tv", with_types=True) + elif additional_transformation == "alias": + tv = tv.alias() + has_key = tv.c.key == "f" stmt = select(my_table.c.id).where(has_key) froms, start = find_unmatching_froms(stmt, my_table) |