edtris/sqlog/sqltest.fnl

19 lines
665 B
Fennel

(local Sqlog (require :sqlog))
(local {: show} (require :inspector.debug))
(import-macros {: $ : query : specify} :sqlog.macros)
(local s (Sqlog))
(specify s
(table parent parent child)
(* [generation name (|| name " jr") 2] [parent name (|| name " jr")])
(* [generation name (|| name " iii") 3] [ancestor name (|| name " iii")])
(* [ancestor x y 2] [parent x y])
(* [ancestor x y (+ gen 1)] [parent x z] [ancestor z y gen])
[parent :bob "bob jr"]
[parent "bob jr" "bob iii"]
[parent :bob #(.. :fred :dy)]
[parent :fred :jim]
[parent :fred :betty])
(show (query s [ancestor (case descendant (when "bob jr" :bob) (else :jim)) descendant gen]))