Skip to content

Commit

Permalink
Fix catLastUsage SQL insert syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
dragotin committed May 22, 2022
1 parent 7155e85 commit 357fa73
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions database/mysql/migration/23_dbmigrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ CREATE TABLE catItemUsage (
catId INT NOT NULL,
itemId INT NOT NULL,
usageCount INT default 0,
lastUsage lastUsed DATETIME,
lastUsed DATETIME,

PRIMARY KEY(catId, itemId)
);

ALTER TABLE Catalog DROP COLUMN lastUsed;
ALTER TABLE Catalog DROP COLUMN useCounter;
´

2 changes: 1 addition & 1 deletion database/sqlite3/migration/23_dbmigrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CREATE TABLE catItemUsage (
catId INT NOT NULL,
itemId INT NOT NULL,
usageCount INT default 0,
lastUsage lastUsed DATETIME,
lastUsed DATETIME,

PRIMARY KEY(catId, itemId)
);
Expand Down
3 changes: 2 additions & 1 deletion src/katalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ QPair<int, QDateTime> Katalog::recordUsage(int id)
int usage = usageCount(id).first;

if (usage == 0) {
q.prepare("INSERT INTO catItemUsage SET catId=:catId, itemId=:itemId, usageCount=:usage, lastUsed=:timeStamp");
q.prepare("INSERT INTO catItemUsage (catId, itemId, usageCount, lastUsed) VALUES (:catId, :itemId, :usage, :timeStamp)");

} else {
q.prepare("UPDATE catItemUsage SET usageCount=:usage, lastUsed=:timeStamp WHERE catId=:catId AND itemId=:itemId");
}
Expand Down

0 comments on commit 357fa73

Please sign in to comment.