blob: 236e421dd9fe5ba443e269fc56e4d11f81b2a242 (
about) (
plain)
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
|
(ns clojure-sql.core-test
(:refer-clojure :exclude [sort-by])
(:require [clojure-sql.core :refer :all]
[midje.sweet :refer :all]))
(fact
@(table :user)
=> ["SELECT * FROM \"user\""]
@(-> (table :user) (select '(= :username "george")))
=> ["SELECT * FROM \"user\" WHERE (\"user\".\"username\" = ?)" "george"]
@(-> (table :user) (project {:username :u}))
=> ["SELECT \"user\".\"username\" AS \"u\" FROM \"user\""]
@(-> (table :user) (project {'(+ :username :password) :u}))
=> ["SELECT (\"user\".\"username\" + \"user\".\"password\") AS \"u\" FROM \"user\""])
(into {} (-> (table :user) (project '{(+ :username :password) :u})))
(-> (table :users)
(project '[:username (+ 1 2 3)])
(rename '{(+ 1 2 3) :x})
(select `(exists ~(-> (table :users)
(select '(= 10 :username)))))
println)
(-> (table :users)
(project {:username :un})
(select '(= :username 10)))
|