[Dbix-class] possibly stupid question
Daniel Westermann-Clark
daniel at acceleration.net
Sat Apr 22 01:27:12 CEST 2006
On 2006-04-21 15:05:06 -0700, James Marca wrote:
> CREATE TABLE geom_ids (
> gid serial NOT NULL PRIMARY KEY
> );
The only way I could get PostgreSQL 8.0.4 to insert into a table like
this was to say:
INSERT INTO geom_ids DEFAULT VALUES;
Or:
INSERT INTO geom_ids (id) VALUES (DEFAULT);
> I set up the following Schema:
>
> package Testbed::SpatialVDS::Model::Schema::geom_ids;
> use strict;
> use warnings;
> use base 'DBIx::Class';
> __PACKAGE__->load_components(qw/PK::Auto Core/);
> __PACKAGE__->table('geom_ids');
> __PACKAGE__->add_columns('gid');
> __PACKAGE__->set_primary_key(qw/gid/);
> __PACKAGE__->sequence('geom_ids_gid_seq');
>
> I want to insert a row, using the automatically generated gid, so I
> write
>
> my $vdb =Testbed::SpatialVDS::Model::SpatialVDS->new();
> my $new_geoid = $vdb->resultset('geom_ids')->create({});
Probably PostgreSQL-specific, but try:
my $new_geoid = $vdb->resultset('geom_ids')->create({ id => \'DEFAULT' });
Passing a reference to a scalar prevents quoting, etc.
Could you post the SQL that Class::DBI generates?
--
Daniel Westermann-Clark
More information about the Dbix-class
mailing list