[Dbix-class] SQL extension: INSERT ... ON CONFLICT

Matt S Trout mst at shadowcat.co.uk
Tue Jan 24 22:53:09 GMT 2017


On Tue, Jan 10, 2017 at 06:39:46PM +0300, Alex Povolotsky wrote:
> Hello
> 
> Are there any provisions to make Postgres' INSERT ON CONFLICT
> extension easier than rewrite all DBIx::Class or use literal insert?
> 
> ON CONFLICT must be placed after VALUES (), before RETURNING

The logical approach to that, would, I think, be to add support for
that at the SQLMaker level (maybe not mainline SQL::Abstract because
of the fact it varies between databases).

The trickier question is how you then expose that at the DBIx::Class
level - some users might benefit from e.g. find_or_create using it
automatically, but that would have to be opt-in and there should
likely be some sort of more explicit API to it.

An attribute to be passed to storage of some sort, plus code to
accept attributes to Row's insert() method, maybe?

This is one of those things where implementing it is mostly going to
me a simple matter of programming, but figuring out what shape of
thing *to* implement is a little trickier.

So, as a starting point - imagine the feature you wanted already
existed, and tell us how you'd expect it to work?

-- 
Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue

http://shadowcat.co.uk/blog/matt-s-trout/   http://twitter.com/shadowcat_mst/

Email me now on mst (at) shadowcat.co.uk and let's chat about how our CPAN
commercial support, training and consultancy packages could help your team.



More information about the DBIx-Class mailing list