@@ -14,6 +14,9 @@ const connectionParams = {
1414 engineName : process . env . FIREBOLT_ENGINE_NAME as string
1515} ;
1616
17+ const mixedCaseDBName = process . env . FIREBOLT_DATABASE + "MiXeDcAsE" ;
18+ const mixedCaseEngineName = process . env . FIREBOLT_ENGINE_NAME + "MiXeDcAsE" ;
19+
1720jest . setTimeout ( 500000 ) ;
1821
1922describe ( "infra v2 integration test" , ( ) => {
@@ -23,10 +26,10 @@ describe("infra v2 integration test", () => {
2326 } ) ;
2427 const connection = await firebolt . connect ( systemEngineConnectionParams ) ;
2528 await connection . execute (
26- `CREATE ENGINE IF NOT EXISTS ${ connectionParams . engineName } `
29+ `CREATE ENGINE IF NOT EXISTS " ${ connectionParams . engineName } " `
2730 ) ;
2831 await connection . execute (
29- `CREATE DATABASE IF NOT EXISTS ${ connectionParams . database } `
32+ `CREATE DATABASE IF NOT EXISTS " ${ connectionParams . database } " `
3033 ) ;
3134 } ) ;
3235
@@ -35,13 +38,20 @@ describe("infra v2 integration test", () => {
3538 apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
3639 } ) ;
3740 const connection = await firebolt . connect ( systemEngineConnectionParams ) ;
38- await connection . execute ( `STOP ENGINE ${ connectionParams . engineName } ` ) ;
41+ await connection . execute ( `STOP ENGINE " ${ connectionParams . engineName } " ` ) ;
3942 await connection . execute (
40- `DROP ENGINE IF EXISTS ${ connectionParams . engineName } `
43+ `DROP ENGINE IF EXISTS " ${ connectionParams . engineName } " `
4144 ) ;
4245 await connection . execute (
43- `DROP DATABASE IF EXISTS ${ connectionParams . database } `
46+ `DROP DATABASE IF EXISTS " ${ connectionParams . database } " `
4447 ) ;
48+ try {
49+ await connection . execute ( `STOP ENGINE "${ mixedCaseEngineName } "` ) ;
50+ } catch ( error ) {
51+ // Ignore the error if the engine does not exist
52+ }
53+ await connection . execute ( `DROP ENGINE IF EXISTS "${ mixedCaseEngineName } "` ) ;
54+ await connection . execute ( `DROP DATABASE IF EXISTS "${ mixedCaseDBName } "` ) ;
4555 } ) ;
4656
4757 it ( "connects" , async ( ) => {
@@ -65,7 +75,7 @@ describe("infra v2 integration test", () => {
6575 const connection = await firebolt . connect ( systemEngineConnectionParams ) ;
6676
6777 const engine_name = process . env . FIREBOLT_ENGINE_NAME as string ;
68- await connection . execute ( `USE ENGINE ${ engine_name } ` ) ;
78+ await connection . execute ( `USE ENGINE " ${ engine_name } " ` ) ;
6979
7080 const statement = await connection . execute ( "SELECT 1" ) ;
7181 const { data, meta } = await statement . fetchResult ( ) ;
@@ -75,8 +85,8 @@ describe("infra v2 integration test", () => {
7585
7686 it ( "supports use database and use engine" , async ( ) => {
7787 const table_name = "test_use_database" ;
78- const create_table_sql = `create table if not exists ${ table_name } (id text)` ;
79- const insert_sql = `insert into ${ table_name } values ('1')` ;
88+ const create_table_sql = `create table if not exists " ${ table_name } " (id text)` ;
89+ const insert_sql = `insert into " ${ table_name } " values ('1')` ;
8090
8191 const database_name = process . env . FIREBOLT_DATABASE as string ;
8292 const engine_name = process . env . FIREBOLT_ENGINE_NAME as string ;
@@ -89,17 +99,44 @@ describe("infra v2 integration test", () => {
8999 // should not create table when database is not specified
90100 await expect ( connection . execute ( create_table_sql ) ) . rejects . toThrow ( ) ;
91101
92- await connection . execute ( `use database ${ database_name } ` ) ;
102+ await connection . execute ( `use database " ${ database_name } " ` ) ;
93103 await connection . execute ( create_table_sql ) ;
94104
95105 await expect ( connection . execute ( insert_sql ) ) . rejects . toThrow ( ) ;
96106
97- await connection . execute ( `use engine ${ engine_name } ` ) ;
107+ await connection . execute ( `use engine " ${ engine_name } " ` ) ;
98108
99109 await connection . execute ( insert_sql ) ;
100110
101- await connection . execute ( `use engine system` ) ;
111+ await connection . execute ( `use engine " system" ` ) ;
102112
103113 await expect ( connection . execute ( insert_sql ) ) . rejects . toThrow ( ) ;
104114 } ) ;
115+
116+ it ( "can handle mixed case engines and db" , async ( ) => {
117+ const table_name = "test_mixed_case_database" ;
118+ const create_table_sql = `create table if not exists "${ table_name } " (id text)` ;
119+ const insert_sql = `insert into "${ table_name } " values ('1')` ;
120+
121+ const firebolt = Firebolt ( {
122+ apiEndpoint : process . env . FIREBOLT_API_ENDPOINT as string
123+ } ) ;
124+
125+ const connection = await firebolt . connect ( systemEngineConnectionParams ) ;
126+
127+ await connection . execute ( `CREATE DATABASE "${ mixedCaseDBName } "` ) ;
128+ await connection . execute ( `CREATE ENGINE "${ mixedCaseEngineName } "` ) ;
129+
130+ const mixedCaseConnectionParams = {
131+ ...systemEngineConnectionParams ,
132+ database : mixedCaseDBName ,
133+ engineName : mixedCaseEngineName
134+ } ;
135+
136+ const mixedCaseConnection = await firebolt . connect (
137+ mixedCaseConnectionParams
138+ ) ;
139+ await mixedCaseConnection . execute ( create_table_sql ) ;
140+ await mixedCaseConnection . execute ( insert_sql ) ;
141+ } ) ;
105142} ) ;
0 commit comments