pombreda / formalchemy

Automatically exported from code.google.com/p/formalchemy
MIT License
0 stars 0 forks source link

better synonym support #87

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
FA manages synonyms on it's own way, using the original Column name.

Using the synonymed attribute name would make things easier for user.
One plus side is that setters/getters would actually be triggered.

Original issue reported on code.google.com by iElect...@gmail.com on 30 Mar 2009 at 6:45

GoogleCodeExporter commented 9 years ago
that is not what I see (and the test confirms).  if what you were saying in the 
case
then we would see _foo in the .fields.

If you have a case where it does break please include it.

class Synonym(Base):
    __tablename__ = 'synonyms'
    id = Column(Integer, primary_key=True)
    _foo = Column(Text, nullable=True)
    def _set_foo(self, foo):
        self._foo = "SOMEFOO " + foo
    def _get_foo(self):
        return self._foo
    foo = synonym('_foo', descriptor=property(_get_foo, _set_foo))

>>> fs_s = FieldSet(Synonym)
>>> fs_s._fields
{'foo': AttributeField(foo), 'id': AttributeField(id)}

Original comment by jbel...@gmail.com on 31 Mar 2009 at 3:26

GoogleCodeExporter commented 9 years ago
guess I should be more specific,

self.field.name still includes the old non-decorated field value (if there 
isn't any
second storage for the field name), it would be useful to use synonym also
internally. It would make customizing FA easier.

Original comment by iElect...@gmail.com on 31 Mar 2009 at 9:21