Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

task: make setting service handle conflict on insert #9160

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
574 changes: 287 additions & 287 deletions .yarn/releases/yarn-4.5.3.cjs → .yarn/releases/yarn-4.6.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.3.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.3.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"last 1 safari version"
]
},
"packageManager": "yarn@4.5.3",
"packageManager": "yarn@4.6.0",
"dependencies": {
"json-2-csv": "^5.5.5"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,5 @@
"yarn biome format --write --no-errors-on-unmatched"
]
},
"packageManager": "yarn@4.5.3"
"packageManager": "yarn@4.6.0"
}
15 changes: 5 additions & 10 deletions src/lib/db/setting-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export default class SettingStore implements ISettingStore {
});
}

async insertNewRow(name: string, content: any) {
return this.db(TABLE).insert({ name, content });
}

async exists(name: string): Promise<boolean> {
const result = await this.db.raw(
`SELECT EXISTS (SELECT 1 FROM ${TABLE} WHERE name = ?) AS present`,
Expand All @@ -58,13 +54,12 @@ export default class SettingStore implements ISettingStore {
return undefined;
}

// Is actually an upsert
async insert(name: string, content: any): Promise<void> {
const exists = await this.exists(name);
if (exists) {
await this.updateRow(name, content);
} else {
await this.insertNewRow(name, content);
}
await this.db(TABLE)
.insert({ name, content })
.onConflict('name')
.merge();
}

async delete(name: string): Promise<void> {
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion website/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarnPath: .yarn/releases/yarn-4.5.3.cjs
yarnPath: .yarn/releases/yarn-4.6.0.cjs
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
"http-proxy-middleware": "3.0.3",
"express/path-to-regexp": "0.1.12"
},
"packageManager": "yarn@4.5.3"
"packageManager": "yarn@4.6.0"
}
Loading