Skip to content

Commit

Permalink
fix: modify exp/database/sql/ddl/cockroachdb data types
Browse files Browse the repository at this point in the history
  • Loading branch information
ginokent committed Dec 31, 2023
1 parent 0534760 commit 988f372
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions exp/database/sql/ddl/cockroachdb/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func TestDataType_StringForDiff(t *testing.T) {

t.Run("success", func(t *testing.T) {
t.Parallel()
dataType := &DataType{Name: "integer", Type: TOKEN_INTEGER, Size: ""}
expected := string(TOKEN_INTEGER)
dataType := &DataType{Name: "integer", Type: TOKEN_INT4, Size: ""}
expected := string(TOKEN_INT4)
actual := dataType.StringForDiff()

require.Equal(t, expected, actual)
Expand Down
18 changes: 9 additions & 9 deletions exp/database/sql/ddl/cockroachdb/lexar.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ const (

// DATA TYPE.
TOKEN_BOOL TokenType = "BOOL" //diff:ignore-line-postgres-cockroach
TOKEN_SMALLINT TokenType = "SMALLINT"
TOKEN_INTEGER TokenType = "INTEGER"
TOKEN_BIGINT TokenType = "BIGINT"
TOKEN_INT2 TokenType = "INT2"
TOKEN_INT4 TokenType = "INT4"
TOKEN_INT8 TokenType = "INT8"
TOKEN_DECIMAL TokenType = "DECIMAL"
TOKEN_NUMERIC TokenType = "NUMERIC"
TOKEN_REAL TokenType = "REAL"
Expand Down Expand Up @@ -164,12 +164,12 @@ func lookupIdent(ident string) TokenType {
return TOKEN_TO
case "BOOLEAN", "BOOL": //diff:ignore-line-postgres-cockroach
return TOKEN_BOOL //diff:ignore-line-postgres-cockroach
case "SMALLINT":
return TOKEN_SMALLINT
case "INTEGER", "INT":
return TOKEN_INTEGER
case "BIGINT":
return TOKEN_BIGINT
case "INT2", "SMALLINT":
return TOKEN_INT2
case "INT4", "INTEGER", "INT":
return TOKEN_INT4
case "INT8", "BIGINT":
return TOKEN_INT8
case "DECIMAL":
return TOKEN_DECIMAL
case "NUMERIC":
Expand Down
8 changes: 4 additions & 4 deletions exp/database/sql/ddl/cockroachdb/lexar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ func Test_lookupIdent(t *testing.T) {
{name: "success,TO", input: "TO", want: TOKEN_TO},
{name: "success,BOOL", input: "BOOL", want: TOKEN_BOOL},
{name: "success,BOOLEAN", input: "BOOLEAN", want: TOKEN_BOOL},
{name: "success,SMALLINT", input: "SMALLINT", want: TOKEN_SMALLINT},
{name: "success,INTEGER", input: "INTEGER", want: TOKEN_INTEGER},
{name: "success,INT", input: "INT", want: TOKEN_INTEGER},
{name: "success,BIGINT", input: "BIGINT", want: TOKEN_BIGINT},
{name: "success,SMALLINT", input: "SMALLINT", want: TOKEN_INT2},
{name: "success,INTEGER", input: "INTEGER", want: TOKEN_INT4},
{name: "success,INT", input: "INT", want: TOKEN_INT4},
{name: "success,BIGINT", input: "BIGINT", want: TOKEN_INT8},
{name: "success,DECIMAL", input: "DECIMAL", want: TOKEN_DECIMAL},
{name: "success,NUMERIC", input: "NUMERIC", want: TOKEN_NUMERIC},
{name: "success,REAL", input: "REAL", want: TOKEN_REAL},
Expand Down
2 changes: 1 addition & 1 deletion exp/database/sql/ddl/cockroachdb/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ func isReservedValue(tokenType TokenType) bool {
func isDataType(tokenType TokenType) bool {
switch tokenType { //nolint:exhaustive
case TOKEN_BOOL, //diff:ignore-line-postgres-cockroach
TOKEN_SMALLINT, TOKEN_INTEGER, TOKEN_BIGINT,
TOKEN_INT2, TOKEN_INT4, TOKEN_INT8,
TOKEN_DECIMAL, TOKEN_NUMERIC,
TOKEN_REAL, TOKEN_DOUBLE, /* TOKEN_PRECISION, */
TOKEN_SMALLSERIAL, TOKEN_SERIAL, TOKEN_BIGSERIAL,
Expand Down

0 comments on commit 988f372

Please sign in to comment.