This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; I want to be able to do something like this... | |
(defdbtest has-and-belongs-to-many-creates-find-functions | |
(let [humedai (manufacturer/create (valid-manufacturer-with {:name "Humedai Automotive"})) | |
s3000xi (product/create {:name "S-3000xi" :manufacturer_id (:id humedai)}) | |
s3000xl (product/create {:name "S-3000xl" :manufacturer_id (:id humedai)}) | |
chambars (dealer/create {:name "Chambers Motors"}) | |
ira (dealer/create {:name "IRA Autos"}) | |
tundre (dealer/create {:name "Tundre Automotives"})] | |
(dealer/insert-relationship chambars (:id s3000xi)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns clj-record.query | |
(:require [clojure.contrib.str-utils :as str-utils])) | |
(defn- clause-and-parameters [join-with values] | |
[(str-utils/str-join join-with (reduce (fn [v1 v2] (conj v1 (if (nil? v2) "NULL" "?"))) [] values)) (filter (complement nil?) values)]) | |
(defn between [value1 value2] | |
(fn [attribute] | |
(let [[clause parameters] (clause-and-parameters " AND " [value1 value2])] |
NewerOlder