1. Michael Bayer
  2. sqlalchemy
  3. Issues

Issues

Issue #2586 resolved

add __clause_element__ to ColumnProperty ?

Michael Bayer
repo owner created an issue

to support a declarative pattern like this:

Base = declarative_base()

class DocumentBase(Base):
    __abstract__ = True
    filename = Column(String)

    @declared_attr
    def file_object(cls):
        return deferred(Column('file_object', LargeBinary))

    @declared_attr
    def file_size(cls):
        # i.e. this:
        return column_property(func.length(cls.file_object))

        # and not this:
        return column_property(func.length(cls.file_object.columns[0](0)))

class Document(DocumentBase):
    __tablename__ = 'document'

    id = Column(Integer, primary_key=True)

Comments (2)

  1. Log in to comment