Hello everyone!

I am continuing with the migration from SqlAlchemy 0.6.8 to 0.7.4, and
I've seen a little difference in behavior.

I have a class Product (more or less) like:

class Product(declarativeBase):
        _id = Column("id", Integer, primary_key=True)
        _model = Column("model", Unicode(128))

        @hybrid_property
        def model(self):
                return self._model

        @model.setter
        def setModel(self, model):
                if model:
                        self._model = unicode(model)
                else:
                        self._model = None

         #id hybrid property as well

Both id and model are hybrid_properties now (they were Synonyms in 0.6.8)

When I query only some values:

query = session.query(Product.Product).filter(Product.Product.id ==
25).values(Product.Product.model)
for element in query:
        print "%s\n" % vars(element)

The query works perfectly, but I get this:
{'_model': u'myAifon', '_labels': ('_model',)}

The "hidden" (or masked... I don't know how to call it) attribute (the
"private" one, starting with a "_") so if I try something like

for element in query:
        print "The 'model' is: %s\n" % element.model

I get a "Kaboom!!" (I''ve heard it's the Swahili for AttributeError
exception). Is there a workaround this? I am trying to migrate all my
Synonyms to hybrid_properties, specially since I read "synonym() is
superseded as of 0.7 by the hybrid extension."
(http://www.sqlalchemy.org/docs/orm/mapper_config.html). That was
enough to make me obsessed with getting rid of the synonyms :-)

Thank you in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to