Avoid closing the SQLite3 database connection inside instance methods...

Commit
bef2fa2a386e07b57f66255aa987c1d6de0456f5
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
src/MyFitnessTracker/MFTSQLite3Database.class.st
index 4215ab9e..5b129ec7 100644..100644
@@ -183,17 +183,37 @@
183 183 ]
184 184
185 185 { #category : #'as yet unclassified' }
186 Added: MFTSQLite3Database >> insertWeight: aMFTWeight [
187 Added:
188 Added: connection
189 Added: execute: 'INSERT INTO weights(user_id, date, value)
190 Added: VALUES( ?, ?, ?)'
191 Added: with: {
192 Added: 1.
193 Added: aMFTWeight date.
194 Added: aMFTWeight value }
195 Added: ]
196 Added:
197 Added: { #category : #'as yet unclassified' }
198 Added: MFTSQLite3Database >> insertWorkout: aMFTWorkout [
199 Added:
200 Added: connection
201 Added: execute:
202 Added: 'INSERT INTO workouts(user_id, date, primary_muscle, secondary_muscles)
203 Added: VALUES( ?, ?, ?, ?)'
204 Added: with: { 1. 'foo'. 'Primary muscle'. 'Test' }
205 Added: ]
206 Added:
207 Added: { #category : #'as yet unclassified' }
186 208 MFTSQLite3Database >> login: aMFTUser atDateAndTime: aDateAndTime [
187 209
188 210 connection
189 Removed: open;
190 211 execute: 'UPDATE users
191 212 SET last_login_date_time = ?
192 213 WHERE username = ?'
193 214 with: {
194 215 aDateAndTime.
195 Removed: aMFTUser username };
196 Removed: close
216 Added: aMFTUser username }
197 217 ]
198 218
199 219 { #category : #'as yet unclassified' }
@@ -226,7 +246,7 @@
226 246 FROM weights
227 247 INNER JOIN users ON weights.user_id = users.id
228 248 WHERE users.username = ?'
229 Removed: value: 'foobar123') rows collect: [ :each |
249 Added: value: aMFTUser username) rows collect: [ :each |
230 250 MFTWeight newFromDictionary: each asDictionary ]
231 251 ]
232 252
@@ -239,6 +259,20 @@
239 259 FROM workouts
240 260 INNER JOIN users ON workouts.user_id = users.id
241 261 WHERE users.username = ?'
242 Removed: value: 'foobar123') rows collect: [ :each |
262 Added: value: aMFTUser username) rows collect: [ :each |
243 263 MFTWorkout newFromDictionary: each asDictionary ]
264 Added: ]
265 Added:
266 Added: { #category : #'as yet unclassified' }
267 Added: MFTSQLite3Database >> updateWeight: aMFTWeight for: aMFTUser [
268 Added:
269 Added: connection
270 Added: execute: 'UPDATE weights
271 Added: SET date = ?,
272 Added: value = ?
273 Added: WHERE user_id'
274 Added: with: {
275 Added: aMFTWeight date yyyymmdd.
276 Added: aMFTWeight value.
277 Added: aMFTUser username }
244 278 ]