@@ -52,6 +52,7 @@ Given("A new Databend Driver Client", async function () {
5252 assert . fail ( "No connection returned" ) ;
5353 }
5454 this . conn = conn ;
55+ conn . exec ( "set timezone='Asia/Shanghai'" )
5556} ) ;
5657
5758Then ( "Select string {string} should be equal to {string}" , async function ( input , output ) {
@@ -143,7 +144,7 @@ Then("Select types should be expected native types", async function () {
143144 const row = await this . conn . queryRow (
144145 "SELECT to_datetime('2020-01-01 12:34:56.789'), to_datetime('2020-01-02 12:34:56.789')" ,
145146 ) ;
146- assert . deepEqual ( row . values ( ) , [ new Date ( "2020-01-01T12 :34:56.789Z" ) , new Date ( "2020-01-02T12 :34:56.789Z" ) ] ) ;
147+ assert . deepEqual ( row . values ( ) , [ new Date ( "2020-01-01T04 :34:56.789Z" ) , new Date ( "2020-01-02T04 :34:56.789Z" ) ] ) ;
147148 }
148149
149150 // VARCHAR
@@ -166,8 +167,10 @@ Then("Select types should be expected native types", async function () {
166167
167168 // TUPLE
168169 {
169- const row = await this . conn . queryRow ( `SELECT (10, '20', to_datetime('2024-04-16 12:34:56.789'))` ) ;
170- assert . deepEqual ( row . values ( ) , [ [ 10 , "20" , new Date ( "2024-04-16T12:34:56.789Z" ) ] ] ) ;
170+ const row = await this . conn . queryRow (
171+ `SELECT (10, '20', to_datetime('2024-04-16 12:34:56.789'))` ,
172+ ) ;
173+ assert . deepEqual ( row . values ( ) , [ [ 10 , "20" , new Date ( "2024-04-16T04:34:56.789Z" ) ] ] ) ;
171174 }
172175
173176 // MAP
@@ -220,7 +223,7 @@ Then("Select types should be expected native types", async function () {
220223 // TimestampTz
221224 if ( ! ( DRIVER_VERSION > [ 0 , 30 , 3 ] && DB_VERSION >= [ 1 , 2 , 836 ] ) ) {
222225 const row = await this . conn . queryRow ( `SELECT to_datetime_tz('2024-04-16 12:34:56.789 +0800'))` ) ;
223- assert . deepEqual ( row . values ( ) , [ "2024-04-16T12 :34:56.789 +0800" ] ) ;
226+ assert . deepEqual ( row . values ( ) , [ new Date ( "2024-04-16 04 :34:56.789Z" ) ] ) ;
224227 }
225228} ) ;
226229
@@ -310,9 +313,9 @@ Then("Insert and Select should be equal", async function () {
310313 ret . push ( row . values ( ) ) ;
311314 }
312315 const expected = [
313- [ - 1 , 1 , 1.0 , "'" , null , new Date ( "2011-03-06" ) , new Date ( "2011-03-06T06 :20:00Z" ) ] ,
314- [ - 2 , 2 , 2.0 , '"' , "" , new Date ( "2012-05-31" ) , new Date ( "2012-05-31T11 :20:00Z" ) ] ,
315- [ - 3 , 3 , 3.0 , "\\" , "NULL" , new Date ( "2016-04-04" ) , new Date ( "2016-04-04T11 :30:00Z" ) ] ,
316+ [ - 1 , 1 , 1.0 , "'" , null , new Date ( "2011-03-06" ) , new Date ( "2011-03-05T22 :20:00Z" ) ] ,
317+ [ - 2 , 2 , 2.0 , '"' , "" , new Date ( "2012-05-31" ) , new Date ( "2012-05-31T03 :20:00Z" ) ] ,
318+ [ - 3 , 3 , 3.0 , "\\" , "NULL" , new Date ( "2016-04-04" ) , new Date ( "2016-04-04T03 :30:00Z" ) ] ,
316319 ] ;
317320 assert . deepEqual ( ret , expected ) ;
318321} ) ;
@@ -353,16 +356,16 @@ Then("Load file with Stage and Select should be equal", async function () {
353356 ret . push ( row . values ( ) ) ;
354357 }
355358 const expected = [
356- [ - 1 , 1 , 1.0 , "'" , null , new Date ( "2011-03-06" ) , new Date ( "2011-03-06T06 :20:00Z" ) ] ,
357- [ - 2 , 2 , 2.0 , '"' , null , new Date ( "2012-05-31" ) , new Date ( "2012-05-31T11 :20:00Z" ) ] ,
358- [ - 3 , 3 , 3.0 , "\\" , "NULL" , new Date ( "2016-04-04" ) , new Date ( "2016-04-04T11 :30:00Z" ) ] ,
359+ [ - 1 , 1 , 1.0 , "'" , null , new Date ( "2011-03-06" ) , new Date ( "2011-03-05T22 :20:00Z" ) ] ,
360+ [ - 2 , 2 , 2.0 , '"' , null , new Date ( "2012-05-31" ) , new Date ( "2012-05-31T03 :20:00Z" ) ] ,
361+ [ - 3 , 3 , 3.0 , "\\" , "NULL" , new Date ( "2016-04-04" ) , new Date ( "2016-04-04T03 :30:00Z" ) ] ,
359362 ] ;
360363 assert . deepEqual ( ret , expected ) ;
361364} ) ;
362365
363366Then ( "Load file with Streaming and Select should be equal" , async function ( ) {
364367 const progress = await this . conn . loadFile (
365- `INSERT INTO test VALUES from @_databend_load file_format=(type=csv)` ,
368+ `INSERT /*+SET_VAR(timezone='Asia/Shanghai')*/ INTO test VALUES from @_databend_load file_format=(type=csv)` ,
366369 "tests/data/test.csv" ,
367370 "streaming" ,
368371 ) ;
@@ -374,9 +377,9 @@ Then("Load file with Streaming and Select should be equal", async function () {
374377 ret . push ( row . values ( ) ) ;
375378 }
376379 const expected = [
377- [ - 1 , 1 , 1.0 , "'" , null , new Date ( "2011-03-06" ) , new Date ( "2011-03-06T06 :20:00Z" ) ] ,
378- [ - 2 , 2 , 2.0 , '"' , null , new Date ( "2012-05-31" ) , new Date ( "2012-05-31T11 :20:00Z" ) ] ,
379- [ - 3 , 3 , 3.0 , "\\" , "NULL" , new Date ( "2016-04-04" ) , new Date ( "2016-04-04T11 :30:00Z" ) ] ,
380+ [ - 1 , 1 , 1.0 , "'" , null , new Date ( "2011-03-06" ) , new Date ( "2011-03-05T22 :20:00Z" ) ] ,
381+ [ - 2 , 2 , 2.0 , '"' , null , new Date ( "2012-05-31" ) , new Date ( "2012-05-31T03 :20:00Z" ) ] ,
382+ [ - 3 , 3 , 3.0 , "\\" , "NULL" , new Date ( "2016-04-04" ) , new Date ( "2016-04-04T03 :30:00Z" ) ] ,
380383 ] ;
381384 assert . deepEqual ( ret , expected ) ;
382385} ) ;
0 commit comments