Skip to content

Commit 9cd2417

Browse files
authored
Revise RowMetaData#getColumnMetadata(String) (#257)
Motivation: The current behavior does not align with the specification Modifications: implement the intended behavior as per the specification. Result: Correct behavior
1 parent dcbd67a commit 9cd2417

File tree

7 files changed

+110
-541
lines changed

7 files changed

+110
-541
lines changed

r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/ColumnNameSet.java

Lines changed: 0 additions & 216 deletions
This file was deleted.

r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/InsertSyntheticRow.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,11 @@ final class InsertSyntheticRow implements MySqlRow, MySqlRowMetadata, MySqlColum
5252

5353
private final long lastInsertId;
5454

55-
private final ColumnNameSet nameSet;
56-
5755
InsertSyntheticRow(Codecs codecs, String keyName, long lastInsertId) {
5856
this.codecs = requireNonNull(codecs, "codecs must not be null");
5957
this.keyName = requireNonNull(keyName, "keyName must not be null");
6058
// lastInsertId may be negative if key is BIGINT UNSIGNED and value overflow than signed int64.
6159
this.lastInsertId = lastInsertId;
62-
// Singleton name must be sorted.
63-
this.nameSet = ColumnNameSet.of(keyName);
6460
}
6561

6662
@Override
@@ -164,14 +160,14 @@ public <T> T get(String name, ParameterizedType type) {
164160
lastInsertId < 0 ? Long.toUnsignedString(lastInsertId) : lastInsertId));
165161
}
166162

167-
private void assertValidName(String name) {
168-
if (!contains0(name)) {
169-
throw new NoSuchElementException("Column name '" + name + "' does not exist in " + this.nameSet);
170-
}
163+
private boolean contains0(final String name) {
164+
return keyName.equalsIgnoreCase(name);
171165
}
172166

173-
private boolean contains0(String name) {
174-
return nameSet.contains(name);
167+
private void assertValidName(final String name) {
168+
if (!contains0(name)) {
169+
throw new NoSuchElementException("Column name '" + name + "' does not exist in {" + name + '}');
170+
}
175171
}
176172

177173
private <T> T get0(Class<?> type) {

r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlColumnDescriptor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.asyncer.r2dbc.mysql.constant.MySqlType;
2424
import io.asyncer.r2dbc.mysql.message.server.DefinitionMetadataMessage;
2525
import io.r2dbc.spi.Nullability;
26+
import org.jetbrains.annotations.VisibleForTesting;
2627

2728
import static io.asyncer.r2dbc.mysql.internal.util.AssertUtils.require;
2829
import static io.asyncer.r2dbc.mysql.internal.util.AssertUtils.requireNonNull;
@@ -50,7 +51,8 @@ final class MySqlColumnDescriptor implements MySqlColumnMetadata {
5051

5152
private final int collationId;
5253

53-
private MySqlColumnDescriptor(int index, short typeId, String name, int definitions,
54+
@VisibleForTesting
55+
MySqlColumnDescriptor(int index, short typeId, String name, int definitions,
5456
long size, int decimals, int collationId) {
5557
require(index >= 0, "index must not be a negative integer");
5658
require(size >= 0, "size must not be a negative integer");

0 commit comments

Comments
 (0)