Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/korma/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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)
Expand Down