@@ -5,14 +5,16 @@ describe('TypeCast with negative numbers', () => {
55 const sql = `SELECT -1::integer` ;
66 const result = await expectParseDeparse ( sql ) ;
77 // Negative numbers require CAST() syntax for precedence
8- expect ( result ) . toBe ( `SELECT CAST(-1 AS integer)` ) ;
8+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
9+ expect ( result ) . toBe ( `SELECT CAST(-1 AS int)` ) ;
910 } ) ;
1011
1112 it ( 'should handle parenthesized negative integer' , async ( ) => {
1213 const sql = `SELECT (-1)::integer` ;
1314 const result = await expectParseDeparse ( sql ) ;
1415 // Parenthesized negative numbers can use :: syntax
15- expect ( result ) . toBe ( `SELECT (-1)::integer` ) ;
16+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
17+ expect ( result ) . toBe ( `SELECT (-1)::int` ) ;
1618 } ) ;
1719
1820 it ( 'should handle negative float with CAST syntax' , async ( ) => {
@@ -42,21 +44,24 @@ describe('TypeCast with complex expressions', () => {
4244 const sql = `SELECT (1 + 2)::integer` ;
4345 const result = await expectParseDeparse ( sql ) ;
4446 // Complex expressions require CAST() syntax
45- expect ( result ) . toBe ( `SELECT CAST((1 + 2) AS integer)` ) ;
47+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
48+ expect ( result ) . toBe ( `SELECT CAST((1 + 2) AS int)` ) ;
4649 } ) ;
4750
4851 it ( 'should handle subtraction expression' , async ( ) => {
4952 const sql = `SELECT (a - b)::integer FROM t` ;
5053 const result = await expectParseDeparse ( sql ) ;
5154 // Complex expressions require CAST() syntax
52- expect ( result ) . toBe ( `SELECT CAST((a - b) AS integer) FROM t` ) ;
55+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
56+ expect ( result ) . toBe ( `SELECT CAST((a - b) AS int) FROM t` ) ;
5357 } ) ;
5458
5559 it ( 'should handle CASE expression with CAST syntax' , async ( ) => {
5660 const sql = `SELECT (CASE WHEN a > 0 THEN 1 ELSE 2 END)::integer FROM t` ;
5761 const result = await expectParseDeparse ( sql ) ;
5862 // Complex expressions require CAST() syntax
59- expect ( result ) . toBe ( `SELECT CAST((CASE WHEN (a > 0) THEN 1 ELSE 2 END) AS integer) FROM t` ) ;
63+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
64+ expect ( result ) . toBe ( `SELECT CAST((CASE WHEN (a > 0) THEN 1 ELSE 2 END) AS int) FROM t` ) ;
6065 } ) ;
6166
6267 it ( 'should handle boolean expression' , async ( ) => {
@@ -158,7 +163,8 @@ describe('TypeCast with simple constants', () => {
158163 it ( 'should handle positive integer with :: syntax' , async ( ) => {
159164 const sql = `SELECT 123::integer` ;
160165 const result = await expectParseDeparse ( sql ) ;
161- expect ( result ) . toBe ( `SELECT 123::integer` ) ;
166+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
167+ expect ( result ) . toBe ( `SELECT 123::int` ) ;
162168 } ) ;
163169
164170 it ( 'should handle positive float with :: syntax' , async ( ) => {
@@ -183,28 +189,32 @@ describe('TypeCast with simple constants', () => {
183189 const sql = `SELECT NULL::integer` ;
184190 const result = await expectParseDeparse ( sql ) ;
185191 // NULL can use :: syntax
186- expect ( result ) . toBe ( `SELECT NULL::integer` ) ;
192+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
193+ expect ( result ) . toBe ( `SELECT NULL::int` ) ;
187194 } ) ;
188195} ) ;
189196
190197describe ( 'TypeCast with column references' , ( ) => {
191198 it ( 'should handle simple column reference with :: syntax' , async ( ) => {
192199 const sql = `SELECT a::integer FROM t` ;
193200 const result = await expectParseDeparse ( sql ) ;
194- expect ( result ) . toBe ( `SELECT a::integer FROM t` ) ;
201+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
202+ expect ( result ) . toBe ( `SELECT a::int FROM t` ) ;
195203 } ) ;
196204
197205 it ( 'should handle qualified column reference' , async ( ) => {
198206 const sql = `SELECT t.a::integer FROM t` ;
199207 const result = await expectParseDeparse ( sql ) ;
200- expect ( result ) . toBe ( `SELECT t.a::integer FROM t` ) ;
208+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
209+ expect ( result ) . toBe ( `SELECT t.a::int FROM t` ) ;
201210 } ) ;
202211
203212 it ( 'should handle fully qualified column reference' , async ( ) => {
204213 const sql = `SELECT schema.t.a::integer FROM schema.t` ;
205214 const result = await expectParseDeparse ( sql ) ;
206215 // Fully qualified column references can use :: syntax
207- expect ( result ) . toBe ( `SELECT schema.t.a::integer FROM schema.t` ) ;
216+ // Note: PostgreSQL normalizes "integer" to "int" in the AST
217+ expect ( result ) . toBe ( `SELECT schema.t.a::int FROM schema.t` ) ;
208218 } ) ;
209219} ) ;
210220
@@ -236,13 +246,15 @@ describe('TypeCast with arrays', () => {
236246 const sql = `SELECT ARRAY[1, 2, 3]::integer[]` ;
237247 const result = await expectParseDeparse ( sql ) ;
238248 // Array literals require CAST() syntax
249+ // Note: PostgreSQL normalizes "integer[]" to "int[]" in the AST
239250 expect ( result ) . toBe ( `SELECT CAST(ARRAY[1, 2, 3] AS int[])` ) ;
240251 } ) ;
241252
242253 it ( 'should handle array string literal cast' , async ( ) => {
243254 const sql = `SELECT '{1,2,3}'::integer[]` ;
244255 const result = await expectParseDeparse ( sql ) ;
245256 // Array string literals require CAST() syntax
257+ // Note: PostgreSQL normalizes "integer[]" to "int[]" in the AST
246258 expect ( result ) . toBe ( `SELECT CAST('{1,2,3}' AS int[])` ) ;
247259 } ) ;
248260} ) ;
0 commit comments