Skip to content

Commit

Permalink
Merge pull request #298 from HemeraOne/293-mediumint-fix
Browse files Browse the repository at this point in the history
Fixes mediumint not being recognized as number
  • Loading branch information
shuhaowu authored Jul 12, 2021
2 parents 459b862 + 1831785 commit d7a3f61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion table_schema_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (t *TableSchema) paginationKeyColumn(cascadingPaginationColumnConfig *Casca
err = NonExistingPaginationKeyError(t.Schema, t.Name)
}

if paginationKeyColumn != nil && paginationKeyColumn.Type != schema.TYPE_NUMBER {
if paginationKeyColumn != nil && paginationKeyColumn.Type != schema.TYPE_NUMBER && paginationKeyColumn.Type != schema.TYPE_MEDIUM_INT {
return nil, -1, NonNumericPaginationKeyError(t.Schema, t.Name, paginationKeyColumn.Name)
}

Expand Down
13 changes: 13 additions & 0 deletions test/go/table_schema_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ func (this *TableSchemaCacheTestSuite) TestLoadTablesRejectTablesWithoutNumericP
this.Require().EqualError(err, ghostferry.NonNumericPaginationKeyError(testhelpers.TestSchemaName, table, paginationColumn).Error())
this.Require().Contains(err.Error(), table)
}
func (this *TableSchemaCacheTestSuite) TestLoadTablesRejectTablesWithoutNumericPKWithMediumInt() {
table := "pagination_by_column_medium_int_pk"
paginationColumn := "id"
query := fmt.Sprintf("CREATE TABLE %s.%s (%s mediumint(8) not null, data TEXT, primary key(%s))", testhelpers.TestSchemaName, table, paginationColumn, paginationColumn)
_, err := this.Ferry.SourceDB.Exec(query)
this.Require().Nil(err)

tableSchemaCache, err := ghostferry.LoadTables(this.Ferry.SourceDB, this.tableFilter, nil, nil, nil, nil)

this.Require().Nil(err)
this.Require().Contains(tableSchemaCache, testhelpers.TestSchemaName + "." + table)
this.Require().Equal(1, len(tableSchemaCache[testhelpers.TestSchemaName + "." + table].PKColumns))
}

func (this *TableSchemaCacheTestSuite) TestLoadTablesCascadingPaginationColumnConfigRightScenario1() {
table := "pagination_by_column_config_right_scenario_1"
Expand Down

0 comments on commit d7a3f61

Please sign in to comment.