allow loading of unhashable types with query

Issue #2592 resolved
Mike Bayer repo owner created an issue
    def test_unhashable_type(self):
        from sqlalchemy.types import TypeDecorator, Integer
        from sqlalchemy.sql import type_coerce

        class MyType(TypeDecorator):
            impl = Integer
            hashable = False
            def process_result_value(self, value, dialect):
                return [value](value)

        User, users = self.classes.User, self.tables.users

        mapper(User, users)

        s = Session()
        row = s.\
                    query(User, type_coerce(users.c.id, MyType).label('foo')).\
                    filter(User.id == 7).first()
        eq_(
            row, (User(id=7), [7](7))
        )

Comments (3)

  1. Log in to comment