~subsetpark/doozer

doozer/doozer/common.janet -rw-r--r-- 787 bytes
4a8e0e3e — Zach Smith update docs 1 year, 8 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(defn make-alias
  [&opt prefix]
  (def prefix (cond
                (nil? prefix) ""
                (not (bytes? prefix)) ""
                (> (length prefix) 7) (string/slice prefix 0 7)
                prefix))
  (string prefix (gensym)))

(def operators
  {'= "%s = %s"
   'not= "%s <> %s"
   '+ "%s + %s"
   '- "%s - %s"
   '* "%s * %s"
   '/ "%s / %s"
   'mod "%s % %s"
   '= "%s = %s"
   'not= "%s <> %s"
   '> "%s > %s"
   '< "%s < %s"
   '>= "%s >= %s"
   '<= "%s <= %s"
   'between "%s BETWEEN %s AND %s"
   'in "%s IN %s"
   'not-in "%s NOT IN %s"
   'exists "EXISTS %s"
   'nil? "%s IS NULL"
   'and "(%s AND %s)"
   'or "(%s OR %s)"
   'not "NOT %s"
   'like "%s LIKE %s"
   'glob "%s GLOB %s"
   # TODO: Make this variadic.
   'string "%s || %s"
   'unique "UNIQUE %s"})