bomberpac/sqlog/sqltest.fnl
Jeremy Penner fd3fcbd978 integrate sqlite, reorganize code
* diet-sqlite - a cleaned-up, slightly updated, and de-ooped version of
  https://github.com/Wiladams/LJIT2SQLite
* rename waltz -> sqlog
* separate compiler from driver
* introduce uniform syntax for actions
2022-03-29 13:24:34 -04:00

19 lines
594 B
Fennel

(local Sqlog (require :sqlog))
(import-macros {: $ : query : specify} :sqlog.macros)
(local s (Sqlog))
(s:connect ":memory:")
(s:deftable :parent :parent :child)
(specify s
(* [generation name (|| name " jr") 2] [parent name (|| name " jr")])
(* [generation name (|| name " iii") 3] [ancestor name (|| name " iii")])
(* [ancestor x y 1] [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]
[parent :fred :jim]
[parent :fred :betty])
(pp (query s [generation :bob descendant gen]))