Skip to content

Commit bc7ffcc

Browse files
committed
db.d: avoid REPLACE INTO in some cases
Avoid inserting new rows if we don't have to.
1 parent 57ab9ee commit bc7ffcc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/db.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ final class Database
328328
private void set_config_value(string option, string value)
329329
{
330330
enum sql = text(
331-
"REPLACE INTO ", config_table, "(option, value) VALUES(?, ?);"
331+
"INSERT INTO ", config_table, "(option, value) VALUES(?, ?)",
332+
" ON CONFLICT(option) DO UPDATE SET value = excluded.value;"
332333
);
333334
query(sql, [option, value]);
334335

@@ -408,7 +409,7 @@ final class Database
408409
bool filter_search_phrase(SearchFilterType type)(string phrase)
409410
{
410411
enum sql = text(
411-
"REPLACE INTO ",
412+
"INSERT OR IGNORE INTO ",
412413
search_filters_table, "(type, phrase) VALUES(?, ?);"
413414
);
414415
query(sql, [text(cast(uint) type), phrase]);

0 commit comments

Comments
 (0)