[#6475] Added MariaDB support
This commit is contained in:
parent
d3dc0ac857
commit
4d2bbbe73c
@ -79,6 +79,18 @@ package org.jooq;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ package org.jooq.impl;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
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.conf.ParamType.INLINED;
|
||||
@ -130,20 +131,6 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
decrement(ctx.data(), DATA_BLOCK_NESTING);
|
||||
break;
|
||||
}
|
||||
// case MARIADB: {
|
||||
// if (increment(ctx.data(), DATA_BLOCK_NESTING)) {
|
||||
// ctx/*.paramType(INLINED)
|
||||
// */.visit(K_BEGIN).sql(' ').visit(K_NOT).sql(' ').visit(K_ATOMIC)
|
||||
// .formatIndentStart();
|
||||
//
|
||||
// // ctx.data(DATA_FORCE_STATIC_STATEMENT, true);
|
||||
// }
|
||||
//
|
||||
// accept0(ctx);
|
||||
//
|
||||
// decrement(ctx.data(), DATA_BLOCK_NESTING);
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ -195,6 +182,7 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
break;
|
||||
}
|
||||
|
||||
case MARIADB:
|
||||
|
||||
|
||||
|
||||
@ -315,17 +303,8 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
|
||||
|
||||
private static final void acceptNonDeclarations(Context<?> ctx, List<Statement> statements, boolean wrapInBeginEnd) {
|
||||
if (wrapInBeginEnd) {
|
||||
if (ctx.family() == H2)
|
||||
ctx.sql('{');
|
||||
else
|
||||
ctx.visit(K_BEGIN);
|
||||
|
||||
if (ctx.family() == MARIADB)
|
||||
ctx.sql(' ').visit(K_NOT).sql(' ').visit(K_ATOMIC);
|
||||
|
||||
ctx.formatIndentStart();
|
||||
}
|
||||
if (wrapInBeginEnd)
|
||||
begin(ctx);
|
||||
|
||||
if (statements.isEmpty()) {
|
||||
switch (ctx.family()) {
|
||||
@ -419,6 +398,18 @@ final class BlockImpl extends AbstractQuery implements Block {
|
||||
end(ctx);
|
||||
}
|
||||
|
||||
private static final void begin(Context<?> ctx) {
|
||||
if (ctx.family() == H2)
|
||||
ctx.sql('{');
|
||||
else
|
||||
ctx.visit(K_BEGIN);
|
||||
|
||||
if (ctx.family() == MARIADB && toplevel(ctx.data(), DATA_BLOCK_NESTING))
|
||||
ctx.sql(' ').visit(K_NOT).sql(' ').visit(K_ATOMIC);
|
||||
|
||||
ctx.formatIndentStart();
|
||||
}
|
||||
|
||||
private static final void end(Context<?> ctx) {
|
||||
ctx.formatIndentEnd()
|
||||
.formatSeparator();
|
||||
|
||||
@ -124,6 +124,8 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -37,105 +37,104 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.DSL.field;
|
||||
import static org.jooq.impl.Keywords.K_DECLARE;
|
||||
import static org.jooq.impl.Keywords.K_DEFAULT;
|
||||
|
||||
import org.jooq.Context;
|
||||
// ...
|
||||
import org.jooq.Field;
|
||||
// ...
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Statement;
|
||||
// ...
|
||||
import org.jooq.conf.ParamType;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@Pro
|
||||
final class DeclarationImpl<T> extends AbstractStatement implements Declaration<T> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -4976947749196983386L;
|
||||
final Variable<T> variable;
|
||||
final Field<T> value;
|
||||
|
||||
DeclarationImpl(Variable<T> variable, Field<T> value) {
|
||||
this.variable = variable;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Statement set(T v) {
|
||||
return set(Tools.field(v, variable.getDataType()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Statement set(Field<T> v) {
|
||||
return new DeclarationImpl<T>(variable, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Statement set(Select<? extends Record1<T>> v) {
|
||||
return set(field(v));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
case H2:
|
||||
ctx.sql(BlockImpl.variableType(variable))
|
||||
.sql(' ')
|
||||
.sql(variable.getName());
|
||||
|
||||
if (value instanceof ScalarSubquery) {
|
||||
ctx.sql(" = null;")
|
||||
.formatSeparator();
|
||||
|
||||
ctx.visit(variable.set(value));
|
||||
}
|
||||
else if (value != null)
|
||||
ctx.sql(" = ").visit(value);
|
||||
else
|
||||
ctx.sql(" = null");
|
||||
|
||||
break;
|
||||
|
||||
case POSTGRES:
|
||||
case ORACLE:
|
||||
ctx.visit(variable).sql(' ');
|
||||
Tools.toSQLDDLTypeDeclaration(ctx, variable.getDataType());
|
||||
|
||||
if (value != null)
|
||||
ctx.sql(" := ").visit(value);
|
||||
|
||||
break;
|
||||
|
||||
case DB2:
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLSERVER:
|
||||
default:
|
||||
ctx.visit(K_DECLARE).sql(' ').visit(variable).sql(' ');
|
||||
Tools.toSQLDDLTypeDeclaration(ctx, variable.getDataType());
|
||||
|
||||
ParamType previous = ctx.paramType();
|
||||
if (value != null)
|
||||
if (ctx.family() == SQLSERVER)
|
||||
ctx.sql(" = ").visit(value);
|
||||
else
|
||||
ctx.sql(' ').visit(K_DEFAULT).sql(' ').paramType(INLINED).visit(value).paramType(previous);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* [/pro] */
|
||||
@ -125,6 +125,8 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -37,7 +37,19 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
// ...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -82,6 +82,8 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -277,6 +277,19 @@ package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user