diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-02-24 18:41:56 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-02-24 18:41:56 +0000 |
| commit | 955f4a27c37ba73901745b89eb555eb8681d4b9f (patch) | |
| tree | 04d4b7fb9f86b155201eed4d46f97fc765970a77 /test/sql | |
| parent | 3cb614009ee87a115ec7230949c031402efb17c1 (diff) | |
| parent | 996654df341a30b539434bb4fd1e0d53f46641a0 (diff) | |
| download | sqlalchemy-955f4a27c37ba73901745b89eb555eb8681d4b9f.tar.gz | |
Merge "Ensure schema-level table includes annotations in caching"
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_compare.py | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/test/sql/test_compare.py b/test/sql/test_compare.py index 7333fb306..fb6c515e4 100644 --- a/test/sql/test_compare.py +++ b/test/sql/test_compare.py @@ -168,6 +168,25 @@ class CoreFixtures(object): ), ), lambda: ( + table_a, + table_a._annotate({"orm": True}), + table_a._annotate({"orm": True})._annotate({"bar": False}), + table_a._annotate( + {"orm": True, "parententity": MyEntity("a", table_a)} + ), + table_a._annotate( + {"orm": True, "parententity": MyEntity("b", table_a)} + ), + table_a._annotate( + {"orm": True, "parententity": MyEntity("b", select([table_a]))} + ), + ), + lambda: ( + table("a", column("x"), column("y")), + table("a", column("x"), column("y"))._annotate({"orm": True}), + table("b", column("x"), column("y"))._annotate({"orm": True}), + ), + lambda: ( cast(column("q"), Integer), cast(column("q"), Float), cast(column("p"), Integer), @@ -780,7 +799,27 @@ class CompareClausesTest(fixtures.TestBase): ne_(t1._generate_cache_key(), t2._generate_cache_key()) - eq_(t1._generate_cache_key().key, (t1,)) + eq_(t1._generate_cache_key().key, (t1, "_annotations", ())) + + def test_compare_metadata_tables_annotations(self): + # metadata Table objects cache on their own identity, not their + # structure. This is mainly to reduce the size of cache keys + # as well as reduce computational overhead, as Table objects have + # very large internal state and they are also generally global + # objects. + + t1 = Table("a", MetaData(), Column("q", Integer), Column("p", Integer)) + t2 = Table("a", MetaData(), Column("q", Integer), Column("p", Integer)) + + t1 = t1._annotate({"orm": True}) + t2 = t2._annotate({"orm": True}) + + ne_(t1._generate_cache_key(), t2._generate_cache_key()) + + eq_( + t1._generate_cache_key().key, + (t1, "_annotations", (("orm", True),)), + ) def test_compare_adhoc_tables(self): # non-metadata tables compare on their structure. these objects are |
