@@ -130,12 +130,22 @@ it('Should work with persistent database', async () => {
130
130
} ) ;
131
131
const columns = getColumns ( ) ;
132
132
const data = await streamToArray ( getData ( ) ) ;
133
+ const db = new duckdb . Database ( testFile ) ;
134
+ const result = await getQueryResults (
135
+ db ,
136
+ 'select * from "users" where age < 200 order by id desc'
137
+ ) ;
133
138
// Assert
134
139
expect ( columns . length ) . toBe ( 4 ) ;
135
140
expect ( columns ) . toContainEqual ( { name : 'id' , type : 'number' } ) ;
136
141
expect ( columns ) . toContainEqual ( { name : 'name' , type : 'string' } ) ;
137
142
expect ( columns ) . toContainEqual ( { name : 'age' , type : 'number' } ) ;
138
143
expect ( columns ) . toContainEqual ( { name : 'enabled' , type : 'boolean' } ) ;
144
+ expect ( data . length ) . toEqual ( result . length ) ;
145
+ for ( let i = 0 ; i < data . length ; i ++ ) {
146
+ expect ( data [ i ] ) . toEqual ( result [ i ] ) ;
147
+ }
148
+ expect ( data ) . toEqual ( result ) ;
139
149
expect ( data . length ) . toBe ( 2 ) ;
140
150
expect ( data [ 0 ] ) . toEqual ( {
141
151
id : 2 ,
@@ -146,6 +156,47 @@ it('Should work with persistent database', async () => {
146
156
expect ( data [ 1 ] ) . toEqual ( { id : 1 , name : 'freda' , age : 18 , enabled : true } ) ;
147
157
} ) ;
148
158
159
+ it ( 'Should return correct data chunk' , async ( ) => {
160
+ // Arrange
161
+ const dataSource = new DuckDBDataSource ( null , 'duckdb' , [
162
+ {
163
+ name : 'mocked-profile' ,
164
+ type : 'duck' ,
165
+ connection : {
166
+ 'persistent-path' : testFile ,
167
+ } ,
168
+ allow : '*' ,
169
+ } ,
170
+ ] ) ;
171
+ await dataSource . activate ( ) ;
172
+ const bindParams = new Map < string , any > ( ) ;
173
+ // Act
174
+ const { getColumns, getData } = await dataSource . execute ( {
175
+ statement : 'select * from "users" order by id desc' ,
176
+ bindParams,
177
+ operations : { } as any ,
178
+ profileName : 'mocked-profile' ,
179
+ } ) ;
180
+ const columns = getColumns ( ) ;
181
+ const data = await streamToArray ( getData ( ) ) ;
182
+ const db = new duckdb . Database ( testFile ) ;
183
+ const result = await getQueryResults (
184
+ db ,
185
+ 'select * from "users" order by id desc'
186
+ ) ;
187
+ // Assert
188
+ expect ( columns . length ) . toBe ( 4 ) ;
189
+ expect ( columns ) . toContainEqual ( { name : 'id' , type : 'number' } ) ;
190
+ expect ( columns ) . toContainEqual ( { name : 'name' , type : 'string' } ) ;
191
+ expect ( columns ) . toContainEqual ( { name : 'age' , type : 'number' } ) ;
192
+ expect ( columns ) . toContainEqual ( { name : 'enabled' , type : 'boolean' } ) ;
193
+ expect ( data . length ) . toEqual ( result . length ) ;
194
+ for ( let i = 0 ; i < data . length ; i ++ ) {
195
+ expect ( data [ i ] ) . toEqual ( result [ i ] ) ;
196
+ }
197
+ expect ( data . length ) . toBe ( 2000 + 3 ) ;
198
+ } ) ;
199
+
149
200
it ( 'Should send correct data with chunks' , async ( ) => {
150
201
// Arrange
151
202
const dataSource = new DuckDBDataSource ( null , 'duckdb' , [
0 commit comments