@@ -105,6 +105,8 @@ import {
105105 intervalValue ,
106106 listValue ,
107107 mapValue ,
108+ quotedIdentifier ,
109+ quotedString ,
108110 structValue ,
109111 timeTZValue ,
110112 timeValue ,
@@ -2402,4 +2404,45 @@ ORDER BY name
24022404 } ) ;
24032405 } ) ;
24042406 } ) ;
2407+
2408+ describe ( 'SQL utility functions' , ( ) => {
2409+ test ( 'quotedString' , ( ) => {
2410+ // Basic string
2411+ assert . equal ( quotedString ( 'hello' ) , "'hello'" ) ;
2412+
2413+ // String with single quotes
2414+ assert . equal ( quotedString ( "it's" ) , "'it''s'" ) ;
2415+ assert . equal ( quotedString ( "'quoted'" ) , "'''quoted'''" ) ;
2416+
2417+ // String with multiple single quotes
2418+ assert . equal ( quotedString ( "it's 'really' good" ) , "'it''s ''really'' good'" ) ;
2419+
2420+ // Empty string
2421+ assert . equal ( quotedString ( '' ) , "''" ) ;
2422+
2423+ // String with special characters
2424+ assert . equal ( quotedString ( 'hello\nworld' ) , "'hello\nworld'" ) ;
2425+ assert . equal ( quotedString ( 'tab\there' ) , "'tab\there'" ) ;
2426+ } ) ;
2427+
2428+ test ( 'quotedIdentifier' , ( ) => {
2429+ // Basic identifier
2430+ assert . equal ( quotedIdentifier ( 'table_name' ) , '"table_name"' ) ;
2431+
2432+ // Identifier with double quotes
2433+ assert . equal ( quotedIdentifier ( 'my"table' ) , '"my""table"' ) ;
2434+ assert . equal ( quotedIdentifier ( '"column"' ) , '"""column"""' ) ;
2435+
2436+ // Identifier with multiple double quotes
2437+ assert . equal ( quotedIdentifier ( 'my"special"table' ) , '"my""special""table"' ) ;
2438+
2439+ // Empty identifier
2440+ assert . equal ( quotedIdentifier ( '' ) , '""' ) ;
2441+
2442+ // Identifier with special characters
2443+ assert . equal ( quotedIdentifier ( 'table-name' ) , '"table-name"' ) ;
2444+ assert . equal ( quotedIdentifier ( 'table.name' ) , '"table.name"' ) ;
2445+ assert . equal ( quotedIdentifier ( 'table name' ) , '"table name"' ) ;
2446+ } ) ;
2447+ } ) ;
24052448} ) ;
0 commit comments