diff --git a/src/korma/db.clj b/src/korma/db.clj index f1391a1..3ceed4d 100644 --- a/src/korma/db.clj +++ b/src/korma/db.clj @@ -262,6 +262,18 @@ :subname db} (dissoc opts :db))) +(defn mariadb + "Create a database specification for a mariadb database. Opts should include keys + for :db, :user, and :password. You can also optionally set host and port. + Delimiters are automatically set to \"`\"." + [{:keys [user password host port db] + :or {user "root" password "" host "localhost", port 3306, db ""} + :as opts}] + (merge {:classname "org.mariadb.jdbc.Driver" + :subprotocol "mariadb" + :subname (str "//" host ":" port "/" db "?user=" user "&password=" password "")} + (dissoc opts :host :port :db))) + (defmacro transaction "Execute all queries within the body in a single transaction. Optionally takes as a first argument a map to specify the :isolation and :read-only? properties of the transaction." @@ -289,7 +301,7 @@ (defn- exec-sql [{:keys [results sql-str params]}] (let [keys (get-in *current-db* [:options :naming :keys]) - sql-params (apply vector sql-str params)] + sql-params (apply vector (clojure.string/replace sql-str #"\"" "`") params)] (case results :results (jdbc/query *current-conn* sql-params {:identifiers keys}) :keys (jdbc/db-do-prepared-return-keys *current-conn* sql-params)