[jifty-devel] Database setup question

Jesse Vincent jesse at bestpractical.com
Sat Apr 22 17:01:16 EDT 2006

On Fri, Apr 21, 2006 at 06:09:37PM -0400, Bort, Paul wrote:
> 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.)

It's something we actually hadn't done yet. 

1) I'd love to see a syntax proposal
2) I have this nagging feeling that the jifty way to do this 
   would actually put the logic into the application.  (IE, a subroutine
   reference as the default). But I can see value in supporting both.

3) Failing tests would be absolutely wonderful.  And the best way to
push us into implementing this. Well, short of implementing it entirely


> 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
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel


More information about the jifty-devel mailing list