[#7185] Emulate CREATE VIEW IF NOT EXISTS in PostgreSQL
This commit is contained in:
parent
705476f620
commit
dd7404c535
@ -47,6 +47,7 @@ import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
@ -88,7 +89,7 @@ final class CreateViewImpl<R extends Record> extends AbstractQuery implements
|
||||
*/
|
||||
private static final long serialVersionUID = 8904572826501186329L;
|
||||
private static final Clause[] CLAUSES = { CREATE_VIEW };
|
||||
private static final EnumSet<SQLDialect> NO_SUPPORT_IF_NOT_EXISTS = EnumSet.of(DERBY, FIREBIRD);
|
||||
private static final EnumSet<SQLDialect> NO_SUPPORT_IF_NOT_EXISTS = EnumSet.of(DERBY, FIREBIRD, POSTGRES);
|
||||
|
||||
private final boolean ifNotExists;
|
||||
private final Table<?> view;
|
||||
|
||||
@ -254,6 +254,7 @@ final class Keywords {
|
||||
static final Keyword K_SIBLINGS = keyword("siblings");
|
||||
static final Keyword K_SKIP = keyword("skip");
|
||||
static final Keyword K_SQL = keyword("sql");
|
||||
static final Keyword K_SQLSTATE = keyword("sqlstate");
|
||||
static final Keyword K_START_AT = keyword("start at");
|
||||
static final Keyword K_START_WITH = keyword("start with");
|
||||
static final Keyword K_SWITCH = keyword("switch");
|
||||
|
||||
@ -125,6 +125,7 @@ import static org.jooq.impl.Keywords.K_RAISE;
|
||||
import static org.jooq.impl.Keywords.K_RAISERROR;
|
||||
import static org.jooq.impl.Keywords.K_SERIAL;
|
||||
import static org.jooq.impl.Keywords.K_SERIAL8;
|
||||
import static org.jooq.impl.Keywords.K_SQLSTATE;
|
||||
import static org.jooq.impl.Keywords.K_START_WITH;
|
||||
import static org.jooq.impl.Keywords.K_THEN;
|
||||
import static org.jooq.impl.Keywords.K_THROW;
|
||||
@ -3730,6 +3731,11 @@ final class Tools {
|
||||
break;
|
||||
}
|
||||
|
||||
case POSTGRES: {
|
||||
begin(ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -3895,6 +3901,14 @@ final class Tools {
|
||||
break;
|
||||
}
|
||||
|
||||
case POSTGRES: {
|
||||
ctx.sql(';').formatIndentEnd().formatSeparator()
|
||||
.visit(K_EXCEPTION).formatIndentStart().formatSeparator()
|
||||
.visit(K_WHEN).sql(' ').visit(K_SQLSTATE).sql(" '42P07' ").visit(K_THEN).sql(' ').visit(K_NULL).sql(';').formatIndentEnd();
|
||||
end(ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user