Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@
<trust file=".*-sources[.]jar" regex="true" reason="IDEs download sources jars during Gradle import; they are not on compile/runtime classpaths"/>
</trusted-artifacts>
<ignored-keys>
<ignored-key id="1364C5E2DF3E99C5" reason="Key couldn't be downloaded from any key server"/>
<ignored-key id="386F8FCD70E6AF64" reason="Key couldn't be downloaded from any key server"/>
<ignored-key id="4406B84C1661DCD1" reason="Key couldn't be downloaded from any key server"/>
<ignored-key id="58BD11D32974088F" reason="Key couldn't be downloaded from any key server"/>
<ignored-key id="61651257058D3757" reason="Signs org.testfx:openjfx-monocle; not published on any key server, so that jar is pinned by checksum"/>
<ignored-key id="66F8E4860BF74983" reason="Key couldn't be downloaded from any key server"/>
<ignored-key id="700E4F39BC05364B" reason="Key couldn't be downloaded from any key server"/>
<ignored-key id="739D53C0A4CF0287" reason="Signs com.h2database:h2; not published on any key server, so that jar is pinned by checksum"/>
<ignored-key id="80EF47E549604C05" reason="Key couldn't be downloaded from any key server"/>
<ignored-key id="91C65920226E26BD" reason="Key couldn't be downloaded from any key server"/>
<ignored-key id="DD2B17ACA29BD7AB" reason="Key couldn't be downloaded from any key server"/>
Expand Down Expand Up @@ -859,6 +864,11 @@
<sha512 value="91b1127c967f765da06ca16aee7206aac74c83b28cdfd493b7ed24961abad4717c6b1230fc3e517ad5f17a8c47d01f2b12d2ab0c9d372ec218bc94b3230a0983" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
</artifact>
</component>
<component group="com.h2database" name="h2" version="2.5.252">
<artifact name="h2-2.5.252.jar">
<sha512 value="13fde1ed16eb80f169f204f0d61270f8dc6e98edd01e464d05e74502137d39ed2c712de4d8768d459392fe4b84cf385c161aec26502cfc342bb218596d205f96" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
</artifact>
</component>
<component group="com.h3xstream.findsecbugs" name="findsecbugs-plugin" version="1.13.0">
<artifact name="findsecbugs-plugin-1.13.0.jar">
<pgp value="CFC10B69382CBCF5387E51484ECE492B63E38ACF"/>
Expand Down Expand Up @@ -1207,6 +1217,12 @@
<pgp value="48B086A7D843CFA258E83286928FBF39003C0425"/>
</artifact>
</component>
<component group="io.r2dbc" name="r2dbc-spi" version="1.0.0.RELEASE">
<artifact name="r2dbc-spi-1.0.0.RELEASE.jar">
<sha256 value="a5846c59fea336431a4ae72ca14edbf5299b78486fa308eafb383f4ae0ea74e5" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
<sha512 value="c5890241d219e903b48c3666ef376ec2394a5715e7c5a8a6b5209e2d3b3676a13405d77288e6bc9a7e59782de9f254ab4b3e272a4ce970385ce3d82453886209" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
</artifact>
</component>
<component group="io.reactivex.rxjava3" name="rxjava" version="3.1.10">
<artifact name="rxjava-3.1.10.jar">
<pgp value="E9CC3CD1AE59E851E4DB3FA350FFD7487D34B5B9"/>
Expand Down Expand Up @@ -3113,6 +3129,12 @@
<sha512 value="ac2ced8c9308a6f1606dbd4e15dce428d0fecef9bbd16d3a350368067af7a4aab3773242f46a7d89b9f7422942ba4fc10582232977a3d47240686f8c1a5e66f6" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jooq" name="jooq" version="3.19.36">
<artifact name="jooq-3.19.36.jar">
<sha256 value="3f155f81c017a1ab456959cedb5597bfe52a893115b7dcd91514c0a5b56138dd" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
<sha512 value="db9cfe587707e5102ecd8890e619de780517392d14cfedf6628c7ca17c3be2ef6b80a5754b458822397d68c8ff67f550b2717f9728ad6f5146e2a79ed395690d" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
</artifact>
</component>
<component group="org.jparsec" name="jparsec" version="3.1">
<artifact name="jparsec-3.1.jar">
<pgp value="E9C9747A809C424B5BC9DD4A4783A0225D80620F"/>
Expand Down Expand Up @@ -3588,6 +3610,12 @@
<sha512 value="adcc480f68828ffd68d03846be852988b595c2e1bb69224d273578dd6c2ad2773edfe96625a7c00bc40ae0f2d1cac8412eaa54b88cc8e681b0b4c0ee3b082333" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.reactivestreams" name="reactive-streams" version="1.0.3">
<artifact name="reactive-streams-1.0.3.jar">
<sha256 value="1dee0481072d19c929b623e155e14d2f6085dc011529a0a0dbefc84cf571d865" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
<sha512 value="aafc86186d82b4f3bd44ef7f955978481172eab267d208aa80b24f8ca218bd902d69b587fcae2fe44a888b7a9f81fc5a209e837958307fdc0ee815248f7065f9" origin="Generated by Gradle" reason="A key couldn't be downloaded"/>
</artifact>
</component>
<component group="org.reactivestreams" name="reactive-streams" version="1.0.4">
<artifact name="reactive-streams-1.0.4.jar">
<pgp value="50A628FFAF58480736B1079FD1031D14464180E0"/>
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def subprojects = [
'groovy-callsite',
'groovy-logging-test',
'groovy-ginq',
'groovy-ginq-sql',
'groovy-http-builder',
'groovy-markdown',
'groovy-macro',
Expand Down
46 changes: 46 additions & 0 deletions subprojects/groovy-ginq-sql/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
plugins {
id 'org.apache.groovy-library'
}

dependencies {
api rootProject
api projects.groovyGinq
api projects.groovySql
compileOnly "org.jooq:jooq:${versions.jooq}" // used by the optional jooq-sql provider
testImplementation projects.groovyTest
testImplementation "org.jooq:jooq:${versions.jooq}"
testImplementation "com.h2database:h2:${versions.h2}"
}

groovyLibrary {
optionalModule()

withoutBinaryCompatibilityChecks()
}

// GINQ macros expand at test-compile time using this module's classes, so the
// provider implementation (not just its ABI) is a genuine input; without this,
// compilation avoidance and the build cache can reuse test classes containing
// stale macro expansions
tasks.named('compileTestGroovy') {
inputs.files(tasks.named('compileGroovy').flatMap { it.destinationDirectory })
.withPropertyName('sqlProviderImplementation')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
package org.apache.groovy.ginq.provider.sql;

import org.apache.groovy.lang.annotation.Incubating;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

/**
* Which ANSI functions a dialect can render, including under a different
* spelling. The translator consults this before emitting a {@code SqlFunction},
* and the renderer consults it again so a function that cannot be rendered is
* never written into SQL. A dialect that lacks a function is not a special
* case in the planner: the name is added to {@link #UNSUPPORTED} and both
* strict mode and mixed mode pick it up.
* <p>
* A function that the dialect spells differently but can still render
* ({@code CHAR_LENGTH} as SQLite {@code LENGTH}, {@code GREATEST} as
* {@code MAX}) stays supported. Only functions with no faithful rendering
* belong here.
*
* @since 7.0.0
*/
@Incubating
public final class FunctionSupport {
private static final Map<String, Set<String>> UNSUPPORTED = unsupported();

private FunctionSupport() {
}

/**
* Canonical dialect family for a configured name. Unknown names are
* lower-cased and then support every function, which is what a jOOQ
* dialect without a known gap does.
*
* @param dialectName the configured dialect, or {@code null}
* @return the family name used by {@link #supports(String, String)}
*/
public static String canonical(String dialectName) {
if (dialectName == null || dialectName.isEmpty()) {
return "ansi";
}
switch (dialectName.toLowerCase(Locale.ROOT)) {
case "postgresql":
case "postgres":
return "postgres";
case "mariadb":
case "mysql":
return "mysql";
case "sqlite":
return "sqlite";
case "h2":
return "h2";
case "default":
case "ansi":
return "ansi";
default:
return dialectName.toLowerCase(Locale.ROOT);
}
}

/**
* Whether {@code ansiName} can be rendered for {@code dialectName}.
*
* @param dialectName the configured dialect
* @param ansiName the ANSI function name, for example {@code FLOOR}
* @return {@code false} only when the dialect has no rendering of that function
*/
public static boolean supports(String dialectName, String ansiName) {
if (ansiName == null || ansiName.isEmpty()) {
return false;
}
Set<String> missing = UNSUPPORTED.get(canonical(dialectName));
return missing == null || !missing.contains(ansiName);
}

private static Map<String, Set<String>> unsupported() {
Map<String, Set<String>> map = new HashMap<>();
map.put("sqlite", set("FLOOR", "CEILING"));
return Collections.unmodifiableMap(map);
}

private static Set<String> set(String... names) {
Set<String> values = new HashSet<>();
Collections.addAll(values, names);
return Collections.unmodifiableSet(values);
}
}
Loading
Loading