commit e9d268bed2ab369cfc0974f8a0b07bb18d8b466b
parent a83f45245da5986287c5e028363837ab44bbf42d
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Sun, 31 Mar 2024 17:42:48 -0700
Do some checks in time setting SQL statements
Check that the break was started before setting break end time, and
check that the time was started before ending the time. These checks
are just in the WHERE expression, so no error is reported if these
checks prevent bad behavior at the moment.
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/stmt.c b/stmt.c
@@ -95,12 +95,14 @@ struct sqlbox_pstmt pstmts[] = {
[StmtEndBreakTime] = { .stmt =
"UPDATE times SET endbreak = ?\n"
" WHERE userid IS ? AND entry IS\n"
- " (SELECT (entry) FROM current_entries WHERE userid IS ?)"
+ " (SELECT (entry) FROM current_entries WHERE userid IS ?) AND\n"
+ " startbreak NOTNULL"
},
[StmtEndTime] = { .stmt =
"UPDATE times SET end = ?\n"
" WHERE userid IS ? AND entry IS\n"
- " (SELECT (entry) FROM current_entries WHERE userid IS ?)"
+ " (SELECT (entry) FROM current_entries WHERE userid IS ?) AND\n"
+ " start NOTNULL"
},
[StmtGetTimes] = { .stmt =
"SELECT period, entry, start, startbreak, endbreak, end FROM times\n"