[jifty-devel] Database setup question

Bort, Paul pbort at tmwsystems.com
Fri Apr 21 18:09:37 EDT 2006


I'm building an on-line testing application (testing people, not
software) and I can't figure out how to specify a function as a default
when defining a column. (I'm using PostgreSQL.)

The column contains a timestamp, and I'd like it to default to the time
the record was inserted. This is no problem in PG: 

CREATE TABLE foo ( bar timestamp default now() );

And the time of the insert will be used as the default. But if there are
quotes around the function, like this:

CREATE TABLE foo ( bar timestamp default 'now()' );

Then the default is set as the time the TABLE was created. Not so
helpful.

The column definition in the model is currently as follows:

column created_on =>
    label is 'Date this test was created',
    type is 'timestamp',
    default is 'now()';

And Jifty dutifully quotes the default when constructing the CREATE
TABLE statement.

As expected, if I leave the quotes off in the column definition, Perl
goes looking for a function named 'now', so that's out.

Any ideas? Undocumented magic quote control? I'd rather not have to
change the schema outside Jifty if possible.

Regards,
Paul



More information about the jifty-devel mailing list