diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-24 18:49:32 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-24 18:49:32 -0500 |
| commit | de11f9498258182cbb6668b72067ec3f43a90415 (patch) | |
| tree | d5d8aba789516b02391fa38d14085709ef86aca3 /test/base/test_utils.py | |
| parent | ba926a09b493b37c88e7b435aaccc6b399574057 (diff) | |
| download | sqlalchemy-de11f9498258182cbb6668b72067ec3f43a90415.tar.gz | |
- The :meth:`.PropComparator.of_type` modifier has been
improved in conjunction with loader directives such as
:func:`.joinedload` and :func:`.contains_eager` such that if
two :meth:`.PropComparator.of_type` modifiers of the same
base type/path are encountered, they will be joined together
into a single "polymorphic" entity, rather than replacing
the entity of type A with the one of type B. E.g.
a joinedload of ``A.b.of_type(BSub1)->BSub1.c`` combined with
joinedload of ``A.b.of_type(BSub2)->BSub2.c`` will create a
single joinedload of ``A.b.of_type((BSub1, BSub2)) -> BSub1.c, BSub2.c``,
without the need for the ``with_polymorphic`` to be explicit
in the query.
fixes #3256
Diffstat (limited to 'test/base/test_utils.py')
| -rw-r--r-- | test/base/test_utils.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index f75c5cbe9..df61d7874 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -8,6 +8,7 @@ from sqlalchemy.util import classproperty, WeakSequence, get_callable_argspec from sqlalchemy.sql import column from sqlalchemy.util import langhelpers + class _KeyedTupleTest(object): def _fixture(self, values, labels): @@ -283,6 +284,35 @@ class MemoizedAttrTest(fixtures.TestBase): eq_(val[0], 21) +class ToListTest(fixtures.TestBase): + def test_from_string(self): + eq_( + util.to_list("xyz"), + ["xyz"] + ) + + def test_from_set(self): + spec = util.to_list(set([1, 2, 3])) + assert isinstance(spec, list) + eq_( + sorted(spec), + [1, 2, 3] + ) + + def test_from_dict(self): + spec = util.to_list({1: "a", 2: "b", 3: "c"}) + assert isinstance(spec, list) + eq_( + sorted(spec), + [1, 2, 3] + ) + + def test_from_tuple(self): + eq_( + util.to_list((1, 2, 3)), + [1, 2, 3] + ) + class ColumnCollectionTest(fixtures.TestBase): def test_in(self): |
