From 89413f2d1e505a7cf1a5f0356d4b06f75261b9b1 Mon Sep 17 00:00:00 2001 From: Cyrus Harmon Date: Tue, 13 Sep 2016 16:25:57 -0700 Subject: [PATCH] added support for box type and arrays --- cl-postgres/interpret.lisp | 10 ++++++++++ cl-postgres/tests.lisp | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/cl-postgres/interpret.lisp b/cl-postgres/interpret.lisp index 10b0b99..d4b2975 100644 --- a/cl-postgres/interpret.lisp +++ b/cl-postgres/interpret.lisp @@ -162,6 +162,7 @@ interpreted as an array of the given type." 1016 ;; int8 array 1017 ;; point array 1018 ;; lseg array + 1020 ;; box array 1021 ;; float4 array 1022 ;; float8 array 1028 ;; oid array @@ -188,6 +189,15 @@ interpreted as an array of the given type." (list (cl-postgres-ieee-floats:decode-float64 point-x2-bits) (cl-postgres-ieee-floats:decode-float64 point-y2-bits)))) +(define-interpreter 603 "box" ((point-x1-bits uint 8) + (point-y1-bits uint 8) + (point-x2-bits uint 8) + (point-y2-bits uint 8)) + (list (list (cl-postgres-ieee-floats:decode-float64 point-x1-bits) + (cl-postgres-ieee-floats:decode-float64 point-y1-bits)) + (list (cl-postgres-ieee-floats:decode-float64 point-x2-bits) + (cl-postgres-ieee-floats:decode-float64 point-y2-bits)))) + (define-interpreter 700 "float4" ((bits uint 4)) (cl-postgres-ieee-floats:decode-float32 bits)) (define-interpreter 701 "float8" ((bits uint 8)) diff --git a/cl-postgres/tests.lisp b/cl-postgres/tests.lisp index 17b23bf..c819fd5 100644 --- a/cl-postgres/tests.lisp +++ b/cl-postgres/tests.lisp @@ -304,3 +304,18 @@ (with-test-connection (is (equalp (exec-query connection "select row(ARRAY[lseg(point(1,2),point(3,4))])" 'list-row-reader) '(((#(((1.0d0 2.0d0) (3.0d0 4.0d0)))))))))) + +(test box + (with-test-connection + (is (equalp (exec-query connection "select box(point(1,2),point(3,4))" 'list-row-reader) + '((((3.0d0 4.0d0) (1.0d0 2.0d0)))))))) + +(test row-box + (with-test-connection + (is (equalp (exec-query connection "select row(box(point(1,2),point(3,4)))" 'list-row-reader) + '(((((3.0d0 4.0d0) (1.0d0 2.0d0))))))))) + +(test row-box-array + (with-test-connection + (is (equalp (exec-query connection "select row(ARRAY[box(point(1,2),point(3,4))])" 'list-row-reader) + '(((#(((3.0d0 4.0d0) (1.0d0 2.0d0)))))))))) -- 2.11.4.GIT