On 6/27/06 3:03 PM, Jonathan Vanasco wrote:
> if postgres is this:
> 
> create table stuff ( id integer not null primary key , name varchar
> (40), active boolean default true );
> 
> and rosedb::object subclass is this
> 
> __PACKAGE__->meta->table('stuff');
> __PACKAGE__->meta->columns(qw(id name active ));
> __PACKAGE__->meta->primary_key_columns('id');
> 
> new inserts like this:
> 
>      rosedbObject->new( id=> 1 , name=>'your mom' )->save;
>                                                    ^^^^^^
> will create a null value in 'active'

(Underlined part added, since I think that's what you meant to type.)

Right, because you did not specify a default value for the "active" column,
and RDBO includes values for all columns on insert.

> is there any way to not define the default value in perl, and just
> let the db specify it?

Well, you can auto-initialize your columns.  This will look up column
information, including default values, from the database.  You can also
auto-initialize your entire class, which will pick up the primary key,
foreign keys, and so on.  Both of these options mean that the database will
be accessed when this module is loaded.

But it'd be simpler to just specify the default value in the Perl code.

The update() method has a changes_only parameter that instructs it to only
update the columns whose values have been modified.  I suppose I should add
the same option to the insert() method (thus making it also valid on all
calls to the save() method).  I'll add it to my list...

-John




Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to