I have created a custom type in order to store denormalized PKs in a
TEXT field. The idea is that the text is converted back and forth from
a set of integers:

http://paste.pocoo.org/show/249784/

This seems to work OK, however if you make a change to the set it's
not picked up by SQLAlchemy on commit.

For example, given the following model:

class Post(DeclarativeBase):
    __tablename__ = "posts"
    id = Column(Integer, primary_key=True)
    votes = Column(DenormalizedText)

    def __init__(self, *args, **kwargs):
        super(Post, self).__init__(*args, **kwargs)
        self.votes = self.votes or set()

If I do this:

post = Post()
post.votes.add(3)

session.add(post)
session.commit()

The value '3' is committed to the 'votes' column as expected.

However if I then try to modify:

post.votes.add(5)
session.commit()

The change to the set is not saved to the DB, i.e. it's still "3".

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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