Re: Bit by "commands ignored until end of transaction block" again - Mailing list pgsql-sql

From Stephen Frost
Subject Re: Bit by "commands ignored until end of transaction block" again
Date
Msg-id 20090723105516.GJ23840@tamriel.snowman.net
Whole thread Raw
In response to Re: Bit by "commands ignored until end of transaction block" again  (Glenn Maynard <glenn@zewt.org>)
List pgsql-sql
* Glenn Maynard (glenn@zewt.org) wrote:
> > The ORM can't control transactions, can't call functions or can't set
> > savepoints?
>
> It can't write the necessary SQL to say "insert this unless it already
> exists", namely:

If it can't cleanly handle failure cases like this one, then I think
your issue is with your ORM and not with PG.  An INSERT failing on a
uniqueness violation is actually a rather big deal in a relational
database and not erroring on it goes quite against data integrity
considerations.

If your ORM could call a function instead, you could handle the insert
and error-check in the function, to make up for the lack of intelligence
in the ORM.  Another option would be to have a 'fake' table, which has
no rows in it and just has an 'ON INSERT' trigger that calls a function
to handle this.  That could also be a view with a do-instead rule, if
the ORM has to query the same table.

I would think the time would better be spent fixing the ORM though.
Thanks,
    Stephen

pgsql-sql by date:

Previous
From: Glenn Maynard
Date:
Subject: Re: Need magical advice for counting NOTHING
Next
From: Adrian Klaver
Date:
Subject: Re: Bit by "commands ignored until end of transaction block" again