Skip to content

Commit

Permalink
Add more test cases for all other data types.
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Teng <[email protected]>
  • Loading branch information
Jason Teng committed Sep 23, 2024
1 parent 3270dee commit 7ecf63e
Show file tree
Hide file tree
Showing 2 changed files with 249 additions and 9 deletions.
152 changes: 147 additions & 5 deletions test/JDBC/expected/temp_table.out
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,156 @@ int#!#varchar#!#int
~~END~~


-- BABEL-5273 ALTER COLUMN to another char type
INSERT INTO #t1 (b) VALUES ('hello')
-- BABEL-5273 ALTER COLUMN to another type
ALTER TABLE #t1 ALTER COLUMN b TINYINT
GO
~~ROW COUNT: 1~~

ALTER TABLE #t1 ALTER COLUMN b SMALLINT
GO

ALTER TABLE #t1 ALTER COLUMN b INT
GO

ALTER TABLE #t1 ALTER COLUMN b BIGINT
GO

ALTER TABLE #t1 ALTER COLUMN b BIT
GO

ALTER TABLE #t1 ALTER COLUMN b DECIMAL
GO

ALTER TABLE #t1 ALTER COLUMN b NUMERIC
GO

ALTER TABLE #t1 ALTER COLUMN b MONEY
GO

ALTER TABLE #t1 ALTER COLUMN b SMALLMONEY
GO

ALTER TABLE #t1 ALTER COLUMN b FLOAT
GO

ALTER TABLE #t1 ALTER COLUMN b REAL
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b DATE
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: column "b" cannot be cast automatically to type date)~~


-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b TIME
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: column "b" cannot be cast automatically to type time without time zone)~~


-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b DATETIME2
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: column "b" cannot be cast automatically to type datetime2)~~


ALTER TABLE #t1 ALTER COLUMN b char(5)
-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b DATETIMEOFFSET
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: column "b" cannot be cast automatically to type datetimeoffset)~~


ALTER TABLE #t1 ALTER COLUMN b DATETIME
GO

ALTER TABLE #t1 ALTER COLUMN b SMALLDATETIME
GO

ALTER TABLE #t1 ALTER COLUMN b CHAR
GO

ALTER TABLE #t1 ALTER COLUMN b VARCHAR
GO

-- TODO: fix this, it should work and not raise a syntax error
ALTER TABLE #t1 ALTER COLUMN b TEXT
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: syntax error at or near "TEXT")~~


ALTER TABLE #t1 ALTER COLUMN b NCHAR
GO

ALTER TABLE #t1 ALTER COLUMN b NVARCHAR
GO

ALTER TABLE #t1 ALTER COLUMN b NTEXT
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b BINARY
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: type "BINARY" does not exist)~~


-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b VARBINARY
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: column "b" cannot be cast automatically to type varbinary)~~


-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b IMAGE
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: column "b" cannot be cast automatically to type image)~~


-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b GEOGRAPHY
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: column "b" cannot be cast automatically to type geography)~~


-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b GEOMETRY
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: column "b" cannot be cast automatically to type geometry)~~


-- TODO: fix this, it should work and not raise a syntax error
ALTER TABLE #t1 ALTER COLUMN b XML
GO
~~ERROR (Code: 33557097)~~

~~ERROR (Message: syntax error at or near "XML")~~


ALTER TABLE #t1 ALTER COLUMN b CHAR(5)
GO

INSERT INTO #t1 (b) VALUES ('hello')
GO
~~ROW COUNT: 1~~


SELECT * FROM #t1
GO
Expand All @@ -82,7 +224,7 @@ int#!#char#!#int


-- should fail due to possible truncation
ALTER TABLE #t1 ALTER COLUMN b char(4)
ALTER TABLE #t1 ALTER COLUMN b CHAR(4)
GO
~~ERROR (Code: 8152)~~

Expand Down
106 changes: 102 additions & 4 deletions test/JDBC/input/temp_tables/temp_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,116 @@ GO
SELECT * FROM #t1
GO

-- BABEL-5273 ALTER COLUMN to another char type
INSERT INTO #t1 (b) VALUES ('hello')
-- BABEL-5273 ALTER COLUMN to another type
ALTER TABLE #t1 ALTER COLUMN b TINYINT
GO

ALTER TABLE #t1 ALTER COLUMN b SMALLINT
GO

ALTER TABLE #t1 ALTER COLUMN b INT
GO

ALTER TABLE #t1 ALTER COLUMN b BIGINT
GO

ALTER TABLE #t1 ALTER COLUMN b BIT
GO

ALTER TABLE #t1 ALTER COLUMN b DECIMAL
GO

ALTER TABLE #t1 ALTER COLUMN b NUMERIC
GO

ALTER TABLE #t1 ALTER COLUMN b MONEY
GO

ALTER TABLE #t1 ALTER COLUMN b SMALLMONEY
GO

ALTER TABLE #t1 ALTER COLUMN b FLOAT
GO

ALTER TABLE #t1 ALTER COLUMN b REAL
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b DATE
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b TIME
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b DATETIME2
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b DATETIMEOFFSET
GO

ALTER TABLE #t1 ALTER COLUMN b DATETIME
GO

ALTER TABLE #t1 ALTER COLUMN b SMALLDATETIME
GO

ALTER TABLE #t1 ALTER COLUMN b CHAR
GO

ALTER TABLE #t1 ALTER COLUMN b VARCHAR
GO

-- TODO: fix this, it should work and not raise a syntax error
ALTER TABLE #t1 ALTER COLUMN b TEXT
GO

ALTER TABLE #t1 ALTER COLUMN b NCHAR
GO

ALTER TABLE #t1 ALTER COLUMN b NVARCHAR
GO

ALTER TABLE #t1 ALTER COLUMN b NTEXT
GO

ALTER TABLE #t1 ALTER COLUMN b char(5)
-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b BINARY
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b VARBINARY
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b IMAGE
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b GEOGRAPHY
GO

-- should raise error due to incompatible types
ALTER TABLE #t1 ALTER COLUMN b GEOMETRY
GO

-- TODO: fix this, it should work and not raise a syntax error
ALTER TABLE #t1 ALTER COLUMN b XML
GO

ALTER TABLE #t1 ALTER COLUMN b CHAR(5)
GO

INSERT INTO #t1 (b) VALUES ('hello')
GO

SELECT * FROM #t1
GO

-- should fail due to possible truncation
ALTER TABLE #t1 ALTER COLUMN b char(4)
ALTER TABLE #t1 ALTER COLUMN b CHAR(4)
GO

ALTER TABLE #t1 DROP COLUMN b
Expand Down

0 comments on commit 7ecf63e

Please sign in to comment.