Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Clojure 1.3.0-beta1 compatibility #97

Closed
wants to merge 2 commits into from

1 participant

@paraseba

clojure-contrib is deprecated in favor of individual libraries.
c.c.sql is no longer maintained and has some serious bugs that are being
addressed in the new org.clojure/java.jdbc (see for instance
http://dev.clojure.org/jira/browse/JDBC-11)
clojure 1.3.0 requires the addition of :dynamic metadata. All these issues are
taken care in the commit. All tests are passing, regular and integration, using both
clojure 1.2.0 and 1.3.0-beta1. Using clojure 1.3.0 there is a little issue with the
mocking library used for a couple of tests.

The downside is that projects using clojureql and c.c.sql will need to change
namespaces to the new clojure.java.jdbc.

Detail:

  • No longer depend on clojure-contrib ** c.c.sql replaced by org.clojure/java.jdbc ** c.c.core replaced by org.clojure/core.incubator ** c.c.mock replaced by org.clojure.contrib/mock
paraseba added some commits
@paraseba paraseba clojure 1.3.0 compatibility
clojure-contrib is deprecated in favor of individual libraries.
c.c.sql is no longer maintained and has some serious bugs that are being
addressed in the new org.clojure/java.jdbc (see for instance
http://dev.clojure.org/jira/browse/JDBC-11)
clojure 1.3.0 requires the addition of :dynamic metadata. All these issues are
taken care in the commit. All tests are passing, regular and integration, using both
clojure 1.2.0 and 1.3.0-beta1. Using clojure 1.3.0 there is a little issue with the
mocking library used for a couple of tests.

The downside is that projects using clojureql and c.c.sql will need to change
namespaces to the new clojure.java.jdbc.

Detail:

* No longer depend on clojure-contrib
** c.c.sql replaced by org.clojure/java.jdbc
** c.c.core replaced by org.clojure/core.incubator
** c.c.mock replaced by org.clojure.contrib/mock
c5f1fb7
@paraseba paraseba Use clojure.java.jdbc/prepare-statement a270eff
@paraseba

I'm closing this request to create a new one which depends on the latest version of c.j.jdbc

@paraseba paraseba closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 21, 2011
  1. @paraseba

    clojure 1.3.0 compatibility

    paraseba authored
    clojure-contrib is deprecated in favor of individual libraries.
    c.c.sql is no longer maintained and has some serious bugs that are being
    addressed in the new org.clojure/java.jdbc (see for instance
    http://dev.clojure.org/jira/browse/JDBC-11)
    clojure 1.3.0 requires the addition of :dynamic metadata. All these issues are
    taken care in the commit. All tests are passing, regular and integration, using both
    clojure 1.2.0 and 1.3.0-beta1. Using clojure 1.3.0 there is a little issue with the
    mocking library used for a couple of tests.
    
    The downside is that projects using clojureql and c.c.sql will need to change
    namespaces to the new clojure.java.jdbc.
    
    Detail:
    
    * No longer depend on clojure-contrib
    ** c.c.sql replaced by org.clojure/java.jdbc
    ** c.c.core replaced by org.clojure/core.incubator
    ** c.c.mock replaced by org.clojure.contrib/mock
  2. @paraseba
This page is out of date. Refresh to see the latest.
View
11 project.clj
@@ -1,8 +1,15 @@
(defproject clojureql "1.1.0-SNAPSHOT"
:description "Superior SQL integration for Clojure"
:dependencies [[org.clojure/clojure "1.2.0"]
- [org.clojure/clojure-contrib "1.2.0"]]
+ [org.clojure/core.incubator "0.1.0"]
+ [org.clojure.contrib/mock "1.3.0-alpha4"]
+ [org.clojure/java.jdbc "0.0.5"]]
:dev-dependencies [[swank-clojure "1.3.0-SNAPSHOT"]
[mysql/mysql-connector-java "5.1.6"]
[org.xerial/sqlite-jdbc "3.6.20.1"]
- [postgresql/postgresql "8.4-701.jdbc4"]])
+ [postgresql/postgresql "8.4-701.jdbc4"]]
+
+ :repositories {"clojure-releases" {:url "http://build.clojure.org/releases"}})
+
+
+
View
14 src/clojureql/connectivity.clj
@@ -8,7 +8,7 @@
default global connection."
([specs] (open-global ::clojureql.internal/default-connection specs))
([conn-name specs]
- (let [con (sqlint/get-connection specs)]
+ (let [con (jdbcint/get-connection specs)]
(when-let [ac (-> specs :auto-commit)]
(.setAutoCommit con ac))
(swap! global-connections assoc conn-name {:connection con :opts specs}))))
@@ -42,13 +42,13 @@
(io!
(cond
- (find-connection) ; an already open c.c.sql connection takes precedence
+ (find-connection*) ; an already open c.j.jdbc connection takes precedence
(func)
(map? con-info) ; then we try a passed connection info (presumably associated with some table in the query)
- (with-open [con (sqlint/get-connection con-info)]
- (binding [sqlint/*db*
- (assoc sqlint/*db*
+ (with-open [con (jdbcint/get-connection con-info)]
+ (binding [jdbcint/*db*
+ (assoc jdbcint/*db*
:connection con
:level 0
:rollback (atom false)
@@ -59,8 +59,8 @@
:default ; try global connection
(if-let [con (@clojureql.core/global-connections
(or con-info :clojureql.internal/default-connection))]
- (binding [sqlint/*db*
- (assoc sqlint/*db*
+ (binding [jdbcint/*db*
+ (assoc jdbcint/*db*
:connection (:connection con)
:level 0
:rollback (atom false)
View
13 src/clojureql/core.clj
@@ -9,14 +9,15 @@
(:refer-clojure
:exclude [take drop sort distinct conj! disj! compile case])
(:use
- [clojureql internal predicates]
- [clojure.string :only [join upper-case] :rename {join join-str}]
- [clojure.contrib sql [core :only [-?> -?>>]]]
- [clojure.contrib.sql.internal :as sqlint]
- [clojure.walk :only (postwalk-replace)]))
+ [clojureql internal predicates]
+ [clojure.string :only [join upper-case] :rename {join join-str}]
+ [clojure.java.jdbc :only [delete-rows]]
+ [clojure.java.jdbc.internal :as jdbcint]
+ [clojure.core.incubator :only [-?> -?>>]]
+ [clojure.walk :only (postwalk-replace)]))
; GLOBALS
-(def *debug* false)
+(def ^{:dynamic true} *debug* false)
(declare table?)
(declare table)
View
21 src/clojureql/internal.clj
@@ -1,10 +1,9 @@
(ns clojureql.internal
(:require
- [clojure.contrib.sql.internal :as sqlint]
- [clojure.contrib.sql :as csql])
+ [clojure.java.jdbc.internal :as jdbcint]
+ [clojure.java.jdbc :as jdbc])
(:use [clojure.string :only [join upper-case] :rename {join join-str}]
- [clojure.contrib.string :only (as-str)]
- [clojure.contrib.core :only [-?> -?>>]]))
+ [clojure.core.incubator :only [-?> -?>>]]))
(defn upper-name [kw]
(-> kw name .toUpperCase))
@@ -152,7 +151,7 @@
returns the same as to-tablename."
[c]
(if (map? c)
- (as-str (first (vals c)))
+ (name (first (vals c)))
(to-tablename c)))
(defn emit-case
@@ -348,13 +347,13 @@
[[sql & params :as sql-params] func]
(when-not (vector? sql-params)
(throw (Exception. "sql-params must be a vector")))
- (with-open [stmt (.prepareStatement (:connection sqlint/*db*) sql)]
+ (with-open [stmt (jdbc/prepare-statement (:connection jdbcint/*db*) sql)]
(doseq [[idx v] (map vector (iterate inc 1) params)]
(.setObject stmt idx v))
- (if-let [fetch-size (-> sqlint/*db* :opts :fetch-size)]
+ (if-let [fetch-size (-> jdbcint/*db* :opts :fetch-size)]
(do
(.setFetchSize stmt fetch-size)
- (csql/transaction
+ (jdbc/transaction
(with-open [rset (.executeQuery stmt)]
(func (result-seq rset)))))
(with-open [rset (.executeQuery stmt)]
@@ -365,12 +364,12 @@
open database connection. Each param-group is a seq of values for all of
the parameters."
[sql & param-groups]
- (with-open [stmt (.prepareStatement (:connection sqlint/*db*) sql)]
+ (with-open [stmt (jdbc/prepare-statement (:connection jdbcint/*db*) sql)]
(doseq [param-group param-groups]
(doseq [[idx v] (map vector (iterate inc 1) param-group)]
(.setObject stmt idx v))
(.addBatch stmt))
- (csql/transaction
+ (jdbc/transaction
(let [retr (.executeBatch stmt)
ks (.getGeneratedKeys stmt)]
(with-meta
@@ -418,7 +417,7 @@
criteria followed by values for any parameters. record is a map from
strings or keywords (identifying columns) to updated values."
[table where-params record]
- (csql/transaction
+ (jdbc/transaction
(let [result (update-vals table where-params record)]
(if (zero? (first result))
(conj-rows table (keys record) (vals record))
View
6 test/clojureql/test.clj
@@ -1,9 +1,9 @@
(ns clojureql.test
- (:refer-clojure :exclude [compile drop take sort distinct conj! disj! case])
- (:use clojure.contrib.sql
+ (:refer-clojure :exclude [compile drop take sort distinct conj! disj! case resultset-seq])
+ (:use clojure.java.jdbc
clojure.test
clojureql.core
- [clojure.contrib.io :only [delete-file]]
+ [clojure.java.io :only [delete-file]]
[cake :only [*opts*]]))
(when (:show-sql *opts*)
View
13 test/clojureql/test/core.clj
@@ -2,7 +2,8 @@
(:refer-clojure
:exclude [compile take drop sort distinct conj! disj! case])
(:use [clojureql.internal :only [update-or-insert-vals update-vals]]
- [clojure.contrib.sql :only [with-connection find-connection]]
+ [clojure.java.jdbc :only [with-connection]]
+ [clojure.java.jdbc.internal :only [find-connection*]]
clojure.test
clojureql.core
clojure.contrib.mock)
@@ -28,7 +29,7 @@
(defn resolve-table-db [spec-on-tble]
(with-cnx spec-on-tble
- (get (find-connection) :id)))
+ (get (find-connection*) :id)))
(deftest connection-sources
(testing "missing connection info"
@@ -340,18 +341,18 @@
(testing "update!"
(expect [update-vals (has-args [:users ["(id = ?)" 1] {:name "Bob"}])
- find-connection (returns true)]
+ find-connection* (returns true)]
(update! (table :users) (where (= :id 1)) {:name "Bob"}))
(expect [update-vals (has-args [:users ["(salary IS NULL)"] {:salary 1000}])
- find-connection (returns true)]
+ find-connection* (returns true)]
(update! (table :users) (where (= :salary nil)) {:salary 1000})))
(testing "update-in!"
(expect [update-or-insert-vals (has-args [:users ["(id = ?)" 1] {:name "Bob"}])
- find-connection (returns true)]
+ find-connection* (returns true)]
(update-in! (table :users) (where (= :id 1)) {:name "Bob"}))
(expect [update-or-insert-vals (has-args [:users ["(salary IS NULL)"] {:salary 1000}])
- find-connection (returns true)]
+ find-connection* (returns true)]
(update-in! (table :users) (where (= :salary nil)) {:salary 1000})))
(testing "difference"
Something went wrong with that request. Please try again.