Use insert-missing-data-and-return-all-ids for locations
This commit is contained in:
parent
221394eafb
commit
9a38374e7c
1 changed files with 9 additions and 29 deletions
|
|
@ -19,35 +19,15 @@
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (guix utils)
|
#:use-module (guix utils)
|
||||||
#:use-module (squee)
|
#:use-module (squee)
|
||||||
|
#:use-module (guix-data-service model utils)
|
||||||
#:export (location->location-id))
|
#:export (location->location-id))
|
||||||
|
|
||||||
(define select-existing-location
|
|
||||||
(string-append
|
|
||||||
"SELECT id "
|
|
||||||
"FROM locations "
|
|
||||||
"WHERE file = $1 AND line = $2 AND column_number = $3"))
|
|
||||||
|
|
||||||
(define insert-location
|
|
||||||
(string-append
|
|
||||||
"INSERT INTO locations "
|
|
||||||
"(file, line, column_number) VALUES "
|
|
||||||
"($1, $2, $3) "
|
|
||||||
"RETURNING id"))
|
|
||||||
|
|
||||||
(define (location->location-id conn location)
|
(define (location->location-id conn location)
|
||||||
(match location
|
(car
|
||||||
(($ <location> file line column)
|
(insert-missing-data-and-return-all-ids
|
||||||
(string->number
|
conn
|
||||||
(match (exec-query conn
|
"locations"
|
||||||
select-existing-location
|
'(file line column_number)
|
||||||
(list file
|
(match location
|
||||||
(number->string line)
|
(($ <location> file line column)
|
||||||
(number->string column)))
|
(list (list file line column)))))))
|
||||||
(((id)) id)
|
|
||||||
(()
|
|
||||||
(caar
|
|
||||||
(exec-query conn
|
|
||||||
insert-location
|
|
||||||
(list file
|
|
||||||
(number->string line)
|
|
||||||
(number->string column))))))))))
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue