From 9e21abc16639934b67749363d7a931fb7a545581 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Wed, 7 May 2014 17:29:23 +0200 Subject: [PATCH] [#883] DDL fixes --- .../org/jooq/test/all/testcases/DDLTests.java | 28 +++++-------------- .../java/org/jooq/impl/AlterTableImpl.java | 22 +++++++++++++-- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/jOOQ-test/src/test/java/org/jooq/test/all/testcases/DDLTests.java b/jOOQ-test/src/test/java/org/jooq/test/all/testcases/DDLTests.java index 645d0e9d1a..ebdf043e45 100644 --- a/jOOQ-test/src/test/java/org/jooq/test/all/testcases/DDLTests.java +++ b/jOOQ-test/src/test/java/org/jooq/test/all/testcases/DDLTests.java @@ -44,6 +44,7 @@ import static java.util.Arrays.asList; import static org.jooq.SQLDialect.DERBY; import static org.jooq.SQLDialect.FIREBIRD; // ... +import static org.jooq.impl.DSL.field; import static org.jooq.impl.DSL.table; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -135,7 +136,7 @@ extends BaseTest ctx) { + SQLDialect family = ctx.configuration().dialect().family(); + ctx.start(ALTER_TABLE_TABLE) .keyword("alter table").sql(" ").visit(table) .end(ALTER_TABLE_TABLE); @@ -191,8 +197,20 @@ class AlterTableImpl extends AbstractQuery implements .qualify(true); if (alterType != null) { - ctx.sql(" ") - .keyword(alterType.getCastTypeName(ctx.configuration())); + if (asList(POSTGRES).contains(family)) { + ctx.sql(" ").keyword("type"); + } + /* [pro] xx + xxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x + xxxxxxxxx xxxxxxxxxxxxxxx xxxx xxxxxxx + x + xx [/pro] */ + + ctx.sql(" ").keyword(alterType.getCastTypeName(ctx.configuration())); + + if (!alterType.nullable()) { + ctx.sql(" ").keyword("not null"); + } } else if (alterDefault != null) { ctx.start(ALTER_TABLE_ALTER_DEFAULT)