Skip to content
Merged
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
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ concurrency:

jobs:
test:
name: Maven test and release verification
name: Maven test and release verification on Java ${{ matrix.java-version }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
java-version: ["17", "21"]
services:
postgres:
image: postgres:16-alpine
Expand All @@ -37,11 +41,11 @@ jobs:
with:
persist-credentials: false

- name: Set up Java 21
- name: Set up Java ${{ matrix.java-version }}
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6
with:
distribution: temurin
java-version: "21"
java-version: ${{ matrix.java-version }}
cache: maven
cache-dependency-path: pom.xml

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ or release procedure yet either.

## Requirements

- Java 21 for the CLI and for applications that use the generated code.
- Java 17 or later for the CLI and for applications that use the generated code.
- Maven, to build sqlcj and to build a consuming project.
- PostgreSQL, reached through the application's own PostgreSQL JDBC driver.
sqlcj does not ship a driver. Behavior is verified against PostgreSQL 16.
Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on the application's classpath.

## 1. Prerequisites

- A full JDK 21 on the `PATH` (`java -version` reports 21).
- A full JDK 17 or later on the `PATH`.
- Maven (verified with 3.8.7).
- Docker, or another way to reach a PostgreSQL 16 server.

Expand Down Expand Up @@ -80,7 +80,7 @@ mkdir -p sql/migrations src/main/java/com/example/app
<version>1.0.0-SNAPSHOT</version>

<properties>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sqlcj.version>0.1.0-SNAPSHOT</sqlcj.version>
<sqlcj.generated.sources>${project.build.directory}/generated-sources/sqlcj</sqlcj.generated.sources>
Expand Down
2 changes: 1 addition & 1 deletion examples/maven-postgresql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
-->

<properties>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sqlcj.version>0.1.0-SNAPSHOT</sqlcj.version>
<sqlcj.generated.sources>${project.build.directory}/generated-sources/sqlcj</sqlcj.generated.sources>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</modules>

<properties>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spotless.plugin.version>3.10.2</spotless.plugin.version>
<spotless.eclipse.version>4.40</spotless.eclipse.version>
Expand Down Expand Up @@ -157,7 +157,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.15.0</version>
<configuration>
<release>21</release>
<release>17</release>
</configuration>
</plugin>
<plugin>
Expand Down
3 changes: 2 additions & 1 deletion scripts/verify-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
# parameter filter, the 'now()' rename, the grouped book count, the upsert, and
# the id-list read.
#
# Requirements: JDK 21, Maven, psql, and a reachable PostgreSQL server.
# Requirements: JDK 17 or later, Maven, psql, and a reachable PostgreSQL
# server.
#
# Connection settings, defaulting to the values used by docs/quickstart.md:
#
Expand Down
18 changes: 9 additions & 9 deletions sqlcj-cli/src/main/java/dev/sqlcj/analysis/QueryAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ private String resolveReturningRowTable(ReturningClause returningClause, Source
return null;
}

return returningClause.getFirst().getExpression() instanceof AllColumns
return returningClause.get(0).getExpression() instanceof AllColumns
? source.table().name()
: null;
}
Expand Down Expand Up @@ -1659,7 +1659,7 @@ private Expression anyListArgument(Expression expression, Placeholders placehold

List<String> name = function.getMultipartName();

if (name == null || name.size() != 1 || !name.getFirst().equalsIgnoreCase("any")) {
if (name == null || name.size() != 1 || !name.get(0).equalsIgnoreCase("any")) {
return null;
}

Expand All @@ -1673,7 +1673,7 @@ private Expression anyListArgument(Expression expression, Placeholders placehold
return null;
}

Expression argument = arguments.getFirst();
Expression argument = arguments.get(0);

return bindsValue(argument, placeholders)
? argument
Expand Down Expand Up @@ -1919,7 +1919,7 @@ private void requireSupportedPlaceholders(ParsedSql parsedSql) {

if (!uncompiled.isEmpty()) {
throw new UnsupportedOperationException(
NAMED_PLACEHOLDER_REJECTION.formatted(uncompiled.getFirst())
NAMED_PLACEHOLDER_REJECTION.formatted(uncompiled.get(0))
);
}

Expand Down Expand Up @@ -2029,7 +2029,7 @@ private List<QueryColumn> resolveColumns(
private boolean isScalarCount(Function function) {
List<String> name = function.getMultipartName();

if (name == null || name.size() != 1 || !name.getFirst().equalsIgnoreCase("count")) {
if (name == null || name.size() != 1 || !name.get(0).equalsIgnoreCase("count")) {
return false;
}

Expand All @@ -2041,7 +2041,7 @@ private boolean isScalarCount(Function function) {

return arguments != null
&& arguments.size() == 1
&& arguments.getFirst().getClass() == AllColumns.class;
&& arguments.get(0).getClass() == AllColumns.class;
}

/**
Expand Down Expand Up @@ -2107,8 +2107,8 @@ private String resolveSelectRowTable(PlainSelect plainSelect, List<Source> sourc
return null;
}

return selectItems.getFirst().getExpression() instanceof AllColumns
? sources.getFirst().table().name()
return selectItems.get(0).getExpression() instanceof AllColumns
? sources.get(0).table().name()
: null;
}

Expand Down Expand Up @@ -2157,7 +2157,7 @@ private ResolvedColumn resolveColumn(net.sf.jsqlparser.schema.Column column, Lis
);
}

Source source = matches.getFirst();
Source source = matches.get(0);

return new ResolvedColumn(source, findColumn(source.table(), columnName));
}
Expand Down
6 changes: 3 additions & 3 deletions sqlcj-cli/src/main/java/dev/sqlcj/config/ConfigValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
*/
final class ConfigValidator {

private static final SourceVersion SOURCE_VERSION = SourceVersion.RELEASE_21;
private static final SourceVersion SOURCE_VERSION = SourceVersion.RELEASE_17;

/**
* Java 21 restricted identifiers. They are rejected as a group name so that
* Java 17 restricted identifiers. They are rejected as a group name so that
* the configured value can be used unchanged as a generated type-name
* prefix.
*/
Expand Down Expand Up @@ -97,7 +97,7 @@ private void validateSchema(List<String> schema, int index, Path configFile) {
}

if (schema.size() == 1) {
requireValue(schema.getFirst(), field, configFile);
requireValue(schema.get(0), field, configFile);

return;
}
Expand Down
2 changes: 1 addition & 1 deletion sqlcj-cli/src/main/java/dev/sqlcj/generator/JavaNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
final class JavaNames {

private static final SourceVersion SOURCE_VERSION = SourceVersion.RELEASE_21;
private static final SourceVersion SOURCE_VERSION = SourceVersion.RELEASE_17;

private static final String REPOSITORY_SUFFIX = "Repository";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ final class SqlParameterCompiler {
private static final int SOURCE_OFFSET = 1;

SqlParameters compile(String sql, Node astRoot) {
if (!(astRoot instanceof Node node)) {
if (astRoot == null) {
throw new SqlParseException("SQL parse tree is unavailable.");
}

Token firstToken = node.jjtGetFirstToken();
Token lastToken = node.jjtGetLastToken();
Token firstToken = astRoot.jjtGetFirstToken();
Token lastToken = astRoot.jjtGetLastToken();

if (firstToken == null || lastToken == null) {
throw new SqlParseException("SQL parse tree has no tokens.");
Expand Down Expand Up @@ -140,7 +140,7 @@ SqlParameters compile(String sql, Node astRoot) {

List<String> uncompiled = new ArrayList<>();

collectUncompiledPlaceholders(node, names, uncompiled);
collectUncompiledPlaceholders(astRoot, names, uncompiled);

return new SqlParameters(
executableSql.toString(),
Expand Down
24 changes: 12 additions & 12 deletions sqlcj-cli/src/test/java/dev/sqlcj/analysis/QueryAnalyzerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ void shouldResolveQueryParameterFromReferencedColumn() {

assertEquals(1, model.parameters().size());

QueryParameter parameter = model.parameters().getFirst();
QueryParameter parameter = model.parameters().get(0);

assertEquals(1, parameter.index());
assertEquals("id", parameter.name());
Expand All @@ -663,7 +663,7 @@ void shouldResolveMultipleQueryParameters() {

assertEquals(2, model.parameters().size());

QueryParameter first = model.parameters().getFirst();
QueryParameter first = model.parameters().get(0);
assertEquals(1, first.index());
assertEquals("id", first.name());
assertEquals(ColumnType.BIGINT, first.type());
Expand Down Expand Up @@ -692,7 +692,7 @@ void shouldResolveMultipleParametersForSameColumn() {

assertEquals(2, model.parameters().size());

QueryParameter first = model.parameters().getFirst();
QueryParameter first = model.parameters().get(0);
assertEquals(1, first.index());
assertEquals("id", first.name());
assertEquals(ColumnType.BIGINT, first.type());
Expand Down Expand Up @@ -721,7 +721,7 @@ void shouldResolveQueryParametersInIndexOrder() {

assertEquals(2, model.parameters().size());

QueryParameter first = model.parameters().getFirst();
QueryParameter first = model.parameters().get(0);
assertEquals(1, first.index());
assertEquals("id", first.name());
assertEquals(ColumnType.BIGINT, first.type());
Expand Down Expand Up @@ -750,7 +750,7 @@ void shouldResolveQueryParametersInsideOrExpression() {

assertEquals(2, model.parameters().size());

QueryParameter first = model.parameters().getFirst();
QueryParameter first = model.parameters().get(0);
assertEquals(1, first.index());
assertEquals("id", first.name());
assertEquals(ColumnType.BIGINT, first.type());
Expand Down Expand Up @@ -784,7 +784,7 @@ void shouldResolveQueryParametersInsideNestedAndOrExpressions() {

assertEquals(3, model.parameters().size());

QueryParameter first = model.parameters().getFirst();
QueryParameter first = model.parameters().get(0);
assertEquals(1, first.index());
assertEquals("id", first.name());
assertEquals(ColumnType.BIGINT, first.type());
Expand Down Expand Up @@ -823,7 +823,7 @@ void shouldResolveQueryParametersForComparisonOperators() {

assertEquals(2, model.parameters().size());

QueryParameter first = model.parameters().getFirst();
QueryParameter first = model.parameters().get(0);
assertEquals(1, first.index());
assertEquals("id", first.name());
assertEquals(ColumnType.BIGINT, first.type());
Expand Down Expand Up @@ -869,7 +869,7 @@ void shouldResolveQueryParameterForComparisonOperator(

assertEquals(1, model.parameters().size());

QueryParameter parameter = model.parameters().getFirst();
QueryParameter parameter = model.parameters().get(0);

assertEquals(1, parameter.index());
assertEquals("id", parameter.name());
Expand All @@ -894,7 +894,7 @@ void shouldResolveQueryParameterWhenParameterIsOnLeftSide() {

assertEquals(1, model.parameters().size());

QueryParameter parameter = model.parameters().getFirst();
QueryParameter parameter = model.parameters().get(0);

assertEquals(1, parameter.index());
assertEquals("id", parameter.name());
Expand Down Expand Up @@ -1657,7 +1657,7 @@ void shouldResolveQueryParametersInsideInExpression() {

assertEquals(3, model.parameters().size());

QueryParameter first = model.parameters().getFirst();
QueryParameter first = model.parameters().get(0);
assertEquals(1, first.index());
assertEquals("id", first.name());
assertEquals(ColumnType.BIGINT, first.type());
Expand Down Expand Up @@ -1691,7 +1691,7 @@ void shouldResolveQueryParametersInsideInExpressionInIndexOrder() {

assertEquals(3, model.parameters().size());

QueryParameter first = model.parameters().getFirst();
QueryParameter first = model.parameters().get(0);
assertEquals(1, first.index());
assertEquals("id", first.name());
assertEquals(ColumnType.BIGINT, first.type());
Expand Down Expand Up @@ -1730,7 +1730,7 @@ WHERE id IN ($1, $2)

assertEquals(4, model.parameters().size());

QueryParameter first = model.parameters().getFirst();
QueryParameter first = model.parameters().get(0);
assertEquals(1, first.index());
assertEquals("id", first.name());
assertEquals(ColumnType.BIGINT, first.type());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ void shouldLoadEntriesInDeclaredOrder() throws IOException {

assertEquals(2, sources.size());

assertTrue(schemaOf(sources.getFirst()).contains("CREATE TABLE users"));
assertTrue(schemaOf(sources.get(0)).contains("CREATE TABLE users"));
assertTrue(schemaOf(sources.get(1)).contains("CREATE TABLE orders"));

assertEquals(
List.of("GetUser", "ListUsers"),
names(sources.getFirst())
names(sources.get(0))
);

assertEquals(
Expand Down Expand Up @@ -111,10 +111,10 @@ void shouldLoadTheSameQueryNameInTwoEntries() throws IOException {
)
);

assertEquals(List.of("GetUser"), names(sources.getFirst()));
assertEquals(List.of("GetUser"), names(sources.get(0)));
assertEquals(List.of("GetUser"), names(sources.get(1)));

assertEquals("Users", sources.getFirst().name());
assertEquals("Users", sources.get(0).name());
assertEquals("Orders", sources.get(1).name());
}

Expand Down Expand Up @@ -251,12 +251,12 @@ void shouldCarrySourcePathsAndQueryLines() throws IOException {
)
);

Source source = sources.getFirst();
Source source = sources.get(0);

assertEquals("Users", source.name());
assertEquals(List.of(schema), schemaPaths(source));
assertEquals(queries, source.queriesPath());
assertEquals(1, source.queries().getFirst().line());
assertEquals(1, source.queries().get(0).line());
assertEquals(6, source.queries().get(1).line());
}

Expand Down Expand Up @@ -297,7 +297,7 @@ void shouldLoadListedFilesAndDirectoryMigrationsInOrder() throws IOException {
)
);

Source source = sources.getFirst();
Source source = sources.get(0);

assertEquals(
List.of(
Expand Down Expand Up @@ -434,7 +434,7 @@ void shouldRejectUnlistableSchemaDirectory() throws IOException {
}

private String schemaOf(Source source) {
return source.schemaFiles().getFirst().sql();
return source.schemaFiles().get(0).sql();
}

private List<Path> schemaPaths(Source source) {
Expand Down
Loading
Loading