From e3d0f1feee034f8b6a53cbe2d74a48c5039682a0 Mon Sep 17 00:00:00 2001 From: Henning Poettker Date: Sat, 8 Jan 2022 13:59:58 +0100 Subject: [PATCH] Adjust IDENTITY in DDLs for H2 2.x compatibility See gh-29200 --- .../src/test/resources/city-schema.sql | 2 +- .../r2dbc/ConnectionFactoryHealthIndicatorTests.java | 10 ++++++---- .../src/test/resources/batch/custom-schema.sql | 12 ++++++------ .../src/test/resources/data-city-schema.sql | 2 +- .../boot/autoconfigure/jdbc/another.sql | 2 +- .../boot/autoconfigure/jdbc/lexical-schema-aaa.sql | 2 +- .../boot/autoconfigure/jdbc/schema.sql | 2 +- .../src/test/resources/schema.sql | 2 +- .../src/test/resources/schema-all.sql | 2 +- .../spring-boot/src/test/resources/schema.sql | 2 +- .../src/main/resources/schema.sql | 2 +- .../src/main/resources/schema.sql | 2 +- 12 files changed, 22 insertions(+), 20 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-schema.sql b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-schema.sql index 7e3a3462e00..b2a4112add9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-schema.sql +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/resources/city-schema.sql @@ -1,5 +1,5 @@ CREATE TABLE CITY ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(30), state VARCHAR(30), country VARCHAR(30), diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/r2dbc/ConnectionFactoryHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/r2dbc/ConnectionFactoryHealthIndicatorTests.java index 0622036d9c6..f22484d7a43 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/r2dbc/ConnectionFactoryHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/r2dbc/ConnectionFactoryHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,9 +98,11 @@ class ConnectionFactoryHealthIndicatorTests { CloseableConnectionFactory connectionFactory = createTestDatabase(); try { String customValidationQuery = "SELECT COUNT(*) from HEALTH_TEST"; - Mono.from(connectionFactory.create()).flatMapMany((it) -> Flux - .from(it.createStatement("CREATE TABLE HEALTH_TEST (id INTEGER IDENTITY PRIMARY KEY)").execute()) - .flatMap(Result::getRowsUpdated).thenMany(it.close())).as(StepVerifier::create).verifyComplete(); + String createTableStatement = "CREATE TABLE HEALTH_TEST (id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY)"; + Mono.from(connectionFactory.create()) + .flatMapMany((it) -> Flux.from(it.createStatement(createTableStatement).execute()) + .flatMap(Result::getRowsUpdated).thenMany(it.close())) + .as(StepVerifier::create).verifyComplete(); ReactiveHealthIndicator healthIndicator = new ConnectionFactoryHealthIndicator(connectionFactory, customValidationQuery); healthIndicator.health().as(StepVerifier::create).assertNext((actual) -> { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql index 0027a4de38e..5953b5c4795 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/batch/custom-schema.sql @@ -1,5 +1,5 @@ CREATE TABLE PREFIX_JOB_INSTANCE ( - JOB_INSTANCE_ID BIGINT IDENTITY NOT NULL PRIMARY KEY , + JOB_INSTANCE_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY , VERSION BIGINT , JOB_NAME VARCHAR(100) NOT NULL, JOB_KEY VARCHAR(32) NOT NULL, @@ -7,7 +7,7 @@ CREATE TABLE PREFIX_JOB_INSTANCE ( ) ; CREATE TABLE PREFIX_JOB_EXECUTION ( - JOB_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY , + JOB_EXECUTION_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY , VERSION BIGINT , JOB_INSTANCE_ID BIGINT NOT NULL, CREATE_TIME TIMESTAMP NOT NULL, @@ -36,7 +36,7 @@ CREATE TABLE PREFIX_JOB_EXECUTION_PARAMS ( ) ; CREATE TABLE PREFIX_STEP_EXECUTION ( - STEP_EXECUTION_ID BIGINT IDENTITY NOT NULL PRIMARY KEY , + STEP_EXECUTION_ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY , VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, @@ -75,11 +75,11 @@ CREATE TABLE PREFIX_JOB_EXECUTION_CONTEXT ( ) ; CREATE TABLE PREFIX_STEP_EXECUTION_SEQ ( - ID BIGINT IDENTITY + ID BIGINT GENERATED BY DEFAULT AS IDENTITY ); CREATE TABLE PREFIX_JOB_EXECUTION_SEQ ( - ID BIGINT IDENTITY + ID BIGINT GENERATED BY DEFAULT AS IDENTITY ); CREATE TABLE PREFIX_JOB_SEQ ( - ID BIGINT IDENTITY + ID BIGINT GENERATED BY DEFAULT AS IDENTITY ); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/data-city-schema.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/data-city-schema.sql index 7e3a3462e00..b2a4112add9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/data-city-schema.sql +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/data-city-schema.sql @@ -1,5 +1,5 @@ CREATE TABLE CITY ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(30), state VARCHAR(30), country VARCHAR(30), diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/another.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/another.sql index 8377bedeed0..b4974a01bbf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/another.sql +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/another.sql @@ -1,4 +1,4 @@ CREATE TABLE SPAM ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(30) ); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-aaa.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-aaa.sql index 86d05121f0b..5d4523e1e17 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-aaa.sql +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-aaa.sql @@ -1,4 +1,4 @@ CREATE TABLE FOO ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, todrop VARCHAR(30) ); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/schema.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/schema.sql index 84a4ad9d93a..1014a04db4a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/schema.sql +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/org/springframework/boot/autoconfigure/jdbc/schema.sql @@ -1,4 +1,4 @@ CREATE TABLE FOO ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(30) ); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.sql b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.sql index f9a35403a70..7f7a6f01a57 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.sql +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/schema.sql @@ -1,4 +1,4 @@ CREATE TABLE BAR ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(30) ); diff --git a/spring-boot-project/spring-boot-cli/src/test/resources/schema-all.sql b/spring-boot-project/spring-boot-cli/src/test/resources/schema-all.sql index 84a4ad9d93a..1014a04db4a 100644 --- a/spring-boot-project/spring-boot-cli/src/test/resources/schema-all.sql +++ b/spring-boot-project/spring-boot-cli/src/test/resources/schema-all.sql @@ -1,4 +1,4 @@ CREATE TABLE FOO ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(30) ); diff --git a/spring-boot-project/spring-boot/src/test/resources/schema.sql b/spring-boot-project/spring-boot/src/test/resources/schema.sql index 73d14cd310a..556b5e372a9 100644 --- a/spring-boot-project/spring-boot/src/test/resources/schema.sql +++ b/spring-boot-project/spring-boot/src/test/resources/schema.sql @@ -1,4 +1,4 @@ CREATE TABLE EXAMPLE ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(30) ); \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jdbc/src/main/resources/schema.sql b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jdbc/src/main/resources/schema.sql index 1b999f2e801..bd0b5fb7a01 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jdbc/src/main/resources/schema.sql +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jdbc/src/main/resources/schema.sql @@ -1,5 +1,5 @@ CREATE TABLE CUSTOMER ( - ID INTEGER IDENTITY PRIMARY KEY, + ID INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, FIRST_NAME VARCHAR(30), DATE_OF_BIRTH DATE ); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc/src/main/resources/schema.sql b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc/src/main/resources/schema.sql index 88217dc41bb..60aa64a368a 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc/src/main/resources/schema.sql +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc/src/main/resources/schema.sql @@ -1,5 +1,5 @@ CREATE TABLE CITY ( - id INTEGER IDENTITY PRIMARY KEY, + id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, name VARCHAR(30), state VARCHAR(30), country VARCHAR(30)