File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
main/java/com/google/cloud/spanner
test/java/com/google/cloud/spanner Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -472,9 +472,9 @@ public int getFieldIndex(String fieldName) {
472472 Map <String , Integer > tmp = new TreeMap <>();
473473 for (int i = 0 ; i < getStructFields ().size (); ++i ) {
474474 Type .StructField field = getStructFields ().get (i );
475- if (tmp .put (field .getName (), i ) != null ) {
475+ if (tmp .put (field .getName (). toLowerCase () , i ) != null ) {
476476 // Column name appears more than once: mark as ambiguous.
477- tmp .put (field .getName (), AMBIGUOUS_FIELD );
477+ tmp .put (field .getName (). toLowerCase () , AMBIGUOUS_FIELD );
478478 }
479479 }
480480 // Benign race: Java's final field semantics mean that if we see a non-null "fieldsByName",
@@ -485,7 +485,10 @@ public int getFieldIndex(String fieldName) {
485485 fieldsByName = ImmutableMap .copyOf (tmp );
486486 }
487487
488- Integer index = fieldsByName .get (fieldName );
488+ if (fieldName == null ) {
489+ throw new IllegalArgumentException ("Field name cannot be null" );
490+ }
491+ Integer index = fieldsByName .get (fieldName .toLowerCase ());
489492 if (index == null ) {
490493 throw new IllegalArgumentException ("Field not found: " + fieldName );
491494 }
Original file line number Diff line number Diff line change @@ -522,7 +522,7 @@ public void struct() {
522522 assertThat (t .getStructFields ().get (2 ).getType ()).isEqualTo (Type .pgNumeric ());
523523 assertThat (t .toString ()).isEqualTo ("STRUCT<f1 INT64, f2 STRING, f3 NUMERIC<PG_NUMERIC>>" );
524524 assertThat (t .getFieldIndex ("f1" )).isEqualTo (0 );
525- assertThat (t .getFieldIndex ("f2 " )).isEqualTo (1 );
525+ assertThat (t .getFieldIndex ("F2 " )).isEqualTo (1 );
526526 assertThat (t .getFieldIndex ("f3" )).isEqualTo (2 );
527527
528528 assertProtoEquals (
You can’t perform that action at this time.
0 commit comments