Skip to content

Commit

Permalink
Merge pull request #70 from zendesk/case_insensitive
Browse files Browse the repository at this point in the history
cast column names to lower case
  • Loading branch information
Ben Osheroff committed Jun 22, 2015
2 parents c5e4098 + 3f800d9 commit 951a34e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/zendesk/maxwell/schema/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,21 @@ private void initColumnOffsetMap() {
}

public int findColumnIndex(String name) {
String lcName = name.toLowerCase();
initColumnOffsetMap();

if ( this.columnOffsetMap.containsKey(name) ) {
return this.columnOffsetMap.get(name);
if ( this.columnOffsetMap.containsKey(lcName) ) {
return this.columnOffsetMap.get(lcName);
} else {
return -1;
}
}

private ColumnDef findColumn(String name) {
String lcName = name.toLowerCase();

for (ColumnDef c : columnList ) {
if ( c.getName().equals(name) )
if ( c.getName().equals(lcName) )
return c;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public abstract class ColumnDef {

public ColumnDef(String tableName, String name, String type, int pos) {
this.tableName = tableName;
this.name = name;
this.name = name.toLowerCase();
this.type = type;
this.pos = pos;
this.signed = false;
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/zendesk/maxwell/MaxwellIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,9 @@ public void testSetJSON() throws Exception {
public void testZeroCreatedAtJSON() throws Exception {
runJSONTestFile(getSQLDir() + "/json/test_zero_created_at");
}

@Test
public void testCaseSensitivity() throws Exception {
runJSONTestFile(getSQLDir() + "/json/test_case_insensitive");
}
}
5 changes: 5 additions & 0 deletions src/test/resources/sql/json/test_case_insensitive
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
create database case_db;
use case_db;
create table case_db.test_case(ID int(10) unsigned not null auto_increment primary key, BAR_FIELD varchar(255));
insert into test_case set bar_field='bar';
-> {database:"case_db", table: "test_case", type: "insert", data: {"id": 1, bar_field: "bar"}}

0 comments on commit 951a34e

Please sign in to comment.