@@ -6,6 +6,8 @@ import { SQLiteCloudError } from '../src/index'
66import { prepareSql , parseConnectionString } from '../src/drivers/utilities'
77import { getTestingDatabaseName } from './shared'
88
9+ import { expect , describe , it } from '@jest/globals'
10+
911describe ( 'prepareSql' , ( ) => {
1012 it ( 'should replace single ? parameter' , ( ) => {
1113 const sql = prepareSql ( 'SELECT * FROM users WHERE name = ?' , 'John' )
@@ -115,6 +117,38 @@ describe('parseConnectionString', () => {
115117 } )
116118 } )
117119
120+ it ( 'should parse options regardless of case' , ( ) => {
121+ const connectionString1 = 'sqlitecloud://host?apiKey=xxx'
122+ const config1 = parseConnectionString ( connectionString1 )
123+ expect ( config1 ) . toEqual ( {
124+ host : 'host' ,
125+ apiKey : 'xxx'
126+ } )
127+
128+ const connectionString2 = 'sqlitecloud://host?apikey=yyy'
129+ const config2 = parseConnectionString ( connectionString2 )
130+ expect ( config2 ) . toEqual ( {
131+ host : 'host' ,
132+ apiKey : 'yyy'
133+ } )
134+
135+ const connectionString3 = 'sqlitecloud://host?api_key=yyy&no_blob=true'
136+ const config3 = parseConnectionString ( connectionString3 )
137+ expect ( config3 ) . toEqual ( {
138+ host : 'host' ,
139+ apiKey : 'yyy' ,
140+ noBlob : 'true' // only parsing here, validation is later in validateConfiguration
141+ } )
142+
143+ const connectionString4 = 'sqlitecloud://host?api-key=yyy&max-rows=42'
144+ const config4 = parseConnectionString ( connectionString4 )
145+ expect ( config4 ) . toEqual ( {
146+ host : 'host' ,
147+ apiKey : 'yyy' ,
148+ maxRows : '42' // only parsing here, validation is later in validateConfiguration
149+ } )
150+ } )
151+
118152 it ( 'should parse connection string without port' , ( ) => {
119153 const connectionString = 'sqlitecloud://user:password@host'
120154 const config = parseConnectionString ( connectionString )
0 commit comments