add __clause_element__ to ColumnProperty ?

Issue #2586 resolved
Mike 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. Mike Bayer reporter

    that code wouldn't even work since it calls upon file_object() more than once when declarative runs. I'd rather not add more paths like this for now.

  2. Log in to comment