Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#50 sqlbuilder funcs get cached instead of their value

closed-wont-fix
nobody
General (125)
4
2008-03-07
2004-11-26
Justin A
No

when caching is enabled and you do
foo.bardate=sqlbuilder.func.now()
it updates the db correctly, but foo.bardate then has
the value of the sqlbuilder function:

Discussion

  • Justin A
    Justin A
    2004-11-26

    output and source of program showing bug

     
    Attachments
  • Justin A
    Justin A
    2004-11-26

    Logged In: YES
    user_id=547833

    This is with sqlobject 0.6.

     
  • Oleg Broytman
    Oleg Broytman
    2005-03-01

    Logged In: YES
    user_id=4799

    Ok, now look. You ran the query

    UPDATE dates SET dateb = NOW() WHERE id = 2

    How should SQLObject know the value of NOW() on the server?
    Should it run SELECT? Really, should it run SELECT on the
    attribute assignment?! on any attribute assignment?

     
  • Justin A
    Justin A
    2005-03-01

    Logged In: YES
    user_id=547833

    I would think it should run SELECT on any assignment to a
    function...

     
  • Oleg Broytman
    Oleg Broytman
    2005-03-01

    Logged In: YES
    user_id=4799

    That breaks the rule "do a least unexpected thing". Running
    SELECT upon an assignment is certainly a very unexpected
    beahviour. Even running SELECT upon reading such attribute
    is a bit strange.

    Currently one can overcome that by setting cacheValues to
    False. Well, I must admit the solution solves too much - it
    forces a SELECT for accessing ANY attribute.

    Well, I can be wrong. Can you bring the subject to the
    mailing list? Public discussions about controversial
    subjects are better than SF tracker.

     
  • Ian Bicking
    Ian Bicking
    2005-09-20

    • priority: 5 --> 4
     
  • Ian Bicking
    Ian Bicking
    2005-09-20

    Logged In: YES
    user_id=210337

    As a workaround, if you call obj.sync() or obj.expire()
    after setting one of its attributes to a sqlbuilder object,
    it will refetch the data (immediately or lazily,
    respectively) and get rid of that bad value.

    In this particular case, it is best to use datetime.now
    (e.g., default=datetime.now).

    However, I'm not closing this, as SQLObject should detect
    these objects and call obj.expire() on its own.

     
  • Oleg Broytman
    Oleg Broytman
    2008-03-07

    • status: open --> closed-wont-fix