empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jan (JIRA)" <empire-db-...@incubator.apache.org>
Subject [jira] [Commented] (EMPIREDB-247) Add Support for "insertOrUpdate" ("UPSERT")
Date Fri, 12 Aug 2016 10:47:20 GMT

    [ https://issues.apache.org/jira/browse/EMPIREDB-247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15418664#comment-15418664
] 

jan commented on EMPIREDB-247:
------------------------------

Branch EMPIREDB-247 was created.

updateOrInsert is the better naming here.

The default (DbDatabase.executeUpdateOrInsert) should be UPDATE, nothing update -> INSERT,
so its clear you have to define a WHERE clause. Changed in commit 7a41de0a64ea2414b991ba13b1e94f351c3ebc19

> Add Support for "insertOrUpdate" ("UPSERT")
> -------------------------------------------
>
>                 Key: EMPIREDB-247
>                 URL: https://issues.apache.org/jira/browse/EMPIREDB-247
>             Project: Empire-DB
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: empire-db-2.4.4
>            Reporter: jan
>            Priority: Minor
>
> It should be possible to create a "insertOrUpdate" statement from a DBCommand and perform
a "executeInsertOrUpdate" in DBDatabase.
> This feature requires database dependent implementations. 
> - for MySQL / MariaDB "INSERT ... ON DUPLICATE KEY UPDATE" (http://dev.mysql.com/doc/refman/5.5/en/insert-on-duplicate.html)
can be used
> - for Oracle "MERGE INTO" can be used
> - for MSSQL merge should work, too
> - for Postgres "INSERT ... ON CONFLICT UPDATE" (https://wiki.postgresql.org/wiki/UPSERT)
can be used
> DBDatabase.executeInsertOrUpdate could use something like
> int count = db.executeUpdate(cmd, conn);
> if (count < 1) {
> 	// nothing updated -> INSERT
> 	count += db.executeInsert(cmd, conn);
> }
> return count;
> as fallback. I dont think a fallback is possible in DBCommand, so the default implementation
should throw a NotSupportedException.
> The DBDriverFeature should be extended by PERFORM_INSERT_OR_UPDATE or maybe PERFORM_UPSERT.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message