diff --git a/src/dsql/pg.clj b/src/dsql/pg.clj index 8b762cd..724b1e8 100644 --- a/src/dsql/pg.clj +++ b/src/dsql/pg.clj @@ -2,7 +2,7 @@ (:require [dsql.core :as ql] [jsonista.core :as json] [clojure.string :as str]) - (:import [com.fasterxml.jackson.databind.node ObjectNode ArrayNode TextNode IntNode BooleanNode] + (:import [com.fasterxml.jackson.databind.node ObjectNode ArrayNode TextNode IntNode BooleanNode DoubleNode LongNode] [com.fasterxml.jackson.databind JsonNode ObjectMapper] [java.util Iterator]) (:refer-clojure :exclude [format])) @@ -412,13 +412,16 @@ (.writeValueAsString object-mapper json)) (defn jackson-param [acc v] (conj acc ["?" (to-json-string v)])) -(defn jackson-param-as-text [acc ^JsonNode v] (conj acc ["?" (.asText v)])) +(defn jackson-param-as-text [acc ^JsonNode v] + (conj acc ["?" (.asText v)])) (defmethod ql/to-sql ObjectNode [acc opts v] (jackson-param acc v)) (defmethod ql/to-sql ArrayNode [acc opts v] (jackson-param acc v)) (defmethod ql/to-sql TextNode [acc opts v] (jackson-param-as-text acc v)) (defmethod ql/to-sql IntNode [acc opts v] (jackson-param-as-text acc v)) (defmethod ql/to-sql BooleanNode [acc opts v] (jackson-param-as-text acc v)) +(defmethod ql/to-sql DoubleNode [acc opts v] (jackson-param-as-text acc v)) +(defmethod ql/to-sql LongNode [acc opts v] (jackson-param-as-text acc v)) diff --git a/test/dsql/pg_test.clj b/test/dsql/pg_test.clj index c27c55f..0e5a708 100644 --- a/test/dsql/pg_test.clj +++ b/test/dsql/pg_test.clj @@ -51,6 +51,8 @@ (def r {:id "fd209869-1f1c-42eb-b0bf-b5942370452c" :meta_partition 123 + :long 1234567890123 + :double 123.123 :birthDate "1991-11-08" :name [{:given "Ibragim"}] :deceasedBoolean false @@ -61,9 +63,11 @@ :into :patient :value (to-jackson r) :returning :*} - ["INSERT INTO patient ( \"id\", \"meta_partition\", \"birthDate\", \"name\", \"deceasedBoolean\", \"extension\" ) VALUES ( ? , ? , ? , ? , ? , ? ) RETURNING *" + ["INSERT INTO patient ( \"id\", \"meta_partition\", \"long\", \"double\", \"birthDate\", \"name\", \"deceasedBoolean\", \"extension\" ) VALUES ( ? , ? , ? , ? , ? , ? , ? , ? ) RETURNING *" "fd209869-1f1c-42eb-b0bf-b5942370452c" "123" + "1234567890123" + "123.123" "1991-11-08" "[{\"given\":\"Ibragim\"}]" "false"