File tree Expand file tree Collapse file tree 1 file changed +21
-6
lines changed
Expand file tree Collapse file tree 1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -329,16 +329,31 @@ export abstract class SqliteLikeBaseDriver extends CommonSQLImplement {
329329 const orderPart =
330330 options . orderBy && options . orderBy . length > 0
331331 ? options . orderBy
332- . map ( ( r ) => `${ this . escapeId ( r . columnName ) } ${ r . by } ` )
333- . join ( ", " )
332+ . map ( ( r ) => `${ this . escapeId ( r . columnName ) } ${ r . by } ` )
333+ . join ( ", " )
334334 : "" ;
335335
336- const sql = `SELECT ${ injectRowIdColumn ? "rowid, " : "" } * FROM ${ this . escapeId ( schemaName ) } .${ this . escapeId ( tableName ) } ${
337- whereRaw ? ` WHERE ${ whereRaw } ` : ""
338- } ${ orderPart ? ` ORDER BY ${ orderPart } ` : "" } LIMIT ${ escapeSqlValue ( options . limit ) } OFFSET ${ escapeSqlValue ( options . offset ) } ;`;
336+ const sql = `SELECT ${ injectRowIdColumn ? "rowid, " : "" } * FROM ${ this . escapeId ( schemaName ) } .${ this . escapeId ( tableName ) } ${ whereRaw ? ` WHERE ${ whereRaw } ` : ""
337+ } ${ orderPart ? ` ORDER BY ${ orderPart } ` : "" } LIMIT ${ escapeSqlValue ( options . limit ) } OFFSET ${ escapeSqlValue ( options . offset ) } ;`;
338+
339+ let data = await this . query ( sql ) ;
340+
341+ // If data does not have any header, we will inject the header from schema
342+ if ( data . headers . length === 0 && data . rows . length === 0 ) {
343+ data = {
344+ ...data ,
345+ headers : schema . columns . map ( ( col ) => {
346+ return {
347+ name : col . name ,
348+ originalType : col . type ,
349+ displayName : col . name ,
350+ } ;
351+ } ) ,
352+ } ;
353+ }
339354
340355 return {
341- data : await this . query ( sql ) ,
356+ data,
342357 schema,
343358 } ;
344359 }
You can’t perform that action at this time.
0 commit comments