SQL extension: INSERT ... ON CONFLICT

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SQL extension: INSERT ... ON CONFLICT

Alex Povolotsky
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

Alex

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SQL extension: INSERT ... ON CONFLICT

Matt S Trout-2
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.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Loading...