From b1afee44cba746be519f9fe03c9eae3024ec77f3 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Tue, 30 Jun 2020 14:23:25 +0200 Subject: [PATCH] [jOOQ/jOOQ#10139] Unknown columns in code generator queries for Firebird 2.5 --- .../jooq/meta/firebird/FirebirdDatabase.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/jOOQ-meta/src/main/java/org/jooq/meta/firebird/FirebirdDatabase.java b/jOOQ-meta/src/main/java/org/jooq/meta/firebird/FirebirdDatabase.java index 5671723b9b..f29ea326c5 100644 --- a/jOOQ-meta/src/main/java/org/jooq/meta/firebird/FirebirdDatabase.java +++ b/jOOQ-meta/src/main/java/org/jooq/meta/firebird/FirebirdDatabase.java @@ -110,6 +110,8 @@ import org.jooq.util.firebird.FirebirdDataType; */ public class FirebirdDatabase extends AbstractDatabase { + private static Boolean is30; + public FirebirdDatabase() { // Firebird doesn't know schemata @@ -351,12 +353,16 @@ public class FirebirdDatabase extends AbstractDatabase { for (Record record : create() .select( trim(RDB$GENERATORS.RDB$GENERATOR_NAME).as(RDB$GENERATORS.RDB$GENERATOR_NAME), - nullif(RDB$GENERATORS.RDB$INITIAL_VALUE, zero()).as(RDB$GENERATORS.RDB$INITIAL_VALUE), - nullif(RDB$GENERATORS.RDB$GENERATOR_INCREMENT, one()).as(RDB$GENERATORS.RDB$GENERATOR_INCREMENT) + (is30() + ? nullif(RDB$GENERATORS.RDB$INITIAL_VALUE, zero()) + : zero()) + .as(RDB$GENERATORS.RDB$INITIAL_VALUE), + (is30() + ? nullif(RDB$GENERATORS.RDB$GENERATOR_INCREMENT, one()) + : one()).as(RDB$GENERATORS.RDB$GENERATOR_INCREMENT) ) .from(RDB$GENERATORS) - .orderBy(1) - .fetch()) { + .orderBy(1)) { SchemaDefinition schema = getSchemata().get(0); DataTypeDefinition type = new DefaultDataTypeDefinition( @@ -520,4 +526,13 @@ public class FirebirdDatabase extends AbstractDatabase { .when((short) 261, (short) 0) .otherwise(f.RDB$CHARACTER_LENGTH); } + + boolean is30() { + + // [#4254] RDB$GENERATORS.RDB$INITIAL_VALUE was added in Firebird 3.0 only + if (is30 == null) + is30 = exists(RDB$GENERATORS.RDB$INITIAL_VALUE); + + return is30; + } }