On Wednesday, March 16, 2016 at 4:41:38 PM UTC+1, Simon King wrote:
>
>
> Hmm, ok. In that case, does it work if you use "TextValue.id.in_(ids)" 
> rather than Node? I can't tell from your 
>

Yes, this works – see my last post in this thread.
 

> description if the "id" and "value" columns are both present on the 
> TextValue table, or if you actually need to join to the Node class.
>

Both TextValue and Node have "id" column and "value" column is only in 
TextValue table. To get TextValue object all tables for superclasses of 
TextValue have to be joined which is how joined table inheritance works.

Abbreviated models below:

class TextValue(Content):
    id = Column(Integer, ForeignKey('contents.id'), primary_key=True)
    value = Column(Unicode)


class Content(Node):
    @classproperty
    def __mapper_args__(cls):
        return dict(polymorphic_identity=camel_case_to_name(cls.__name__))

    id = Column(Integer, ForeignKey('nodes.id'), primary_key=True)
    (...)


class Node(Base, ContainerMixin, PersistentACLMixin):
    __table_args__ = (UniqueConstraint('parent_id', 'name'))

    __mapper_args__ = dict(
        polymorphic_on='type',
        polymorphic_identity='node',
        with_polymorphic='*',
    )

    id = Column(Integer(), primary_key=True)
    type = Column(String(30), nullable=False)
    parent_id = Column(ForeignKey('nodes.id'), index=True)
    (....)

It does seem like a bug that SA is generating this SQL.
>

I would thought so but I don't know SA to be sure.


Regards,
Piotr 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to