Bug? autoNowAdd: true when defining db.DateTimeProperty does not allow the field to be changed later

7 views
Skip to first unread message

Giacecco

unread,
Jul 31, 2010, 11:23:14 AM7/31/10
to appenginejs
See this model definition:

var TwitterMonitor = export.TwitterMonitor =
db.Model.extend("TwitterMonitor", {
fromDate: new db.DateTimeProperty(),
toDate : new db.DateTimeProperty()
});

I have noticed that if I pass {autoNowAdd: true} as a parameter to the
db.DateTimeProperty fields, I will not be able to change their value
later.

E.g.

var fromDate = new Date(), toDate = new Date();
fromDate.addDays(-3);
toDate.addDays(3);
twitterMonitor = new TwitterMonitor({
fromDate: fromDate,
toDate : toDate
});
twitterMonitor.put();

... and what I find in both fromDate and toDate is the "now" at the
moment of execution.

G.

George Moschovitis

unread,
Jul 31, 2010, 11:59:35 AM7/31/10
to appen...@googlegroups.com
Hmm, I am not sure what the correct behavior should be...
I will experiment with the Python API and fix accordingly. Thanks for identifying the problem.
-g.
--
http://www.gmosx.com/blog
http://www.appenginejs.org

Panagiotis Astithas

unread,
Jul 31, 2010, 12:02:58 PM7/31/10
to appen...@googlegroups.com
On Sat, Jul 31, 2010 at 6:23 PM, Giacecco <giac...@giacec.co> wrote:

Isn't that the whole point of the autoNowAdd flag? To have the value
automatically set for you by the container? Why use that flag if you
intend to set the value yourself?

Cheers,
--
Panagiotis Astithas
http://www.linkedin.com/in/astithas

Giacecco

unread,
Jul 31, 2010, 3:00:49 PM7/31/10
to appenginejs
I'd like to use the flag to set a default value to the date, but not
to stop me changing it if I want to!

G.


On Jul 31, 5:02 pm, Panagiotis Astithas <past...@gmail.com> wrote:

George Moschovitis

unread,
Jul 31, 2010, 3:08:34 PM7/31/10
to appen...@googlegroups.com
I 'll see what I can do...

-g.

George Moschovitis

unread,
Aug 1, 2010, 2:28:31 AM8/1/10
to appen...@googlegroups.com
I *think* the current implementation is compatible with the Python API (ie the Python API forces now).

-g.
Reply all
Reply to author
Forward
0 new messages