using backref raises AttributeError when querying column-based entities [declarative extension]

Issue #2733 resolved
Andrija Zarić created an issue

sqlalchemy 0.8.1 and default branch / Python 2.7.3 / Ubuntu 12.04

Addressing "backref" attribute will raise an AttributeError in case of querying column-based entities (Child.parents is specified with backref in Parent class):

This will not raise exception if `Child` or `Parent` entities are used in a query before.

See the attached code for the full example.

I'm not sure if this is a bug or should be expected behaviour. I haven't tried to reproduce it without declarative extension.

Comments (1)

  1. Mike Bayer repo owner

    this is just mappers not getting configured, and your relationship is declared as a backref. you can refer to columns before this occurs for mapping purposes.

    add

    from sqlalchemy.orm import configure_mappers
    configure_mappers()
    
  2. Log in to comment