[Dbix-class] Weird INSERT RETURNING error after updating to DBIx::Class .08123

Steve Kleiman steve at prodhub.com
Mon Jul 12 01:11:22 GMT 2010

Searched the archives on this and didn't see anyone else raise the issue....

Just upgraded to DBIx::Class .08123 from 08120.

I see in the Changelog:

> DBIx::Class
> 0.08121 2010-04-11 18:43:00 (UTC)
>        - Add core support for INSERT RETURNING (for storages that supports this syntax, currently PostgreSQL and Firebird)

I'm using Postgres. Before the update, a simple create query was dispatched as:
> INSERT INTO "project"."vendor_view" ( "name", "project", "classification_xref") VALUES ( 1277144170, 3819016, 10 );

That worked great and returned the last_insert_id as expected.

After upgrading to DBIx::Class . 08123, the SQL generated is now:
> INSERT INTO "project"."vendor_view" ( "name", "project", "classification_xref") VALUES ( 1277144170, 3819016, 10 ) RETURNING id

And that throws the error:
> ERROR:  cannot perform INSERT RETURNING on relation "vendor_view"
> HINT:  You need an unconditional ON INSERT DO INSTEAD rule with a RETURNING clause.

I see in DBIX::Class::Storage::DBI::Pg the comment:
> # only used when INSERT ... RETURNING is disabled
> sub last_insert_id {
> ...
> }

Seems to me I want to disable the RETURNING functionality to make the behavior like it was, but I can't figure out how to do that.

Anyone else experienced this?

Thanks in advance.

-steve kleiman

More information about the DBIx-Class mailing list