Commit b83d16da authored by Dave Griffiths's avatar Dave Griffiths
Browse files

sql fixes

parent e1125b2f
......@@ -119,7 +119,7 @@
;; insert an entire entity
(define (insert-entity db table entity-type user ktvlist)
(insert-entity-with-wholesale db table entity-type (get-unique user) "1" "0" ktvlist))
(insert-entity-wholesale db table entity-type (get-unique user) "1" "0" ktvlist))
;; all the parameters - for syncing purposes
(define (insert-entity-wholesale db table entity-type unique-id dirty version ktvlist)
......@@ -363,10 +363,10 @@
(define (entity-id-from-unique db table unique-id)
(select-first
db (string-append "select entity_id from " table "_entity where unique_id = "
unique-id)))
db (string-append "select entity_id from " table "_entity where unique_id = '"
unique-id "';")))
(define (entity-version-from-unique db table unique-id)
(select-first
db (string-append "select version from " table "_entity where unique_id = "
unique-id)))
db (string-append "select version from " table "_entity where unique_id = '"
unique-id "'")))
......@@ -130,10 +130,14 @@
(msg data)
(for-each
(lambda (i)
(let ((unique-id (car i))
(version (cadr i))
(exists (entity-exists? db table unique-id))
(old (> version (get-entity-version db table unique-id))))
(let* ((unique-id (car i))
(version (cadr i))
(exists (entity-exists? db table unique-id))
(old
(if exists
(> version (string->number
(dbg (get-entity-version db table unique-id))))
#f)))
;; if we don't have this entity or the version on the server is newer
(when (or (not exists) old)
(msg "sending for new version")
......
......@@ -366,10 +366,10 @@
(define (entity-id-from-unique db table unique-id)
(select-first
db (string-append "select entity_id from " table "_entity where unique_id = "
unique-id)))
db (string-append "select entity_id from " table "_entity where unique_id = '"
unique-id "'")))
(define (entity-version-from-unique db table unique-id)
(select-first
db (string-append "select version from " table "_entity where unique_id = "
unique-id)))
db (string-append "select version from " table "_entity where unique_id = '"
unique-id "'")))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment