Skip to content

Commit 37f216f

Browse files
committed
refactor(state): express avatar presence through Kysely
1 parent 569b767 commit 37f216f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎src/state/user-profiles-internal.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { DatabaseSync } from "node:sqlite";
2-
import { sql, type SelectQueryBuilder } from "kysely";
2+
import { expressionBuilder, type SelectQueryBuilder } from "kysely";
33
import { executeSqliteQueryTakeFirstSync, getNodeSqliteKysely } from "../infra/kysely-sync.js";
44
import {
55
openOpenClawStateDatabase,
@@ -18,9 +18,11 @@ import {
1818
export type UserProfileRow = UserProfilesDatabase["user_profiles"];
1919

2020
// Selection metadata is immutable and carries no database handle or profile state.
21-
export const userProfileAvatarPresence = sql<number>`CASE WHEN avatar IS NULL THEN 0 ELSE 1 END`.as(
22-
"has_avatar",
23-
);
21+
export const userProfileAvatarPresence = expressionBuilder<UserProfilesDatabase, "user_profiles">()(
22+
"avatar",
23+
"is not",
24+
null,
25+
).as("has_avatar");
2426
type UserProfileAvatar = {
2527
bytes: Uint8Array;
2628
mime: UserProfileAvatarMime;

0 commit comments

Comments
 (0)