|
| 1 | +/* |
| 2 | + * Copyright 2019-2022 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
1 | 16 | package org.springframework.data.r2dbc.dialect;
|
2 | 17 |
|
3 |
| -import org.springframework.data.relational.core.dialect.AnsiDialect; |
4 |
| -import org.springframework.data.relational.core.dialect.LockClause; |
| 18 | +import org.springframework.data.relational.core.dialect.ArrayColumns; |
| 19 | +import org.springframework.data.relational.core.dialect.ObjectArrayColumns; |
5 | 20 | import org.springframework.data.relational.core.sql.SqlIdentifier;
|
| 21 | +import org.springframework.data.util.Lazy; |
| 22 | +import org.springframework.r2dbc.core.binding.BindMarkersFactory; |
6 | 23 |
|
7 | 24 | /**
|
8 |
| - * An SQL dialect for H2 in Postgres Compatibility mode. |
| 25 | + * R2DBC dialect for H2. |
9 | 26 | *
|
10 | 27 | * @author Mark Paluch
|
11 | 28 | * @author Jens Schauder
|
12 | 29 | * @author Diego Krupitza
|
13 | 30 | */
|
14 |
| -public class H2Dialect extends PostgresDialect { |
| 31 | +public class H2Dialect extends org.springframework.data.relational.core.dialect.H2Dialect implements R2dbcDialect { |
15 | 32 |
|
16 | 33 | /**
|
17 | 34 | * Singleton instance.
|
18 | 35 | */
|
19 | 36 | public static final H2Dialect INSTANCE = new H2Dialect();
|
20 | 37 |
|
| 38 | + private static final BindMarkersFactory INDEXED = BindMarkersFactory.indexed("$", 1); |
| 39 | + |
| 40 | + private final Lazy<ArrayColumns> arrayColumns = Lazy |
| 41 | + .of(() -> new SimpleTypeArrayColumns(ObjectArrayColumns.INSTANCE, getSimpleTypeHolder())); |
| 42 | + |
| 43 | + @Override |
| 44 | + public BindMarkersFactory getBindMarkersFactory() { |
| 45 | + return INDEXED; |
| 46 | + } |
| 47 | + |
21 | 48 | @Override
|
22 | 49 | public String renderForGeneratedValues(SqlIdentifier identifier) {
|
23 | 50 | return identifier.getReference(getIdentifierProcessing());
|
24 | 51 | }
|
25 | 52 |
|
26 | 53 | @Override
|
27 |
| - public LockClause lock() { |
28 |
| - // H2 Dialect does not support the same lock keywords as PostgreSQL, but it supports the ANSI SQL standard. |
29 |
| - // see https://www.h2database.com/html/commands.html |
30 |
| - // and https://www.h2database.com/html/features.html#compatibility |
31 |
| - return AnsiDialect.INSTANCE.lock(); |
| 54 | + public ArrayColumns getArraySupport() { |
| 55 | + return this.arrayColumns.get(); |
32 | 56 | }
|
33 |
| - |
34 | 57 | }
|
0 commit comments