1- const { expect } = require ( 'chai' ) ;
2- const sinon = require ( 'sinon' ) ;
3- const config = require ( './utils/config' ) ;
4- const logger = require ( './utils/logger' ) ( config . logger ) ;
5- const { DBSQLClient } = require ( '../../lib' ) ;
6- const ArrowResultHandler = require ( '../../lib/result/ArrowResultHandler' ) . default ;
7- const ArrowResultConverter = require ( '../../lib/result/ArrowResultConverter' ) . default ;
8- const ResultSlicer = require ( '../../lib/result/ResultSlicer' ) . default ;
1+ import { expect } from 'chai' ;
2+ import sinon from 'sinon' ;
3+ import { DBSQLClient } from '../../lib' ;
4+ import { ClientConfig } from '../../lib/contracts/IClientContext' ;
5+ import IDBSQLSession from '../../lib/contracts/IDBSQLSession' ;
6+ import ArrowResultHandler from '../../lib/result/ArrowResultHandler' ;
7+ import ArrowResultConverter from '../../lib/result/ArrowResultConverter' ;
8+ import ResultSlicer from '../../lib/result/ResultSlicer' ;
9+
10+ import config from './utils/config' ;
911
1012const fixtures = require ( '../fixtures/compatibility' ) ;
1113const { expected : expectedColumn } = require ( '../fixtures/compatibility/column' ) ;
1214const { expected : expectedArrow } = require ( '../fixtures/compatibility/arrow' ) ;
1315const { expected : expectedArrowNativeTypes } = require ( '../fixtures/compatibility/arrow_native_types' ) ;
16+
1417const { fixArrowResult } = fixtures ;
1518
16- async function openSession ( customConfig ) {
19+ async function openSession ( customConfig : Partial < ClientConfig > = { } ) {
1720 const client = new DBSQLClient ( ) ;
1821
1922 const clientConfig = client . getConfig ( ) ;
@@ -29,23 +32,23 @@ async function openSession(customConfig) {
2932 } ) ;
3033
3134 return connection . openSession ( {
32- initialCatalog : config . database [ 0 ] ,
33- initialSchema : config . database [ 1 ] ,
35+ initialCatalog : config . catalog ,
36+ initialSchema : config . schema ,
3437 } ) ;
3538}
3639
37- async function execute ( session , statement ) {
40+ async function execute ( session : IDBSQLSession , statement : string ) {
3841 const operation = await session . executeStatement ( statement ) ;
3942 const result = await operation . fetchAll ( ) ;
4043 await operation . close ( ) ;
4144 return result ;
4245}
4346
44- async function deleteTable ( session , tableName ) {
47+ async function deleteTable ( session : IDBSQLSession , tableName : string ) {
4548 await execute ( session , `DROP TABLE IF EXISTS ${ tableName } ` ) ;
4649}
4750
48- async function initializeTable ( session , tableName ) {
51+ async function initializeTable ( session : IDBSQLSession , tableName : string ) {
4952 await deleteTable ( session , tableName ) ;
5053
5154 const createTable = fixtures . createTableSql . replace ( / \$ \{ t a b l e _ n a m e \} / g, tableName ) ;
@@ -58,15 +61,15 @@ async function initializeTable(session, tableName) {
5861describe ( 'Arrow support' , ( ) => {
5962 const tableName = `dbsql_nodejs_sdk_e2e_arrow_${ config . tableSuffix } ` ;
6063
61- function createTest ( testBody , customConfig ) {
64+ function createTest (
65+ testBody : ( session : IDBSQLSession ) => void | Promise < void > ,
66+ customConfig : Partial < ClientConfig > = { } ,
67+ ) {
6268 return async ( ) => {
6369 const session = await openSession ( customConfig ) ;
6470 try {
6571 await initializeTable ( session , tableName ) ;
6672 await testBody ( session ) ;
67- } catch ( error ) {
68- logger ( error ) ;
69- throw error ;
7073 } finally {
7174 await deleteTable ( session , tableName ) ;
7275 await session . close ( ) ;
@@ -82,6 +85,7 @@ describe('Arrow support', () => {
8285 const result = await operation . fetchAll ( ) ;
8386 expect ( result ) . to . deep . equal ( expectedColumn ) ;
8487
88+ // @ts -expect-error TS2339: Property getResultHandler does not exist on type IOperation
8589 const resultHandler = await operation . getResultHandler ( ) ;
8690 expect ( resultHandler ) . to . be . instanceof ( ResultSlicer ) ;
8791 expect ( resultHandler . source ) . to . be . not . instanceof ( ArrowResultConverter ) ;
@@ -103,6 +107,7 @@ describe('Arrow support', () => {
103107 const result = await operation . fetchAll ( ) ;
104108 expect ( fixArrowResult ( result ) ) . to . deep . equal ( expectedArrow ) ;
105109
110+ // @ts -expect-error TS2339: Property getResultHandler does not exist on type IOperation
106111 const resultHandler = await operation . getResultHandler ( ) ;
107112 expect ( resultHandler ) . to . be . instanceof ( ResultSlicer ) ;
108113 expect ( resultHandler . source ) . to . be . instanceof ( ArrowResultConverter ) ;
@@ -126,6 +131,7 @@ describe('Arrow support', () => {
126131 const result = await operation . fetchAll ( ) ;
127132 expect ( fixArrowResult ( result ) ) . to . deep . equal ( expectedArrowNativeTypes ) ;
128133
134+ // @ts -expect-error TS2339: Property getResultHandler does not exist on type IOperation
129135 const resultHandler = await operation . getResultHandler ( ) ;
130136 expect ( resultHandler ) . to . be . instanceof ( ResultSlicer ) ;
131137 expect ( resultHandler . source ) . to . be . instanceof ( ArrowResultConverter ) ;
@@ -155,16 +161,20 @@ describe('Arrow support', () => {
155161 ` ) ;
156162
157163 // We use some internals here to check that server returned response with multiple batches
164+ // @ts -expect-error TS2339: Property getResultHandler does not exist on type IOperation
158165 const resultHandler = await operation . getResultHandler ( ) ;
159166 expect ( resultHandler ) . to . be . instanceof ( ResultSlicer ) ;
160167 expect ( resultHandler . source ) . to . be . instanceof ( ArrowResultConverter ) ;
161168 expect ( resultHandler . source . source ) . to . be . instanceof ( ArrowResultHandler ) ;
162169
170+ // @ts -expect-error TS2339: Property _data does not exist on type IOperation
163171 sinon . spy ( operation . _data , 'fetchNext' ) ;
164172
165173 const result = await resultHandler . fetchNext ( { limit : rowsCount } ) ;
166174
175+ // @ts -expect-error TS2339: Property _data does not exist on type IOperation
167176 expect ( operation . _data . fetchNext . callCount ) . to . be . eq ( 1 ) ;
177+ // @ts -expect-error TS2339: Property _data does not exist on type IOperation
168178 const rawData = await operation . _data . fetchNext . firstCall . returnValue ;
169179 // We don't know exact count of batches returned, it depends on server's configuration,
170180 // but with much enough rows there should be more than one result batch
@@ -181,6 +191,7 @@ describe('Arrow support', () => {
181191 const result = await operation . fetchAll ( ) ;
182192 expect ( fixArrowResult ( result ) ) . to . deep . equal ( expectedArrow ) ;
183193
194+ // @ts -expect-error TS2339: Property getResultHandler does not exist on type IOperation
184195 const resultHandler = await operation . getResultHandler ( ) ;
185196 expect ( resultHandler ) . to . be . instanceof ( ResultSlicer ) ;
186197 expect ( resultHandler . source ) . to . be . instanceof ( ArrowResultConverter ) ;
0 commit comments