[jOOQ/jOOQ#13508] Add MySQL support for INSERT .. ON DUPLICATE KEY UPDATE .. WHERE

This commit is contained in:
Lukas Eder 2022-05-03 08:56:27 +02:00
parent 8139c613b3
commit 86373d9897
3 changed files with 52 additions and 40 deletions

View File

@ -37,16 +37,27 @@
*/
package org.jooq;
import org.jetbrains.annotations.*;
// ...
// ...
// ...
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DERBY;
// ...
import static org.jooq.SQLDialect.H2;
// ...
import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
// ...
import static org.jooq.SQLDialect.SQLITE;
// ...
import static org.jooq.SQLDialect.YUGABYTEDB;
import org.jooq.impl.DSL;
import org.jetbrains.annotations.NotNull;
/**
* This type is used for the {@link Insert}'s DSL API.
* <p>
@ -90,7 +101,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* {@link Operator#AND} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> and(Condition condition);
/**
@ -98,7 +109,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* {@link Operator#AND} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> and(Field<Boolean> condition);
/**
@ -114,7 +125,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> and(SQL sql);
@ -131,7 +142,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> and(String sql);
@ -149,7 +160,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> and(String sql, Object... bindings);
@ -167,7 +178,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> and(String sql, QueryPart... parts);
@ -176,7 +187,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* the {@link Operator#AND} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> andNot(Condition condition);
/**
@ -184,7 +195,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* the {@link Operator#AND} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> andNot(Field<Boolean> condition);
/**
@ -192,7 +203,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* the {@link Operator#AND} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> andExists(Select<?> select);
/**
@ -200,7 +211,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* the {@link Operator#AND} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> andNotExists(Select<?> select);
/**
@ -208,7 +219,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* {@link Operator#OR} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> or(Condition condition);
/**
@ -216,7 +227,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* {@link Operator#OR} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> or(Field<Boolean> condition);
/**
@ -232,7 +243,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> or(SQL sql);
@ -249,7 +260,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> or(String sql);
@ -267,7 +278,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> or(String sql, Object... bindings);
@ -285,7 +296,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> or(String sql, QueryPart... parts);
@ -294,7 +305,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* the {@link Operator#OR} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> orNot(Condition condition);
/**
@ -302,7 +313,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* the {@link Operator#OR} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> orNot(Field<Boolean> condition);
/**
@ -310,7 +321,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* the {@link Operator#OR} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> orExists(Select<?> select);
/**
@ -318,6 +329,6 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* the {@link Operator#OR} operator and proceed to the next step.
*/
@NotNull @CheckReturnValue
@Support({ POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> orNotExists(Select<?> select);
}

View File

@ -39,7 +39,7 @@ package org.jooq;
import org.jetbrains.annotations.*;
// ...
// ...
// ...
import static org.jooq.SQLDialect.CUBRID;
@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.H2;
// ...
import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
// ...
@ -102,7 +103,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> where(Condition condition);
/**
@ -111,7 +112,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* connecting them with each other using {@link Operator#AND}.
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> where(Condition... conditions);
/**
@ -120,7 +121,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* connecting them with each other using {@link Operator#AND}.
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> where(Collection<? extends Condition> conditions);
/**
@ -128,7 +129,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> where(Field<Boolean> field);
/**
@ -144,7 +145,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> where(SQL sql);
@ -161,7 +162,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> where(String sql);
@ -179,7 +180,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> where(String sql, Object... bindings);
@ -197,7 +198,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see SQL
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
@PlainSQL
InsertOnConflictConditionStep<R> where(String sql, QueryPart... parts);
@ -206,7 +207,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> whereExists(Select<?> select);
/**
@ -214,6 +215,6 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@NotNull @CheckReturnValue
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
InsertOnConflictConditionStep<R> whereNotExists(Select<?> select);
}

View File

@ -279,7 +279,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>,
* @param condition The condition
*/
@Override
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
void addConditions(Condition condition);
/**
@ -292,7 +292,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>,
* @param conditions The condition
*/
@Override
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
void addConditions(Condition... conditions);
/**
@ -305,7 +305,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>,
* @param conditions The condition
*/
@Override
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
void addConditions(Collection<? extends Condition> conditions);
/**
@ -318,7 +318,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>,
* @param condition The condition
*/
@Override
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
void addConditions(Operator operator, Condition condition);
/**
@ -331,7 +331,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>,
* @param conditions The condition
*/
@Override
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
void addConditions(Operator operator, Condition... conditions);
/**
@ -344,7 +344,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>,
* @param conditions The condition
*/
@Override
@Support({ CUBRID, DERBY, H2, MARIADB, POSTGRES, SQLITE, YUGABYTEDB })
@Support({ CUBRID, DERBY, H2, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
void addConditions(Operator operator, Collection<? extends Condition> conditions);
/**