mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(rds-data): adding data-api preparedstatement() support (#1887)
* feat(rds-data): adding data-api preparedstatement() support * feat(rds-data): addressing greptile comments * feat(rds-data): addressing PR review comments, fixing timestamp
This commit is contained in:
1 parent
517094adc1
commit
19a32ab51d
7 files changed
+706
-55
No files matched your search
@@ -355,13 +355,30 @@ func TestRdsDataApiGoSdkV1(t *testing.T) {
|
||||
ResourceArn: awsV1.String(resourceArn),
|
||||
SecretArn: awsV1.String(secretArn),
|
||||
Database: awsV1.String(database),
|
||||
Sql: awsV1.String("select :id"),
|
||||
Parameters: []*rdsdataservice.SqlParameter{{
|
||||
Name: awsV1.String("id"),
|
||||
Value: &rdsdataservice.Field{LongValue: awsV1.Int64(1)},
|
||||
}},
|
||||
Sql: awsV1.String("insert into data_api_items (id, title, score) values (:id, :title, :score)"),
|
||||
Parameters: []*rdsdataservice.SqlParameter{
|
||||
{Name: awsV1.String("id"), Value: &rdsdataservice.Field{StringValue: awsV1.String("param-1")}},
|
||||
{Name: awsV1.String("title"), Value: &rdsdataservice.Field{StringValue: awsV1.String("parameterized")}},
|
||||
{Name: awsV1.String("score"), Value: &rdsdataservice.Field{LongValue: awsV1.Int64(42)}},
|
||||
},
|
||||
})
|
||||
assertAwsErrorCode(t, err, "BadRequestException")
|
||||
require.NoError(t, err)
|
||||
|
||||
paramOut, err := dataSvc.ExecuteStatement(&rdsdataservice.ExecuteStatementInput{
|
||||
ResourceArn: awsV1.String(resourceArn),
|
||||
SecretArn: awsV1.String(secretArn),
|
||||
Database: awsV1.String(database),
|
||||
Sql: awsV1.String("select title, score from data_api_items where id = :id and score = :score"),
|
||||
IncludeResultMetadata: awsV1.Bool(true),
|
||||
Parameters: []*rdsdataservice.SqlParameter{
|
||||
{Name: awsV1.String("id"), Value: &rdsdataservice.Field{StringValue: awsV1.String("param-1")}},
|
||||
{Name: awsV1.String("score"), Value: &rdsdataservice.Field{LongValue: awsV1.Int64(42)}},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, paramOut.Records, 1)
|
||||
assert.Equal(t, "parameterized", awsV1.StringValue(paramOut.Records[0][0].StringValue))
|
||||
assert.Equal(t, int64(42), awsV1.Int64Value(paramOut.Records[0][1].LongValue))
|
||||
|
||||
_, err = dataSvc.ExecuteStatement(&rdsdataservice.ExecuteStatementInput{
|
||||
ResourceArn: awsV1.String(resourceArn),
|
||||
@@ -713,13 +730,30 @@ func TestRdsDataApiGoSdkPostgresV1(t *testing.T) {
|
||||
ResourceArn: awsV1.String(resourceArn),
|
||||
SecretArn: awsV1.String(secretArn),
|
||||
Database: awsV1.String(database),
|
||||
Sql: awsV1.String("select :id"),
|
||||
Parameters: []*rdsdataservice.SqlParameter{{
|
||||
Name: awsV1.String("id"),
|
||||
Value: &rdsdataservice.Field{LongValue: awsV1.Int64(1)},
|
||||
}},
|
||||
Sql: awsV1.String("insert into data_api_items (id, title, score) values (:id, :title, :score)"),
|
||||
Parameters: []*rdsdataservice.SqlParameter{
|
||||
{Name: awsV1.String("id"), Value: &rdsdataservice.Field{StringValue: awsV1.String("param-1")}},
|
||||
{Name: awsV1.String("title"), Value: &rdsdataservice.Field{StringValue: awsV1.String("parameterized")}},
|
||||
{Name: awsV1.String("score"), Value: &rdsdataservice.Field{LongValue: awsV1.Int64(42)}},
|
||||
},
|
||||
})
|
||||
assertAwsErrorCode(t, err, "BadRequestException")
|
||||
require.NoError(t, err)
|
||||
|
||||
paramOut, err := dataSvc.ExecuteStatement(&rdsdataservice.ExecuteStatementInput{
|
||||
ResourceArn: awsV1.String(resourceArn),
|
||||
SecretArn: awsV1.String(secretArn),
|
||||
Database: awsV1.String(database),
|
||||
Sql: awsV1.String("select title, score from data_api_items where id = :id and score = :score"),
|
||||
IncludeResultMetadata: awsV1.Bool(true),
|
||||
Parameters: []*rdsdataservice.SqlParameter{
|
||||
{Name: awsV1.String("id"), Value: &rdsdataservice.Field{StringValue: awsV1.String("param-1")}},
|
||||
{Name: awsV1.String("score"), Value: &rdsdataservice.Field{LongValue: awsV1.Int64(42)}},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, paramOut.Records, 1)
|
||||
assert.Equal(t, "parameterized", awsV1.StringValue(paramOut.Records[0][0].StringValue))
|
||||
assert.Equal(t, int64(42), awsV1.Int64Value(paramOut.Records[0][1].LongValue))
|
||||
|
||||
_, err = dataSvc.ExecuteStatement(&rdsdataservice.ExecuteStatementInput{
|
||||
ResourceArn: awsV1.String(resourceArn),
|
||||
@@ -895,13 +929,30 @@ func TestRdsDataApiGoSdkV2(t *testing.T) {
|
||||
ResourceArn: awsV2.String(resourceArn),
|
||||
SecretArn: awsV2.String(secretArn),
|
||||
Database: awsV2.String(database),
|
||||
Sql: awsV2.String("select :id"),
|
||||
Parameters: []rdsdatatypes.SqlParameter{{
|
||||
Name: awsV2.String("id"),
|
||||
Value: &rdsdatatypes.FieldMemberLongValue{Value: 1},
|
||||
}},
|
||||
Sql: awsV2.String("insert into data_api_v2_items (id, name, qty) values (:id, :name, :qty)"),
|
||||
Parameters: []rdsdatatypes.SqlParameter{
|
||||
{Name: awsV2.String("id"), Value: &rdsdatatypes.FieldMemberStringValue{Value: "v2-param"}},
|
||||
{Name: awsV2.String("name"), Value: &rdsdatatypes.FieldMemberStringValue{Value: "parameterized"}},
|
||||
{Name: awsV2.String("qty"), Value: &rdsdatatypes.FieldMemberLongValue{Value: 42}},
|
||||
},
|
||||
})
|
||||
assertSmithyErrorCode(t, err, "BadRequestException")
|
||||
require.NoError(t, err)
|
||||
|
||||
paramOut, err := dataSvc.ExecuteStatement(ctx, &rdsdata.ExecuteStatementInput{
|
||||
ResourceArn: awsV2.String(resourceArn),
|
||||
SecretArn: awsV2.String(secretArn),
|
||||
Database: awsV2.String(database),
|
||||
Sql: awsV2.String("select name, qty from data_api_v2_items where id = :id and qty = :qty"),
|
||||
IncludeResultMetadata: true,
|
||||
Parameters: []rdsdatatypes.SqlParameter{
|
||||
{Name: awsV2.String("id"), Value: &rdsdatatypes.FieldMemberStringValue{Value: "v2-param"}},
|
||||
{Name: awsV2.String("qty"), Value: &rdsdatatypes.FieldMemberLongValue{Value: 42}},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, paramOut.Records, 1)
|
||||
assert.Equal(t, "parameterized", fieldStringValue(t, paramOut.Records[0][0]))
|
||||
assert.Equal(t, int64(42), fieldLongValue(t, paramOut.Records[0][1]))
|
||||
|
||||
_, err = dataSvc.ExecuteSql(ctx, &rdsdata.ExecuteSqlInput{
|
||||
DbClusterOrInstanceArn: awsV2.String(resourceArn),
|
||||
@@ -1068,13 +1119,30 @@ func TestRdsDataApiGoSdkPostgresV2(t *testing.T) {
|
||||
ResourceArn: awsV2.String(resourceArn),
|
||||
SecretArn: awsV2.String(secretArn),
|
||||
Database: awsV2.String(database),
|
||||
Sql: awsV2.String("select :id"),
|
||||
Parameters: []rdsdatatypes.SqlParameter{{
|
||||
Name: awsV2.String("id"),
|
||||
Value: &rdsdatatypes.FieldMemberLongValue{Value: 1},
|
||||
}},
|
||||
Sql: awsV2.String("insert into data_api_v2_items (id, name, qty) values (:id, :name, :qty)"),
|
||||
Parameters: []rdsdatatypes.SqlParameter{
|
||||
{Name: awsV2.String("id"), Value: &rdsdatatypes.FieldMemberStringValue{Value: "v2-param"}},
|
||||
{Name: awsV2.String("name"), Value: &rdsdatatypes.FieldMemberStringValue{Value: "parameterized"}},
|
||||
{Name: awsV2.String("qty"), Value: &rdsdatatypes.FieldMemberLongValue{Value: 42}},
|
||||
},
|
||||
})
|
||||
assertSmithyErrorCode(t, err, "BadRequestException")
|
||||
require.NoError(t, err)
|
||||
|
||||
paramOut, err := dataSvc.ExecuteStatement(ctx, &rdsdata.ExecuteStatementInput{
|
||||
ResourceArn: awsV2.String(resourceArn),
|
||||
SecretArn: awsV2.String(secretArn),
|
||||
Database: awsV2.String(database),
|
||||
Sql: awsV2.String("select name, qty from data_api_v2_items where id = :id and qty = :qty"),
|
||||
IncludeResultMetadata: true,
|
||||
Parameters: []rdsdatatypes.SqlParameter{
|
||||
{Name: awsV2.String("id"), Value: &rdsdatatypes.FieldMemberStringValue{Value: "v2-param"}},
|
||||
{Name: awsV2.String("qty"), Value: &rdsdatatypes.FieldMemberLongValue{Value: 42}},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, paramOut.Records, 1)
|
||||
assert.Equal(t, "parameterized", fieldStringValue(t, paramOut.Records[0][0]))
|
||||
assert.Equal(t, int64(42), fieldLongValue(t, paramOut.Records[0][1]))
|
||||
|
||||
_, err = dataSvc.ExecuteSql(ctx, &rdsdata.ExecuteSqlInput{
|
||||
DbClusterOrInstanceArn: awsV2.String(resourceArn),
|
||||
|
||||
@@ -33,7 +33,7 @@ For the upstream API shape, see the AWS RDS Data API documentation:
|
||||
- `database` is optional when the resolved RDS resource has a database name; otherwise it must be provided. Transactional `ExecuteStatement` requests must use the same database as the active transaction when `database` is present.
|
||||
- Transaction requests validate `resourceArn` against the active transaction resource. Floci resolves accepted ARN aliases to the local resource before comparing transaction identity.
|
||||
- MySQL, MariaDB, and PostgreSQL resources are supported. Aurora PostgreSQL resources resolve to the same PostgreSQL execution path.
|
||||
- SQL is sent directly to the local database engine through JDBC. `SqlParameter` binding is not implemented yet; send raw SQL strings. Non-empty or malformed `parameters` requests return `BadRequestException`.
|
||||
- SQL is sent directly to the local database engine through JDBC. `SqlParameter` binding is supported for all engines: named `:placeholder` markers are rewritten to positional JDBC bind parameters and executed through a `PreparedStatement`. Colons inside string literals, quoted/backtick identifiers, comments, PostgreSQL `::` casts, and PostgreSQL dollar-quoted strings are left untouched. A placeholder used more than once binds its value at each position. Supported value variants are `stringValue`, `booleanValue`, `longValue`, `doubleValue`, `blobValue`, and `isNull`; `typeHint` values `DECIMAL`, `TIMESTAMP`, `DATE`, `TIME`, `UUID`, and `JSON` are honored. `arrayValue` parameters are not supported yet and return `BadRequestException`, as do malformed `parameters` payloads (not a JSON array, or an entry missing `name`).
|
||||
- Result records include Data API field variants such as `stringValue`, `longValue`, `blobValue`, `booleanValue`, `doubleValue`, and `isNull`.
|
||||
- SQL errors are returned as `DatabaseErrorException` so AWS SDK callers can handle database failures with normal AWS error decoding.
|
||||
- If `secretArn` points to a local Secrets Manager secret with JSON credentials (`username` or `user`, plus `password`), those credentials are used. If the secret is missing or cannot be parsed, Floci falls back to the resolved RDS resource's master credentials for local development convenience.
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.rds.model.DatabaseEngine;
|
||||
import io.github.hectorvent.floci.services.secretsmanager.SecretsManagerService;
|
||||
import io.github.hectorvent.floci.services.secretsmanager.model.SecretVersion;
|
||||
import io.github.hectorvent.floci.core.common.Resettable;
|
||||
@@ -16,12 +17,15 @@ import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
@@ -107,6 +111,7 @@ public class RdsDataService implements Resettable {
|
||||
String sql = requiredText(request, "sql");
|
||||
String resourceArn = requiredText(request, "resourceArn");
|
||||
requiredText(request, "secretArn");
|
||||
Map<String, JsonNode> parameters = parseParameters(request);
|
||||
String transactionId = textOrNull(request, "transactionId");
|
||||
boolean includeMetadata = request.path("includeResultMetadata").asBoolean(false);
|
||||
|
||||
@@ -117,7 +122,7 @@ public class RdsDataService implements Resettable {
|
||||
requireActiveTransaction(transactionId, tx);
|
||||
validateTransactionIdentity(tx, request);
|
||||
tx.refresh(transactionTtl);
|
||||
return executeOnConnection(tx.connection, sql, includeMetadata);
|
||||
return executeOnConnection(tx.connection, tx.engine, sql, parameters, includeMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +130,7 @@ public class RdsDataService implements Resettable {
|
||||
Credentials credentials = credentials(request, target, region);
|
||||
String database = databaseName(request, target);
|
||||
try (Connection connection = connectionFactory.open(target, credentials.username(), credentials.password(), database)) {
|
||||
return executeOnConnection(connection, sql, includeMetadata);
|
||||
return executeOnConnection(connection, target.engine(), sql, parameters, includeMetadata);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw databaseError(e);
|
||||
@@ -145,7 +150,7 @@ public class RdsDataService implements Resettable {
|
||||
connection = connectionFactory.open(target, credentials.username(), credentials.password(), database);
|
||||
connection.setAutoCommit(false);
|
||||
String transactionId = UUID.randomUUID().toString();
|
||||
transactions.put(transactionId, new TransactionContext(transactionId, connection, target.arn(), database, transactionTtl));
|
||||
transactions.put(transactionId, new TransactionContext(transactionId, connection, target.engine(), target.arn(), database, transactionTtl));
|
||||
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.put("transactionId", transactionId);
|
||||
@@ -206,28 +211,48 @@ public class RdsDataService implements Resettable {
|
||||
return response;
|
||||
}
|
||||
|
||||
private ObjectNode executeOnConnection(Connection connection, String sql, boolean includeMetadata) throws SQLException {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
boolean hasResultSet = statement.execute(sql);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
if (hasResultSet) {
|
||||
try (ResultSet rs = statement.getResultSet()) {
|
||||
ResultSetMetaData meta = rs.getMetaData();
|
||||
if (includeMetadata) {
|
||||
response.set("columnMetadata", columnMetadata(meta));
|
||||
}
|
||||
response.set("records", records(rs, meta));
|
||||
}
|
||||
response.put("numberOfRecordsUpdated", 0L);
|
||||
} else {
|
||||
int updateCount = statement.getUpdateCount();
|
||||
response.set("records", objectMapper.createArrayNode());
|
||||
response.put("numberOfRecordsUpdated", Math.max(updateCount, 0));
|
||||
}
|
||||
return response;
|
||||
private ObjectNode executeOnConnection(Connection connection, DatabaseEngine engine, String sql,
|
||||
Map<String, JsonNode> parameters, boolean includeMetadata)
|
||||
throws SQLException {
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(sql, usesBackslashEscapes(engine));
|
||||
try (PreparedStatement statement = connection.prepareStatement(parsed.sql())) {
|
||||
RdsDataSqlParameters.bind(statement, parsed.parameterOrder(), parameters);
|
||||
return buildResponse(statement, statement.execute(), includeMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a backslash escapes quotes inside string literals for {@code engine}.
|
||||
* MySQL and MariaDB honor {@code \'} by default (NO_BACKSLASH_ESCAPES disabled);
|
||||
* PostgreSQL treats backslash literally with {@code standard_conforming_strings} on.
|
||||
*/
|
||||
private static boolean usesBackslashEscapes(DatabaseEngine engine) {
|
||||
return switch (engine) {
|
||||
case MYSQL, MARIADB -> true;
|
||||
case POSTGRES -> false;
|
||||
};
|
||||
}
|
||||
|
||||
private ObjectNode buildResponse(Statement statement, boolean hasResultSet, boolean includeMetadata)
|
||||
throws SQLException {
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
if (hasResultSet) {
|
||||
try (ResultSet rs = statement.getResultSet()) {
|
||||
ResultSetMetaData meta = rs.getMetaData();
|
||||
if (includeMetadata) {
|
||||
response.set("columnMetadata", columnMetadata(meta));
|
||||
}
|
||||
response.set("records", records(rs, meta));
|
||||
}
|
||||
response.put("numberOfRecordsUpdated", 0L);
|
||||
} else {
|
||||
int updateCount = statement.getUpdateCount();
|
||||
response.set("records", objectMapper.createArrayNode());
|
||||
response.put("numberOfRecordsUpdated", Math.max(updateCount, 0));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private ArrayNode columnMetadata(ResultSetMetaData meta) throws SQLException {
|
||||
ArrayNode columns = objectMapper.createArrayNode();
|
||||
for (int i = 1; i <= meta.getColumnCount(); i++) {
|
||||
@@ -384,17 +409,36 @@ public class RdsDataService implements Resettable {
|
||||
}
|
||||
|
||||
private static void rejectUnsupportedOptions(JsonNode request) {
|
||||
rejectSqlParameters(request);
|
||||
rejectFormattedRecords(request);
|
||||
rejectResultSetOptions(request);
|
||||
}
|
||||
|
||||
private static void rejectSqlParameters(JsonNode request) {
|
||||
private static Map<String, JsonNode> parseParameters(JsonNode request) {
|
||||
JsonNode parameters = request.get("parameters");
|
||||
if (parameters != null && (!parameters.isArray() || !parameters.isEmpty())) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"SqlParameter binding is not supported by this local RDS Data API implementation.", 400);
|
||||
if (parameters == null || parameters.isNull()) {
|
||||
return Map.of();
|
||||
}
|
||||
if (!parameters.isArray()) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"parameters must be an array of SqlParameter values.", 400);
|
||||
}
|
||||
Map<String, JsonNode> byName = new LinkedHashMap<>();
|
||||
for (JsonNode parameter : parameters) {
|
||||
if (parameter == null || !parameter.isObject()) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"Each parameter must be a SqlParameter object.", 400);
|
||||
}
|
||||
String name = textOrNull(parameter, "name");
|
||||
if (name == null || name.isBlank()) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"Each SqlParameter requires a name.", 400);
|
||||
}
|
||||
if (byName.putIfAbsent(name, parameter) != null) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"Duplicate parameter name :" + name + " in the parameter set.", 400);
|
||||
}
|
||||
}
|
||||
return byName;
|
||||
}
|
||||
|
||||
private static void rejectFormattedRecords(JsonNode request) {
|
||||
@@ -438,13 +482,15 @@ public class RdsDataService implements Resettable {
|
||||
private static final class TransactionContext {
|
||||
private final String id;
|
||||
private final Connection connection;
|
||||
private final DatabaseEngine engine;
|
||||
private final String resourceArn;
|
||||
private final String database;
|
||||
private volatile Instant expiresAt;
|
||||
|
||||
private TransactionContext(String id, Connection connection, String resourceArn, String database, Duration ttl) {
|
||||
private TransactionContext(String id, Connection connection, DatabaseEngine engine, String resourceArn, String database, Duration ttl) {
|
||||
this.id = id;
|
||||
this.connection = connection;
|
||||
this.engine = engine;
|
||||
this.resourceArn = resourceArn;
|
||||
this.database = database;
|
||||
refresh(ttl);
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
package io.github.hectorvent.floci.services.rdsdata;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Translates AWS RDS Data API {@code SqlParameter} bindings into JDBC
|
||||
* {@link PreparedStatement} bindings.
|
||||
*
|
||||
* <p>The Data API uses named placeholders ({@code :name}); JDBC uses positional
|
||||
* {@code ?}. {@link #parse(String)} rewrites the SQL to positional form while
|
||||
* recording the placeholder order, and {@link #bind} binds each value variant.
|
||||
* The rewrite is shared across MySQL, MariaDB, and PostgreSQL; the only
|
||||
* dialect difference is whether a backslash escapes quotes inside string
|
||||
* literals (see {@link #parse(String, boolean)}).
|
||||
*/
|
||||
final class RdsDataSqlParameters {
|
||||
|
||||
private RdsDataSqlParameters() {
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL rewritten with positional {@code ?} placeholders, plus the ordered
|
||||
* list of the Data API parameter names each placeholder was derived from.
|
||||
* A name repeats once per occurrence in the original SQL.
|
||||
*/
|
||||
record ParsedSql(String sql, List<String> parameterOrder) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrites {@code :name} placeholders to positional {@code ?} without
|
||||
* treating backslash as a string-literal escape (the PostgreSQL default
|
||||
* with {@code standard_conforming_strings} on).
|
||||
*/
|
||||
static ParsedSql parse(String sql) {
|
||||
return parse(sql, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewrites {@code :name} placeholders to positional {@code ?}, skipping over
|
||||
* string literals, quoted/backtick identifiers, line and block comments,
|
||||
* PostgreSQL {@code ::} casts, and PostgreSQL dollar-quoted strings so a
|
||||
* colon inside any of those is left untouched.
|
||||
*
|
||||
* @param backslashEscapes when {@code true}, a backslash inside a single- or
|
||||
* double-quoted string escapes the next character (MySQL/MariaDB
|
||||
* default, i.e. {@code NO_BACKSLASH_ESCAPES} disabled). Backtick
|
||||
* identifiers never honor backslash escaping.
|
||||
*/
|
||||
static ParsedSql parse(String sql, boolean backslashEscapes) {
|
||||
StringBuilder out = new StringBuilder(sql.length());
|
||||
List<String> order = new ArrayList<>();
|
||||
int len = sql.length();
|
||||
int i = 0;
|
||||
while (i < len) {
|
||||
char c = sql.charAt(i);
|
||||
|
||||
if (c == '-' && i + 1 < len && sql.charAt(i + 1) == '-') {
|
||||
int end = sql.indexOf('\n', i);
|
||||
if (end < 0) {
|
||||
end = len;
|
||||
}
|
||||
out.append(sql, i, end);
|
||||
i = end;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '/' && i + 1 < len && sql.charAt(i + 1) == '*') {
|
||||
int end = sql.indexOf("*/", i + 2);
|
||||
end = end < 0 ? len : end + 2;
|
||||
out.append(sql, i, end);
|
||||
i = end;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '\'' || c == '"' || c == '`') {
|
||||
i = copyQuoted(sql, i, c, out, backslashEscapes);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '$') {
|
||||
int consumed = copyDollarQuoted(sql, i, out);
|
||||
if (consumed > i) {
|
||||
i = consumed;
|
||||
continue;
|
||||
}
|
||||
out.append(c);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == ':') {
|
||||
if (i + 1 < len && sql.charAt(i + 1) == ':') {
|
||||
out.append("::");
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
if (i + 1 < len && isNameStart(sql.charAt(i + 1))) {
|
||||
int j = i + 1;
|
||||
while (j < len && isNamePart(sql.charAt(j))) {
|
||||
j++;
|
||||
}
|
||||
order.add(sql.substring(i + 1, j));
|
||||
out.append('?');
|
||||
i = j;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
out.append(c);
|
||||
i++;
|
||||
}
|
||||
return new ParsedSql(out.toString(), order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds each positional placeholder from {@code order} using the matching
|
||||
* {@code SqlParameter} node in {@code parametersByName}.
|
||||
*
|
||||
* @throws AwsException if a placeholder has no matching parameter value
|
||||
*/
|
||||
static void bind(PreparedStatement statement, List<String> order, Map<String, JsonNode> parametersByName)
|
||||
throws SQLException {
|
||||
for (int position = 0; position < order.size(); position++) {
|
||||
String name = order.get(position);
|
||||
JsonNode parameter = parametersByName.get(name);
|
||||
if (parameter == null) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"SQL statement references parameter :" + name
|
||||
+ " but no matching value was supplied.", 400);
|
||||
}
|
||||
bindValue(statement, position + 1, name, parameter);
|
||||
}
|
||||
}
|
||||
|
||||
private static void bindValue(PreparedStatement statement, int index, String name, JsonNode parameter)
|
||||
throws SQLException {
|
||||
JsonNode value = parameter.get("value");
|
||||
if (value == null || value.isNull() || value.path("isNull").asBoolean(false)) {
|
||||
statement.setNull(index, Types.NULL);
|
||||
return;
|
||||
}
|
||||
String typeHint = text(parameter, "typeHint");
|
||||
|
||||
if (value.has("booleanValue")) {
|
||||
statement.setBoolean(index, value.get("booleanValue").asBoolean());
|
||||
} else if (value.has("longValue")) {
|
||||
statement.setLong(index, value.get("longValue").asLong());
|
||||
} else if (value.has("doubleValue")) {
|
||||
statement.setDouble(index, value.get("doubleValue").asDouble());
|
||||
} else if (value.has("blobValue")) {
|
||||
statement.setBytes(index, blobBytes(name, value.get("blobValue")));
|
||||
} else if (value.has("arrayValue")) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"arrayValue is not supported for parameter :" + name
|
||||
+ " by this local RDS Data API implementation.", 400);
|
||||
} else if (value.has("stringValue")) {
|
||||
bindString(statement, index, name, value.get("stringValue").asText(), typeHint);
|
||||
} else {
|
||||
throw new AwsException("BadRequestException",
|
||||
"Parameter :" + name + " has no supported value field.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
private static void bindString(PreparedStatement statement, int index, String name, String value, String typeHint)
|
||||
throws SQLException {
|
||||
String hint = typeHint == null ? "" : typeHint.toUpperCase(Locale.ROOT);
|
||||
try {
|
||||
switch (hint) {
|
||||
case "DECIMAL" -> statement.setBigDecimal(index, new BigDecimal(value));
|
||||
case "TIMESTAMP" -> statement.setTimestamp(index, Timestamp.valueOf(value));
|
||||
case "DATE" -> statement.setDate(index, Date.valueOf(value));
|
||||
case "TIME" -> statement.setTime(index, Time.valueOf(withoutFractionalSeconds(value)));
|
||||
case "UUID" -> statement.setObject(index, UUID.fromString(value));
|
||||
case "JSON" -> statement.setObject(index, value, Types.OTHER);
|
||||
default -> statement.setString(index, value);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"Parameter :" + name + " value \"" + value + "\" is not a valid "
|
||||
+ hint + " for the supplied typeHint.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The AWS RDS Data API documents {@code TIME} as {@code HH:MM:SS[.FFF]} with
|
||||
* optional fractional seconds, but {@link Time#valueOf(String)} only accepts
|
||||
* {@code HH:mm:ss} and throws on a fractional part. Drop any fractional
|
||||
* seconds so a documented-valid value is not falsely rejected.
|
||||
*/
|
||||
private static String withoutFractionalSeconds(String value) {
|
||||
int dot = value.indexOf('.');
|
||||
return dot < 0 ? value : value.substring(0, dot);
|
||||
}
|
||||
|
||||
private static byte[] blobBytes(String name, JsonNode blob) {
|
||||
try {
|
||||
return blob.binaryValue();
|
||||
} catch (IOException e) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"Parameter :" + name + " blobValue is not valid base64: " + e.getMessage(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
private static int copyQuoted(String sql, int start, char quote, StringBuilder out, boolean backslashEscapes) {
|
||||
int len = sql.length();
|
||||
boolean escapable = backslashEscapes && quote != '`';
|
||||
out.append(quote);
|
||||
int i = start + 1;
|
||||
while (i < len) {
|
||||
char c = sql.charAt(i);
|
||||
out.append(c);
|
||||
if (escapable && c == '\\' && i + 1 < len) {
|
||||
out.append(sql.charAt(i + 1));
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
if (c == quote) {
|
||||
if (i + 1 < len && sql.charAt(i + 1) == quote) {
|
||||
out.append(quote);
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
return i + 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
private static int copyDollarQuoted(String sql, int start, StringBuilder out) {
|
||||
int len = sql.length();
|
||||
int tagEnd = start + 1;
|
||||
while (tagEnd < len && isNamePart(sql.charAt(tagEnd))) {
|
||||
tagEnd++;
|
||||
}
|
||||
if (tagEnd >= len || sql.charAt(tagEnd) != '$') {
|
||||
return start;
|
||||
}
|
||||
String tag = sql.substring(start, tagEnd + 1);
|
||||
int close = sql.indexOf(tag, tagEnd + 1);
|
||||
int end = close < 0 ? len : close + tag.length();
|
||||
out.append(sql, start, end);
|
||||
return end;
|
||||
}
|
||||
|
||||
private static boolean isNameStart(char c) {
|
||||
return Character.isLetter(c) || c == '_';
|
||||
}
|
||||
|
||||
private static boolean isNamePart(char c) {
|
||||
return Character.isLetterOrDigit(c) || c == '_';
|
||||
}
|
||||
|
||||
private static String text(JsonNode node, String field) {
|
||||
JsonNode value = node.get(field);
|
||||
return value == null || value.isNull() ? null : value.asText();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -10,7 +10,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
class RdsDataControllerIntegrationTest {
|
||||
|
||||
@Test
|
||||
void executeRejectsSqlParametersWithJsonDataApiError() {
|
||||
void executeRejectsMalformedSqlParametersWithJsonDataApiError() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.body("""
|
||||
@@ -19,7 +19,7 @@ class RdsDataControllerIntegrationTest {
|
||||
"secretArn": "arn:aws:secretsmanager:us-east-1:000000000000:secret:missing",
|
||||
"database": "app",
|
||||
"sql": "select 1",
|
||||
"parameters": [{"name": "id", "value": {"longValue": 1}}]
|
||||
"parameters": {"name": "id", "value": {"longValue": 1}}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
|
||||
@@ -72,6 +72,143 @@ class RdsDataServiceTest {
|
||||
assertEquals(0L, selectResponse.get("numberOfRecordsUpdated").asLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
void bindsSqlParametersThroughPreparedStatements() throws Exception {
|
||||
TestHarness harness = new TestHarness();
|
||||
harness.createTables();
|
||||
|
||||
ObjectNode insert = harness.request("""
|
||||
insert into data_api_items(id, title, score, payload, active, created_at)
|
||||
values (:id, :title, :score, :payload, :active, :created_at)
|
||||
""");
|
||||
ArrayNode insertParams = objectMapper.createArrayNode();
|
||||
insertParams.add(stringParam("id", "p1"));
|
||||
insertParams.add(stringParam("title", "Param"));
|
||||
insertParams.add(longParam("score", 7));
|
||||
insertParams.add(blobParam("payload", new byte[] {9, 8, 7}));
|
||||
insertParams.add(booleanParam("active", true));
|
||||
insertParams.add(hintedStringParam("created_at", "2026-06-09 12:34:56", "TIMESTAMP"));
|
||||
insert.set("parameters", insertParams);
|
||||
ObjectNode insertResponse = harness.service.executeStatement(insert, REGION);
|
||||
assertEquals(1L, insertResponse.get("numberOfRecordsUpdated").asLong());
|
||||
|
||||
ObjectNode select = harness.request(
|
||||
"select title, score, payload, active from data_api_items where id = :id");
|
||||
ArrayNode selectParams = objectMapper.createArrayNode();
|
||||
selectParams.add(stringParam("id", "p1"));
|
||||
select.set("parameters", selectParams);
|
||||
ObjectNode selectResponse = harness.service.executeStatement(select, REGION);
|
||||
|
||||
ArrayNode row = (ArrayNode) selectResponse.get("records").get(0);
|
||||
assertEquals("Param", row.get(0).get("stringValue").asText());
|
||||
assertEquals(7L, row.get(1).get("longValue").asLong());
|
||||
assertArrayEquals(new byte[] {9, 8, 7}, row.get(2).get("blobValue").binaryValue());
|
||||
assertTrue(row.get(3).get("booleanValue").asBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsSqlParameterWithoutMatchingValue() throws Exception {
|
||||
TestHarness harness = new TestHarness();
|
||||
harness.createTables();
|
||||
|
||||
ObjectNode select = harness.request("select 1 from data_api_items where id = :id");
|
||||
ArrayNode params = objectMapper.createArrayNode();
|
||||
params.add(stringParam("other", "value"));
|
||||
select.set("parameters", params);
|
||||
|
||||
AwsException error = assertThrows(AwsException.class,
|
||||
() -> harness.service.executeStatement(select, REGION));
|
||||
assertEquals("BadRequestException", error.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMissingParameterEvenWhenParametersOmitted() throws Exception {
|
||||
TestHarness harness = new TestHarness();
|
||||
harness.createTables();
|
||||
|
||||
ObjectNode select = harness.request("select 1 from data_api_items where id = :id");
|
||||
|
||||
AwsException error = assertThrows(AwsException.class,
|
||||
() -> harness.service.executeStatement(select, REGION));
|
||||
assertEquals("BadRequestException", error.getErrorCode());
|
||||
assertEquals(400, error.getHttpStatus());
|
||||
assertTrue(error.getMessage().contains(":id"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void bindsTimeTypeHintWithOptionalFractionalSeconds() throws Exception {
|
||||
TestHarness harness = new TestHarness();
|
||||
harness.createTables();
|
||||
|
||||
ObjectNode withFraction = harness.request("select cast(:t as time) as t");
|
||||
ArrayNode fractionParams = objectMapper.createArrayNode();
|
||||
fractionParams.add(hintedStringParam("t", "14:30:15.123", "TIME"));
|
||||
withFraction.set("parameters", fractionParams);
|
||||
ObjectNode fractionResponse = harness.service.executeStatement(withFraction, REGION);
|
||||
assertEquals("14:30:15",
|
||||
((ArrayNode) fractionResponse.get("records").get(0)).get(0).get("stringValue").asText());
|
||||
|
||||
ObjectNode withoutFraction = harness.request("select cast(:t as time) as t");
|
||||
ArrayNode plainParams = objectMapper.createArrayNode();
|
||||
plainParams.add(hintedStringParam("t", "09:05:07", "TIME"));
|
||||
withoutFraction.set("parameters", plainParams);
|
||||
ObjectNode plainResponse = harness.service.executeStatement(withoutFraction, REGION);
|
||||
assertEquals("09:05:07",
|
||||
((ArrayNode) plainResponse.get("records").get(0)).get(0).get("stringValue").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMalformedTypeHintValueWithBadRequest() throws Exception {
|
||||
TestHarness harness = new TestHarness();
|
||||
harness.createTables();
|
||||
|
||||
ObjectNode select = harness.request(
|
||||
"select id from data_api_items where created_at = :ts");
|
||||
ArrayNode params = objectMapper.createArrayNode();
|
||||
params.add(hintedStringParam("ts", "not-a-timestamp", "TIMESTAMP"));
|
||||
select.set("parameters", params);
|
||||
|
||||
AwsException error = assertThrows(AwsException.class,
|
||||
() -> harness.service.executeStatement(select, REGION));
|
||||
assertEquals("BadRequestException", error.getErrorCode());
|
||||
assertEquals(400, error.getHttpStatus());
|
||||
assertTrue(error.getMessage().contains(":ts"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMalformedUuidTypeHintValueWithBadRequest() throws Exception {
|
||||
TestHarness harness = new TestHarness();
|
||||
harness.createTables();
|
||||
|
||||
ObjectNode select = harness.request("select id from data_api_items where id = :id");
|
||||
ArrayNode params = objectMapper.createArrayNode();
|
||||
params.add(hintedStringParam("id", "not-a-uuid", "UUID"));
|
||||
select.set("parameters", params);
|
||||
|
||||
AwsException error = assertThrows(AwsException.class,
|
||||
() -> harness.service.executeStatement(select, REGION));
|
||||
assertEquals("BadRequestException", error.getErrorCode());
|
||||
assertEquals(400, error.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsDuplicateParameterNames() throws Exception {
|
||||
TestHarness harness = new TestHarness();
|
||||
harness.createTables();
|
||||
|
||||
ObjectNode select = harness.request("select 1 from data_api_items where id = :id");
|
||||
ArrayNode params = objectMapper.createArrayNode();
|
||||
params.add(stringParam("id", "first"));
|
||||
params.add(stringParam("id", "second"));
|
||||
select.set("parameters", params);
|
||||
|
||||
AwsException error = assertThrows(AwsException.class,
|
||||
() -> harness.service.executeStatement(select, REGION));
|
||||
assertEquals("BadRequestException", error.getErrorCode());
|
||||
assertEquals(400, error.getHttpStatus());
|
||||
assertTrue(error.getMessage().contains(":id"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void commitsRollsBackAndRejectsInvalidTransactionRequests() throws Exception {
|
||||
TestHarness harness = new TestHarness();
|
||||
@@ -293,6 +430,40 @@ class RdsDataServiceTest {
|
||||
return request;
|
||||
}
|
||||
|
||||
private ObjectNode stringParam(String name, String value) {
|
||||
ObjectNode param = objectMapper.createObjectNode();
|
||||
param.put("name", name);
|
||||
param.set("value", objectMapper.createObjectNode().put("stringValue", value));
|
||||
return param;
|
||||
}
|
||||
|
||||
private ObjectNode hintedStringParam(String name, String value, String typeHint) {
|
||||
ObjectNode param = stringParam(name, value);
|
||||
param.put("typeHint", typeHint);
|
||||
return param;
|
||||
}
|
||||
|
||||
private ObjectNode longParam(String name, long value) {
|
||||
ObjectNode param = objectMapper.createObjectNode();
|
||||
param.put("name", name);
|
||||
param.set("value", objectMapper.createObjectNode().put("longValue", value));
|
||||
return param;
|
||||
}
|
||||
|
||||
private ObjectNode booleanParam(String name, boolean value) {
|
||||
ObjectNode param = objectMapper.createObjectNode();
|
||||
param.put("name", name);
|
||||
param.set("value", objectMapper.createObjectNode().put("booleanValue", value));
|
||||
return param;
|
||||
}
|
||||
|
||||
private ObjectNode blobParam(String name, byte[] value) {
|
||||
ObjectNode param = objectMapper.createObjectNode();
|
||||
param.put("name", name);
|
||||
param.set("value", objectMapper.createObjectNode().put("blobValue", value));
|
||||
return param;
|
||||
}
|
||||
|
||||
private static SecretsManagerService fallbackSecrets() {
|
||||
SecretsManagerService secrets = mock(SecretsManagerService.class);
|
||||
when(secrets.getSecretValue(any(), any(), any(), any()))
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package io.github.hectorvent.floci.services.rdsdata;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class RdsDataSqlParametersTest {
|
||||
|
||||
@Test
|
||||
void rewritesNamedPlaceholdersToPositional() {
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(
|
||||
"select * from t where id = :id and name = :name");
|
||||
|
||||
assertEquals("select * from t where id = ? and name = ?", parsed.sql());
|
||||
assertEquals(List.of("id", "name"), parsed.parameterOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
void repeatsPlaceholderOncePerOccurrence() {
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(
|
||||
"select * from t where a = :id or b = :id");
|
||||
|
||||
assertEquals("select * from t where a = ? or b = ?", parsed.sql());
|
||||
assertEquals(List.of("id", "id"), parsed.parameterOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
void ignoresColonsInsideStringLiteralsAndIdentifiers() {
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(
|
||||
"select ':notparam', \":col:\", `x:y` from t where id = :id");
|
||||
|
||||
assertEquals("select ':notparam', \":col:\", `x:y` from t where id = ?", parsed.sql());
|
||||
assertEquals(List.of("id"), parsed.parameterOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
void preservesPostgresCastOperatorAndCastsParameters() {
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(
|
||||
"select id::text from t where created = :ts::timestamp");
|
||||
|
||||
assertEquals("select id::text from t where created = ?::timestamp", parsed.sql());
|
||||
assertEquals(List.of("ts"), parsed.parameterOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
void ignoresColonsInsideComments() {
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(
|
||||
"select 1 -- :nope\n/* :also */ where id = :id");
|
||||
|
||||
assertEquals("select 1 -- :nope\n/* :also */ where id = ?", parsed.sql());
|
||||
assertEquals(List.of("id"), parsed.parameterOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
void ignoresColonsInsideDollarQuotedStrings() {
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(
|
||||
"select $tag$ :nope $tag$ where id = :id");
|
||||
|
||||
assertEquals("select $tag$ :nope $tag$ where id = ?", parsed.sql());
|
||||
assertEquals(List.of("id"), parsed.parameterOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
void treatsBackslashAsEscapeInStringLiteralWhenEnabled() {
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(
|
||||
"select * from t where note = 'it\\'s a :id' and id = :id", true);
|
||||
|
||||
assertEquals("select * from t where note = 'it\\'s a :id' and id = ?", parsed.sql());
|
||||
assertEquals(List.of("id"), parsed.parameterOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
void treatsBackslashQuoteAsClosingQuoteWhenEscapesDisabled() {
|
||||
// PostgreSQL default (standard_conforming_strings on): backslash is literal,
|
||||
// so the first unescaped quote closes the literal.
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(
|
||||
"select 'a\\' as c, :id", false);
|
||||
|
||||
assertEquals("select 'a\\' as c, ?", parsed.sql());
|
||||
assertEquals(List.of("id"), parsed.parameterOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
void ignoresBackslashInsideBacktickIdentifierEvenWhenEscapesEnabled() {
|
||||
RdsDataSqlParameters.ParsedSql parsed = RdsDataSqlParameters.parse(
|
||||
"select `a\\` , id from t where id = :id", true);
|
||||
|
||||
assertEquals("select `a\\` , id from t where id = ?", parsed.sql());
|
||||
assertEquals(List.of("id"), parsed.parameterOrder());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user