[#5552] Add a MySQL 8 SQLDialect version

This commit is contained in:
lukaseder 2017-07-19 12:12:06 +02:00
parent 2343b19338
commit feaddd71d4
11 changed files with 73 additions and 6 deletions

View File

@ -104,6 +104,8 @@ public class Databases {
case H2: result = H2Database.class; break;
case HSQLDB: result = HSQLDBDatabase.class; break;
case MARIADB: result = MariaDBDatabase.class; break;
case MYSQL_5_7:
case MYSQL_8_0:
case MYSQL: result = MySQLDatabase.class; break;
case POSTGRES_9_3:
case POSTGRES_9_4:

View File

@ -120,6 +120,16 @@ public enum SQLDialect {
*/
MYSQL("MySQL", false),
/**
* The MySQL 5.7 dialect.
*/
MYSQL_5_7("MySQL", false, MYSQL, null),
/**
* The MySQL 8.0 dialect.
*/
MYSQL_8_0("MySQL", false, MYSQL, MYSQL_5_7),
/**
* The PostgreSQL dialect family.
* <p>

View File

@ -3372,7 +3372,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
@Override
public BigInteger lastID() {
switch (configuration().dialect().family()) {
switch (configuration().family()) {
case DERBY: {
Field<BigInteger> field = field("identity_val_local()", BigInteger.class);
return select(field).fetchOne(field);

View File

@ -106,7 +106,7 @@ final class DeleteQueryImpl<R extends Record> extends AbstractDMLQuery<R> implem
// [#2464] MySQL supports a peculiar multi-table DELETE syntax for aliased tables:
// DELETE t1 FROM my_table AS t1
if (asList(MARIADB, MYSQL).contains(ctx.configuration().dialect())) {
if (asList(MARIADB, MYSQL).contains(ctx.family())) {
// [#2579] [#6304] TableAlias discovery
if (Tools.alias(table) != null)

View File

@ -306,6 +306,8 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
// MySQL has a nice, native syntax for this
case MARIADB:
case MYSQL_5_7:
case MYSQL_8_0:
case MYSQL:
case SQLITE: {
toSQLInsert(ctx);

View File

@ -270,6 +270,8 @@ final class Limit extends AbstractQueryPart {
// [#4785] OFFSET cannot be without LIMIT
case H2:
case MARIADB:
case MYSQL_5_7:
case MYSQL_8_0:
case MYSQL:
case SQLITE: {
context.castMode(NEVER)

View File

@ -57,7 +57,7 @@ final class MD5 extends AbstractFunction<String> {
@Override
final Field<String> getFunction0(Configuration configuration) {
switch (configuration.dialect().family()) {
switch (configuration.family()) {

View File

@ -674,7 +674,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
}
}
else if (forShare) {
switch (dialect) {
switch (family) {
// MySQL has a non-standard implementation for the "FOR SHARE" clause
case MARIADB:

View File

@ -102,7 +102,7 @@ final class SortFieldImpl<T> extends AbstractQueryPart implements SortField<T> {
@Override
public final void accept(Context<?> ctx) {
if (nullsFirst || nullsLast) {
switch (ctx.configuration().dialect().family()) {
switch (ctx.family()) {

View File

@ -1944,7 +1944,7 @@ final class Tools {
*/
static final boolean needsBackslashEscaping(Configuration configuration) {
BackslashEscaping escaping = getBackslashEscaping(configuration.settings());
return escaping == ON || (escaping == DEFAULT && EnumSet.of(MARIADB, MYSQL).contains(configuration.dialect().family()));
return escaping == ON || (escaping == DEFAULT && EnumSet.of(MARIADB, MYSQL).contains(configuration.family()));
}
/**

51
pom.xml
View File

@ -413,6 +413,57 @@