Hi Michael,
Thank you for the reply, the logs I got from the sqlalchemy shown as below:

2011-12-01 13:53:49,062 INFO sqlalchemy.engine.base.Engine.0x...29cc UPDATE
base_media SET name=%s WHERE base_media.id = %s
2011-12-01 13:53:49,062 INFO [sqlalchemy.engine.base.Engine.0x...29cc]
UPDATE base_media SET name=%s WHERE base_media.id = %s
2011-12-01 13:53:49,063 INFO sqlalchemy.engine.base.Engine.0x...29cc
('waucissa2.mov', 42L)
2011-12-01 13:53:49,063 INFO [sqlalchemy.engine.base.Engine.0x...29cc]
('waucissa2.mov', 42L)
2011-12-01 13:53:49,066 INFO sqlalchemy.engine.base.Engine.0x...29cc INSERT
INTO interm_hidden_vsblzrs_to_resources (element_id, base_visibilizer_id)
VALUES (%s, %s)
2011-12-01 13:53:49,066 INFO [sqlalchemy.engine.base.Engine.0x...29cc]
INSERT INTO interm_hidden_vsblzrs_to_resources (element_id,
base_visibilizer_id) VALUES (%s, %s)
2011-12-01 13:53:49,066 INFO sqlalchemy.engine.base.Engine.0x...29cc (42L,
5L)
2011-12-01 13:53:49,066 INFO [sqlalchemy.engine.base.Engine.0x...29cc]
(42L, 5L)
2011-12-01 13:53:49,067 INFO sqlalchemy.engine.base.Engine.0x...29cc COMMIT
2011-12-01 13:53:49,067 INFO [sqlalchemy.engine.base.Engine.0x...29cc]
COMMIT

As you see, sqlalchemy only updated the name field in the base_media table,
so the "onupdate=callable" should be firing since the "modifyUserId" column
was not being touched. I will appreciate if you would give some suggestions
on it. By the way, I am using 0.6.8, not 0.6.4. Thank you very much!

Wubin


On Thu, Dec 1, 2011 at 1:25 PM, Michael Bayer <[email protected]>wrote:

>
> On Dec 1, 2011, at 1:32 AM, Wubin wrote:
>
> > Hi,
> > I created two classes "Resource" and "BaseMedia", and "BaseMedia" is a
> > subclass of "Resource". The table mapping is implemented as below:
> >
> > class Resource(Database.Base):
> >       __tablename__ = "resources"
> >       createUserId = Column("create_user_id", Integer,
> > ForeignKey("users.id"), nullable=True, key="createUserId",
> > default=currentUserId)
> >       modifyUserId = Column("modify_user_id", Integer,
> > ForeignKey("users.id"), nullable=True, key="modifyUserId",
> > default=currentUserId, onupdate=currentUserId)
> >
> > class BaseMedia(Resource.Resource):
> >       __tablename__ = "base_media"
> >        id = Column("id", Integer, ForeignKey("resources.id"),
> > primary_key=True)
> >       __mapper_args__ = { 'extension':
> > BaseMediaMapperExtension.BaseMediaMapperExtension() }
> >       name = Column("name", Unicode(50))
> >       type = Column("type", String(50))
> >       size = Column("size", Integer)
> >
> > and then, when I try to use session.add() to insert a new BaseMedia
> > object, the parameter "default=currentUserId" in both "createUserId"
> > and "modifyUserId" columns is working properly. However, if I use
> > session.merge() to update the "name" column in an existing BaseMedia
> > object, the "name" field is updated correctly in the database, but the
> > parameter "onupdate=currentUserId" is not firing, and therefore I
> > couldn't update the "modifyUserId" field with this "onupdate"
> > parameter.
>
> Do you see an UPDATE occurring in the logs ?   The UPDATE statement should
> include a SET clause for the modifyUserId column unconditionally - the
> value in the parameter list might shed some light on what's actually
> happening.
>
> Particularly with merge(), the value from the merged object is likely
> being passed as the new value of modifyUserId and that's what's being used.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
>

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

Reply via email to