Skip to content

Commit cf65974

Browse files
Copilothotlong
andcommitted
Fix SQL driver count method to handle filter arrays correctly
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 478b7c6 commit cf65974

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/drivers/sql/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ export class SqlDriver implements Driver {
261261
}
262262

263263
async count(objectName: string, filters: any, options?: any): Promise<number> {
264-
// Normalize the query to support both QueryAST and legacy formats
265-
const normalizedQuery = this.normalizeQuery(filters);
266264
const builder = this.getBuilder(objectName, options);
267265

268-
let actualFilters = normalizedQuery;
269-
// If filters is a query object with a 'filters' property, use that
270-
if (normalizedQuery && !Array.isArray(normalizedQuery) && normalizedQuery.filters) {
271-
actualFilters = normalizedQuery.filters;
266+
// Handle both filter arrays and query objects
267+
let actualFilters = filters;
268+
if (filters && !Array.isArray(filters)) {
269+
// It's a query object, normalize it and extract filters
270+
const normalizedQuery = this.normalizeQuery(filters);
271+
actualFilters = normalizedQuery.filters || filters;
272272
}
273273

274274
if (actualFilters) {

0 commit comments

Comments
 (0)