Properly delete all sets for a given workout.

Commit
e93199b219f8d0951517e63882e4362b7e5af7f7
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
src/MyFitnessTracker/MFTSQLite3Database.class.st
index 71e80679..2604eb46 100644..100644
@@ -60,7 +60,7 @@
60 60
61 61 | connection allRows |
62 62 connection := self defaultConnection open.
63 Removed: allRows := (connection execute: 'SELECT * FROM Muscle_Groups') rows.
63 Added: allRows := (connection execute: 'SELECT * FROM MuscleGroups') rows.
64 64 connection close.
65 65 ^ Array withAll: (allRows collect: [ :row |
66 66 MFTMuscleGroup newFromDictionary: row asDictionary ])
@@ -258,13 +258,12 @@
258 258 ]
259 259
260 260 { #category : #'as yet unclassified' }
261 Removed: MFTSQLite3Database >> deleteSetsForWorkoutId: id [
261 Added: MFTSQLite3Database >> deleteSets: aMFTSetCollection [
262 262
263 Removed: connection
264 Removed: execute: 'DELETE
265 Removed: FROM exercises
266 Removed: WHERE workout_id = ?'
267 Removed: value: id
263 Added: aMFTSetCollection do: [ :set |
264 Added: connection
265 Added: execute: 'DELETE FROM Sets WHERE workout_id = ?'
266 Added: value: set workoutId ]
268 267 ]
269 268
270 269 { #category : #'as yet unclassified' }
@@ -272,7 +271,7 @@
272 271
273 272 connection
274 273 execute: 'DELETE
275 Removed: FROM weights
274 Added: FROM Weights
276 275 WHERE user_id = ?
277 276 AND date = ?
278 277 AND value = ?'
@@ -285,16 +284,15 @@
285 284 { #category : #'as yet unclassified' }
286 285 MFTSQLite3Database >> deleteWorkout: aMFTWorkout [
287 286
288 Removed: connection beginTransaction.
287 Added: self deleteSets: aMFTWorkout sets.
289 288 connection
290 289 execute: 'DELETE
291 Removed: FROM workouts
290 Added: FROM Workouts
292 291 WHERE user_id = ?
293 292 AND date = ?'
294 293 with: {
295 294 user id.
296 Removed: aMFTWorkout date yyyymmdd }.
297 Removed: connection commitTransaction
295 Added: aMFTWorkout date yyyymmdd }
298 296 ]
299 297
300 298 { #category : #'as yet unclassified' }