Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(defproject pghstore-clj "0.1.0"
(defproject net.likestream/pghstore-clj "0.1.2"
:description "Helper functions for working with PostgresSQL hstore data type in Clojure via JDBC"
:url "http://github.com/blakesmith/pghstore-clj"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.4.0"]]
:dev-dependencies [[postgresql "9.1-901.jdbc4"]])
:dependencies [[org.clojure/clojure "1.5.1"]
[prismatic/plumbing "0.0.1"]]
:dev-dependencies [[postgresql "9.2-1002.jdbc4"]])
14 changes: 12 additions & 2 deletions src/pghstore_clj/core.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns pghstore-clj.core
(:require [clojure.string :as st])
(:require [clojure.string :as st]
[plumbing.core :refer :all])
(:import [org.postgresql.util PGobject]))

(defprotocol THstorable
Expand Down Expand Up @@ -28,4 +29,13 @@
(map (fn [v]
(map #(st/replace % #"\"" "") (st/split v #"=>")))
(st/split (.getValue this) #", "))]
[(keyword k) v])))))
[(keyword k) v])))))

(extend-type java.util.HashMap
FHstorable
(from-hstore
[this]
(->> this
(into {})
keywordize-map)))