Skip to content

Commit 901eb6e

Browse files
ci: apply automated fixes
1 parent 5812d9d commit 901eb6e

4 files changed

Lines changed: 34 additions & 35 deletions

File tree

packages/db/src/query/builder/functions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,7 @@ export function caseWhen<
422422
C1 extends ExpressionLike,
423423
V1 extends CaseWhenValue,
424424
D extends CaseWhenValue,
425-
>(
426-
condition1: C1,
427-
value1: V1,
428-
defaultValue: D,
429-
): CaseWhenResult<[V1, D], true>
425+
>(condition1: C1, value1: V1, defaultValue: D): CaseWhenResult<[V1, D], true>
430426
export function caseWhen<
431427
C1 extends ExpressionLike,
432428
V1 extends CaseWhenValue,

packages/db/src/query/compiler/group-by.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,7 @@ function compileGroupedSelectObject(
794794
const splitIndex = rest.lastIndexOf(`__`)
795795
const pathStr = splitIndex >= 0 ? rest.slice(0, splitIndex) : rest
796796
const isRefExpr =
797-
typeof value === `object` &&
798-
`type` in value &&
799-
value.type === `ref`
797+
typeof value === `object` && `type` in value && value.type === `ref`
800798
const expression = isRefExpr
801799
? (value as BasicExpression)
802800
: (new PropRef(pathStr.split(`.`)) as BasicExpression)

packages/db/src/query/compiler/select.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ export function processSelect(
149149
return pipeline.pipe(map((row) => processRow(row, ops)))
150150
}
151151

152-
function compileSelectObject(obj: Record<string, any>): (row: NamespacedRow) => any {
152+
function compileSelectObject(
153+
obj: Record<string, any>,
154+
): (row: NamespacedRow) => any {
153155
const ops: Array<SelectOp> = []
154156
addFromObject([], obj, ops)
155157

packages/db/tests/query/case-when.test.ts

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ describe(`caseWhen`, () => {
276276

277277
await query.preload()
278278

279-
expect(query.toArray.map((row) => stripVirtualPropsAndSymbols(row))).toEqual(
280-
[{ status: `active`, total: 2 }],
281-
)
279+
expect(
280+
query.toArray.map((row) => stripVirtualPropsAndSymbols(row)),
281+
).toEqual([{ status: `active`, total: 2 }])
282282
})
283283

284284
test(`selects conditional projection objects with aggregates in grouped queries`, async () => {
@@ -336,7 +336,11 @@ describe(`caseWhen`, () => {
336336
const query = createLiveQueryCollection((q) =>
337337
q
338338
.from({ user: users })
339-
.join({ post: posts }, ({ user, post }) => eq(user.id, post.userId), `left`)
339+
.join(
340+
{ post: posts },
341+
({ user, post }) => eq(user.id, post.userId),
342+
`left`,
343+
)
340344
.select(({ user, post }) => ({
341345
id: user.id,
342346
title: caseWhen(post, post.title, `none`),
@@ -366,10 +370,7 @@ describe(`caseWhen`, () => {
366370
.join(
367371
{ post: posts },
368372
({ user, post }) =>
369-
eq(
370-
caseWhen(eq(user.active, true), user.id, -1),
371-
post.userId,
372-
),
373+
eq(caseWhen(eq(user.active, true), user.id, -1), post.userId),
373374
`inner`,
374375
)
375376
.select(({ user, post }) => ({
@@ -413,13 +414,11 @@ describe(`caseWhen`, () => {
413414

414415
expect(() =>
415416
createLiveQueryCollection((q) =>
416-
q
417-
.from({ user: users })
418-
.orderBy(({ user }) =>
419-
caseWhen(gt(user.age, 18), {
420-
id: user.id,
421-
}),
422-
),
417+
q.from({ user: users }).orderBy(({ user }) =>
418+
caseWhen(gt(user.age, 18), {
419+
id: user.id,
420+
}),
421+
),
423422
),
424423
).toThrow(/caseWhen\(\) cannot be used inside expressions/)
425424
})
@@ -616,17 +615,21 @@ describe(`caseWhen`, () => {
616615
.from({ user: users })
617616
.select(({ user }) => ({
618617
id: user.id,
619-
fallbackProfile: caseWhen(gt(user.age, 100), { kind: `ancient` }, {
620-
id: user.id,
621-
name: user.name,
622-
postTitles: toArray(
623-
q
624-
.from({ post: posts })
625-
.where(({ post }) => eq(post.userId, user.id))
626-
.orderBy(({ post }) => post.id)
627-
.select(({ post }) => post.title),
628-
),
629-
}),
618+
fallbackProfile: caseWhen(
619+
gt(user.age, 100),
620+
{ kind: `ancient` },
621+
{
622+
id: user.id,
623+
name: user.name,
624+
postTitles: toArray(
625+
q
626+
.from({ post: posts })
627+
.where(({ post }) => eq(post.userId, user.id))
628+
.orderBy(({ post }) => post.id)
629+
.select(({ post }) => post.title),
630+
),
631+
},
632+
),
630633
}))
631634
.orderBy(({ user }) => user.id),
632635
)

0 commit comments

Comments
 (0)