Python sqlalchemy.orm.interfaces.PropComparator() Examples
The following are 2
code examples of sqlalchemy.orm.interfaces.PropComparator().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy.orm.interfaces
, or try the search function
.
Example #1
Source File: test_mapper.py From sqlalchemy with MIT License | 6 votes |
def test_kwarg_accepted(self): users, Address = self.tables.users, self.classes.Address class DummyComposite(object): def __init__(self, x, y): pass from sqlalchemy.orm.interfaces import PropComparator class MyFactory(PropComparator): pass for args in ( (column_property, users.c.name), (deferred, users.c.name), (synonym, "name"), (composite, DummyComposite, users.c.id, users.c.name), (relationship, Address), (backref, "address"), (dynamic_loader, Address), ): fn = args[0] args = args[1:] fn(comparator_factory=MyFactory, *args)
Example #2
Source File: test_descriptor.py From sqlalchemy with MIT License | 5 votes |
def test_comparator(self): class Comparator(PropComparator): __hash__ = None attr = "bar" def method1(self): return "method1" def method2(self, other): return "method2" def __getitem__(self, key): return "value" def __eq__(self, other): return column("foo") == func.upper(other) Foo = self._fixture() d = MockDescriptor(Foo, "foo", comparator_factory=Comparator) d.instrument_class(Foo.__mapper__) eq_(Foo.foo.method1(), "method1") eq_(Foo.foo.method2("x"), "method2") assert Foo.foo.attr == "bar" assert Foo.foo["bar"] == "value" eq_((Foo.foo == "bar").__str__(), "foo = upper(:upper_1)")