Merge branch 'main' of github.com:jOOQ/jOOQ

This commit is contained in:
Lukas Eder 2021-01-18 09:15:19 +01:00
commit b2d7bf5bdd
18 changed files with 1856 additions and 6 deletions

View File

@ -0,0 +1,94 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -0,0 +1,101 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -0,0 +1,94 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -0,0 +1,94 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -0,0 +1,136 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -0,0 +1,73 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -0,0 +1,80 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -0,0 +1,101 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -0,0 +1,141 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -9787,6 +9787,48 @@ public interface DSLContext extends Scope {
@Support({ FIREBIRD, H2, HSQLDB, POSTGRES, SQLITE })
CreateIndexStep createUniqueIndexIfNotExists();
/**
* The <code>CREATE SCHEMA</code> statement.
*
@ -10273,6 +10315,48 @@ public interface DSLContext extends Scope {
@Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES })
DropTableStep dropTemporaryTableIfExists(Table<?> table);
/**
* The <code>DROP VIEW</code> statement.
*

View File

@ -0,0 +1,73 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;

View File

@ -0,0 +1,497 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;

View File

@ -7788,6 +7788,56 @@ public class DSL {
return dsl().createUniqueIndexIfNotExists();
}
/**
* The <code>CREATE SCHEMA</code> statement.
*
@ -8382,6 +8432,56 @@ public class DSL {
return dsl().dropTemporaryTableIfExists(table);
}
/**
* The <code>DROP VIEW</code> statement.
*

View File

@ -3056,6 +3056,32 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new CreateIndexImpl(configuration(), true, true);
}
@Override
public org.jooq.CreateSchemaFinalStep createSchema(@Stringly.Name String schema) {
return new CreateSchemaImpl(configuration(), DSL.schema(DSL.name(schema)), false);
@ -3326,6 +3352,32 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new DropTableImpl(configuration(), true, table, true);
}
@Override
public org.jooq.DropViewFinalStep dropView(@Stringly.Name String view) {
return new DropViewImpl(configuration(), DSL.table(DSL.name(view)), false);

View File

@ -100,7 +100,7 @@ extends
else if (t.getType() == Long.class)
ctx.visit(DSL.lpad(DSL.abs(value).cast(VARCHAR(DefaultDataType.LONG_PRECISION)), inline(DefaultDataType.LONG_PRECISION), inline("0")));
else if (t.scaleDefined())
ctx.visit(DSL.lpad(DSL.abs(value.mul(inline(java.math.BigDecimal.TEN.pow(t.scale())))).cast(VARCHAR(t.precision())), inline(t.precision()), inline("0")));
ctx.visit(DSL.lpad(DSL.abs(value.mul(inline(java.math.BigDecimal.TEN.pow(t.scale())))).cast(t.scale(0)).cast(VARCHAR(t.precision())), inline(t.precision()), inline("0")));
else
ctx.visit(DSL.lpad(DSL.abs(value).cast(VARCHAR(t.precision())), inline(t.precision()), inline("0")));
}

View File

@ -0,0 +1,109 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;

View File

@ -142,6 +142,7 @@ final class Keywords {
static final Keyword K_DROP_SCHEMA = keyword("drop schema");
static final Keyword K_DROP_TABLE = keyword("drop table");
static final Keyword K_DROP_VIEW = keyword("drop view");
static final Keyword K_EACH = keyword("each");
static final Keyword K_ELEMENTS = keyword("elements");
static final Keyword K_ELSE = keyword("else");
static final Keyword K_ELSEIF = keyword("elseif");
@ -171,7 +172,7 @@ final class Keywords {
static final Keyword K_FETCH_FIRST = keyword("fetch first");
static final Keyword K_FETCH_NEXT = keyword("fetch next");
static final Keyword K_FILTER = keyword("filter");
static final Keyword K_FINAL_TABLE = keyword("final table");
static final Keyword K_FINAL = keyword("final");
static final Keyword K_FIRST = keyword("first");
static final Keyword K_FOLLOWING = keyword("following");
static final Keyword K_FOR = keyword("for");
@ -208,6 +209,7 @@ final class Keywords {
static final Keyword K_INLINE = keyword("inline");
static final Keyword K_INNER_JOIN = keyword("inner join");
static final Keyword K_INSERT = keyword("insert");
static final Keyword K_INSTEAD = keyword("instead");
static final Keyword K_INT = keyword("int");
static final Keyword K_INTERVAL = keyword("interval");
static final Keyword K_INTO = keyword("into");
@ -252,7 +254,7 @@ final class Keywords {
static final Keyword K_MONTH = keyword("month");
static final Keyword K_MULTISET = keyword("multiset");
static final Keyword K_NAME = keyword("name");
static final Keyword K_NEW_TABLE = keyword("new table");
static final Keyword K_NEW = keyword("new");
static final Keyword K_NEXTVAL = keyword("nextval");
static final Keyword K_NEXT_VALUE_FOR = keyword("next value for");
static final Keyword K_NO = keyword("no");
@ -271,7 +273,7 @@ final class Keywords {
static final Keyword K_NVARCHAR = keyword("nvarchar");
static final Keyword K_OF = keyword("of");
static final Keyword K_OFFSET = keyword("offset");
static final Keyword K_OLD_TABLE = keyword("old table");
static final Keyword K_OLD = keyword("old");
static final Keyword K_ON = keyword("on");
static final Keyword K_ON_COMMIT_DELETE_ROWS = keyword("on commit delete rows");
static final Keyword K_ON_COMMIT_DROP = keyword("on commit drop");
@ -312,6 +314,7 @@ final class Keywords {
static final Keyword K_RECURSIVE = keyword("recursive");
static final Keyword K_REF = keyword("ref");
static final Keyword K_REFERENCES = keyword("references");
static final Keyword K_REFERENCING = keyword("referencing");
static final Keyword K_REGEXP = keyword("regexp");
static final Keyword K_RENAME = keyword("rename");
static final Keyword K_RENAME_COLUMN = keyword("rename column");
@ -376,6 +379,7 @@ final class Keywords {
static final Keyword K_TOP = keyword("top");
static final Keyword K_TRAILING = keyword("trailing");
static final Keyword K_TRIM = keyword("trim");
static final Keyword K_TRIGGER = keyword("trigger");
static final Keyword K_TRUE = keyword("true");
static final Keyword K_TRUNCATE_TABLE = keyword("truncate table");
static final Keyword K_TYPE = keyword("type");

View File

@ -2721,12 +2721,15 @@ final class ParserContext {
return parseDropTable(false);
else if (parseKeywordIf("TEMPORARY TABLE"))
return parseDropTable(true);
else if (parseKeywordIf("TRIGGER") && requireProEdition())
;
else if (parseKeywordIf("TYPE"))
return parseDropType();
else if (parseKeywordIf("TABLESPACE"))
throw notImplemented("DROP TABLESPACE");
else if (parseKeywordIf("TRIGGER"))
throw notImplemented("DROP TRIGGER", "https://github.com/jOOQ/jOOQ/issues/6956");
break;
@ -4891,6 +4894,20 @@ final class ParserContext {
return s2;
}
private final DDLQuery parseDropType() {
boolean ifExists = parseKeywordIf("IF EXISTS");
List<Name> typeNames = parseIdentifiers();