[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/17: .dir-locals.el: properly indent sql macros.
From: |
Caleb Ristvedt |
Subject: |
03/17: .dir-locals.el: properly indent sql macros. |
Date: |
Tue, 29 Aug 2017 02:07:47 -0400 (EDT) |
reepca pushed a commit to branch guile-daemon
in repository guix.
commit e056d1d0e87c6346b34455b1b30639e91489a9c7
Author: Caleb Ristvedt <address@hidden>
Date: Mon Jun 5 20:28:33 2017 -0500
.dir-locals.el: properly indent sql macros.
* .dir-locals.el: add indentation for with-sql-statement, with-sql-database,
run-sql, and run-statement.
* guix/sql.scm: use that indentation.
(step-all): fix invocation of named-let so it works for multi-step
statements.
---
.dir-locals.el | 5 +++
guix/sql.scm | 99 ++++++++++++++++++++++++++++++----------------------------
2 files changed, 57 insertions(+), 47 deletions(-)
diff --git a/.dir-locals.el b/.dir-locals.el
index 04b58d2..d5caef0 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -73,6 +73,11 @@
(eval . (put 'wrap-program 'scheme-indent-function 1))
(eval . (put 'with-imported-modules 'scheme-indent-function 1))
+ (eval . (put 'with-sql-statement 'scheme-indent-function 1))
+ (eval . (put 'with-sql-database 'scheme-indent-function 1))
+ (eval . (put 'run-sql 'scheme-indent-function 1))
+ (eval . (put 'run-statement 'scheme-indent-function 1))
+
(eval . (put 'call-with-container 'scheme-indent-function 1))
(eval . (put 'container-excursion 'scheme-indent-function 1))
(eval . (put 'eventually 'scheme-indent-function 1))
diff --git a/guix/sql.scm b/guix/sql.scm
index b6153e3..d5c7210 100644
--- a/guix/sql.scm
+++ b/guix/sql.scm
@@ -55,7 +55,7 @@
(let maybe-step ((ret (sqlite-step statement))
(count 0))
(if ret
- (maybe-step ret (+ count 1))
+ (maybe-step (sqlite-step statement) (+ count 1))
count)))
;; I get the feeling schemers have probably already got this "with" business
@@ -72,8 +72,8 @@ key-value pairs."
(dynamic-wind noop
(lambda ()
(sql-parameters statement-var
- (name1 val1)
- (name2 val2) ...)
+ (name1 val1)
+ (name2 val2) ...)
exps ...)
(lambda ()
(sqlite-finalize statement-var)))))
@@ -155,10 +155,11 @@ placeholder name and the value to use. Returns the number
of rows."
"If the path \"path\" exists in the ValidPaths table, return its
id. Otherwise, return #f. If you already have a compiled statement for this
purpose, you can give it as statement."
- (with-sql-statement db path-id-sql statement
- (;("$path" path)
- (1 path))
- (single-result statement)))
+ (with-sql-statement
+ db path-id-sql statement
+ (;("$path" path)
+ (1 path))
+ (single-result statement)))
(define update-sql
@@ -177,32 +178,34 @@ of course. Returns the row id of the row that was
modified or inserted."
(let ((id (path-id db path)))
(if id
(begin
- (run-sql db update-sql
- ;; As you may have noticed, sqlite-bind doesn't behave
- ;; exactly how I was expecting...
- ;; ("$id" id)
- ;; ("$deriver" deriver)
- ;; ("$hash" hash)
- ;; ("$size" nar-size)
- ;; ("$time" time)
- (5 id)
- (3 deriver)
- (1 hash)
- (4 nar-size)
- (2 time))
+ (run-sql
+ db update-sql
+ ;; As you may have noticed, sqlite-bind doesn't behave
+ ;; exactly how I was expecting...
+ ;; ("$id" id)
+ ;; ("$deriver" deriver)
+ ;; ("$hash" hash)
+ ;; ("$size" nar-size)
+ ;; ("$time" time)
+ (5 id)
+ (3 deriver)
+ (1 hash)
+ (4 nar-size)
+ (2 time))
id)
(begin
- (run-sql db insert-sql
- ;; ("$path" path)
- ;; ("$deriver" deriver)
- ;; ("$hash" hash)
- ;; ("$size" nar-size)
- ;; ("$time" time)
- (1 path)
- (4 deriver)
- (2 hash)
- (5 nar-size)
- (3 time))
+ (run-sql
+ db insert-sql
+ ;; ("$path" path)
+ ;; ("$deriver" deriver)
+ ;; ("$hash" hash)
+ ;; ("$size" nar-size)
+ ;; ("$time" time)
+ (1 path)
+ (4 deriver)
+ (2 hash)
+ (5 nar-size)
+ (3 time))
(sqlite-last-insert-rowid db)))))
(define add-reference-sql
@@ -213,15 +216,16 @@ FROM ValidPaths WHERE path = $reference")
"referrer is the id of the referring store item, references is a list
containing store item paths being referred to. Note that all of the store
items in \"references\" should already be registered."
- (with-sql-statement db add-reference-sql add-reference-statement ()
- (for-each (lambda (reference)
- (run-statement db
- add-reference-statement
- ;("$referrer" referrer)
- ;("$reference" reference)
- (1 referrer)
- (2 reference)))
- references)))
+ (with-sql-statement
+ db add-reference-sql add-reference-statement ()
+ (for-each (lambda (reference)
+ (run-statement
+ db add-reference-statement
+ ;("$referrer" referrer)
+ ;("$reference" reference)
+ (1 referrer)
+ (2 reference)))
+ references)))
;; XXX figure out caching of statement and database objects... later
(define* (sqlite-register #:key dbpath path references deriver hash nar-size)
@@ -232,11 +236,12 @@ path of the derivation that created the store item PATH,
HASH is the
base16-encoded sha256 hash of the store item denoted by PATH (prefixed with
\"sha256:\") after being converted to nar form, and nar-size is the size in
bytes of the store item denoted by PATH after being converted to nar form."
- (with-sql-database dbpath db
- (let ((id (update-or-insert #:db db
- #:path path
- #:deriver deriver
- #:hash hash
- #:nar-size nar-size
- #:time (current-time))))
+ (with-sql-database
+ dbpath db
+ (let ((id (update-or-insert #:db db
+ #:path path
+ #:deriver deriver
+ #:hash hash
+ #:nar-size nar-size
+ #:time (current-time))))
(add-references db id references))))
- branch guile-daemon updated (f5dfbaa -> 6dee54f), Caleb Ristvedt, 2017/08/29
- 02/17: guix: register-path: Honor environment variables., Caleb Ristvedt, 2017/08/29
- 03/17: .dir-locals.el: properly indent sql macros.,
Caleb Ristvedt <=
- 04/17: guix: sql.scm: split into generic and store-specific parts., Caleb Ristvedt, 2017/08/29
- 16/17: build-derivations: Leaked environment variables more robust., Caleb Ristvedt, 2017/08/29
- 12/17: linux-container: new use-output argument., Caleb Ristvedt, 2017/08/29
- 14/17: build-derivations: initial build-group support, Caleb Ristvedt, 2017/08/29
- 07/17: guix: register-path: do deduplication., Caleb Ristvedt, 2017/08/29
- 13/17: build-derivations: use call-with-container, Caleb Ristvedt, 2017/08/29
- 09/17: deduplication: new module., Caleb Ristvedt, 2017/08/29
- 06/17: guix: register-path: reset timestamps after registering., Caleb Ristvedt, 2017/08/29
- 10/17: guix: register-path: use new %store-database-directory, Caleb Ristvedt, 2017/08/29
- 05/17: guix: register-path: use new %store-database-directory, Caleb Ristvedt, 2017/08/29