Skip to content

Commit ba51eca

Browse files
committed
Lint changes
1 parent c5fb8eb commit ba51eca

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

src/builder.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,9 @@ export class QueryBuilder<GenericResultWrapper, IsAsync extends boolean = true>
122122
limit: 1,
123123
}
124124
if (params.subQueryPlaceholders) {
125-
selectParamsForCount.subQueryPlaceholders = params.subQueryPlaceholders;
125+
selectParamsForCount.subQueryPlaceholders = params.subQueryPlaceholders
126126
}
127127

128-
129128
const mainSql = this._select({ ...params, limit: 1 } as SelectAll, queryArgs)
130129
const countSql = this._select(selectParamsForCount, countQueryArgs)
131130

@@ -162,7 +161,7 @@ export class QueryBuilder<GenericResultWrapper, IsAsync extends boolean = true>
162161
lazy: undefined,
163162
}
164163
if (params.subQueryPlaceholders) {
165-
countQueryParams.subQueryPlaceholders = params.subQueryPlaceholders;
164+
countQueryParams.subQueryPlaceholders = params.subQueryPlaceholders
166165
}
167166

168167
const mainSql = this._select(mainQueryParams, queryArgs)
@@ -508,7 +507,9 @@ export class QueryBuilder<GenericResultWrapper, IsAsync extends boolean = true>
508507
for (const part of parts) {
509508
if (part === '?') {
510509
if (primitiveParamIndex >= primitiveParams.length) {
511-
throw new Error('SQL generation error: Not enough primitive parameters for "?" placeholders in WHERE clause.')
510+
throw new Error(
511+
'SQL generation error: Not enough primitive parameters for "?" placeholders in WHERE clause.'
512+
)
512513
}
513514
context.queryArgs.push(primitiveParams[primitiveParamIndex++])
514515
builtCondition += '?'
@@ -531,8 +532,11 @@ export class QueryBuilder<GenericResultWrapper, IsAsync extends boolean = true>
531532
processedConditions.push(`(${builtCondition})`)
532533
}
533534

534-
if (primitiveParamIndex < primitiveParams.length && primitiveParams.length > 0) { // Check primitiveParams.length to avoid error if no params were expected
535-
throw new Error('SQL generation error: Too many primitive parameters provided for "?" placeholders in WHERE clause.')
535+
if (primitiveParamIndex < primitiveParams.length && primitiveParams.length > 0) {
536+
// Check primitiveParams.length to avoid error if no params were expected
537+
throw new Error(
538+
'SQL generation error: Too many primitive parameters provided for "?" placeholders in WHERE clause.'
539+
)
536540
}
537541

538542
if (processedConditions.length === 0) return ''
@@ -602,7 +606,7 @@ export class QueryBuilder<GenericResultWrapper, IsAsync extends boolean = true>
602606
return ` HAVING ${whereEquivalentString.substring(' WHERE '.length)}`
603607
}
604608
// If _where returned empty (e.g., no conditions) or an unexpected format,
605-
курорт // return an empty string for HAVING as well.
609+
курорт // return an empty string for HAVING as well.
606610
return ''
607611
}
608612

tests/unit/select.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,16 +1019,10 @@ describe('Subqueries in SELECT statements', () => {
10191019
})
10201020

10211021
it('column = (subquery) - scalar subquery', () => {
1022-
const sub = new QuerybuilderTest()
1023-
.select('settings')
1024-
.fields('value')
1025-
.where('key = ?', ['default_role'])
1026-
.limit(1) // limit is important for scalar subquery
1022+
const sub = new QuerybuilderTest().select('settings').fields('value').where('key = ?', ['default_role']).limit(1) // limit is important for scalar subquery
10271023
const q = new QuerybuilderTest().select('users').where('role = ?', [sub.getOptions()]).getQueryAll()
10281024

1029-
expect(q.query).toEqual(
1030-
'SELECT * FROM users WHERE (role = (SELECT value FROM settings WHERE (key = ?) LIMIT 1))'
1031-
)
1025+
expect(q.query).toEqual('SELECT * FROM users WHERE (role = (SELECT value FROM settings WHERE (key = ?) LIMIT 1))')
10321026
expect(q.arguments).toEqual(['default_role'])
10331027
})
10341028

@@ -1072,9 +1066,9 @@ describe('Subqueries in SELECT statements', () => {
10721066
// HAVING (id IN (SELECT customer_id FROM orders GROUP BY customer_id HAVING (SUM(total) > ?)))
10731067
expect(q.query).toEqual(
10741068
'SELECT id, name, COUNT(orders.id) as order_count FROM customers' +
1075-
' JOIN orders ON customers.id = orders.customer_id' +
1076-
' GROUP BY customers.id, customers.name' +
1077-
' HAVING (id IN (SELECT customer_id FROM orders GROUP BY customer_id HAVING (SUM(total) > ?)))'
1069+
' JOIN orders ON customers.id = orders.customer_id' +
1070+
' GROUP BY customers.id, customers.name' +
1071+
' HAVING (id IN (SELECT customer_id FROM orders GROUP BY customer_id HAVING (SUM(total) > ?)))'
10781072
)
10791073
expect(q.arguments).toEqual([1000])
10801074
})

0 commit comments

Comments
 (0)