From 76a38b3145cec23d73f417bd1b2677dd8e6a6f67 Mon Sep 17 00:00:00 2001 From: Cyrus Harmon Date: Tue, 13 Sep 2016 16:20:38 -0700 Subject: [PATCH] support and tests for lseg type --- 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 d682ee0..10b0b99 100644 --- a/cl-postgres/interpret.lisp +++ b/cl-postgres/interpret.lisp @@ -161,6 +161,7 @@ interpreted as an array of the given type." 1015 ;; varchar array 1016 ;; int8 array 1017 ;; point array + 1018 ;; lseg array 1021 ;; float4 array 1022 ;; float8 array 1028 ;; oid array @@ -178,6 +179,15 @@ interpreted as an array of the given type." (list (cl-postgres-ieee-floats:decode-float64 point-x-bits) (cl-postgres-ieee-floats:decode-float64 point-y-bits))) +(define-interpreter 601 "lseg" ((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 c59a175..17b23bf 100644 --- a/cl-postgres/tests.lisp +++ b/cl-postgres/tests.lisp @@ -289,3 +289,18 @@ (with-test-connection (is (equalp (exec-query connection "select row(ARRAY[point(1,2)])" 'list-row-reader) '(((#((1.0d0 2.0d0))))))))) + +(test lseg + (with-test-connection + (is (equalp (exec-query connection "select lseg(point(1,2),point(3,4))" 'list-row-reader) + '((((1.0d0 2.0d0) (3.0d0 4.0d0)))))))) + +(test row-lseg + (with-test-connection + (is (equalp (exec-query connection "select row(lseg(point(1,2),point(3,4)))" 'list-row-reader) + '(((((1.0d0 2.0d0) (3.0d0 4.0d0))))))))) + +(test row-lseg-array + (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)))))))))) -- 2.11.4.GIT