diff options
Diffstat (limited to 'pg-datastore.lisp')
-rw-r--r-- | pg-datastore.lisp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pg-datastore.lisp b/pg-datastore.lisp index 805e748..260902e 100644 --- a/pg-datastore.lisp +++ b/pg-datastore.lisp @@ -94,8 +94,11 @@ :where (:= 'id id)) :single)) (next-priority (funcall (ecase dir (:up #'-) (:down #'+)) - current-priority 1))) + current-priority 1)) + (max-priority (query (:select (:max 'priority) :from type) + :single))) (execute (:update type :set 'priority current-priority :where (:= 'priority next-priority))) - (execute (:update type :set 'priority next-priority + (execute (:update type :set + 'priority (max 1 (min next-priority max-priority)) :where (:= 'id id)))))) |