File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ local PG_TYPES = {
116116 [1016 ] = " array_number" ,
117117 [1021 ] = " array_number" ,
118118 [1022 ] = " array_number" ,
119+ [1041 ] = " array_inet" ,
119120 [1231 ] = " array_number" ,
120121 [1009 ] = " array_string" ,
121122 [1015 ] = " array_string" ,
177178 bytea = function (self , val , name )
178179 return self :decode_bytea (val )
179180 end ,
181+ array_inet = function (self , val , name )
182+ local decode_array
183+ decode_array = require (" pgmoon.arrays" ).decode_array
184+ return decode_array (val , nil , self )
185+ end ,
180186 array_boolean = function (self , val , name )
181187 local decode_array
182188 decode_array = require (" pgmoon.arrays" ).decode_array
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ PG_TYPES = {
110110 [ 1016 ] : " array_number" -- int8 array
111111 [ 1021 ] : " array_number" -- float4 array
112112 [ 1022 ] : " array_number" -- float8 array
113+ [ 1041 ] : " array_inet" -- array of ip addresses
113114 [ 1231 ] : " array_number" -- numeric array
114115
115116 [ 1009 ] : " array_string" -- text array
@@ -173,6 +174,10 @@ class Postgres
173174 bytea : ( val, name) =>
174175 @decode_bytea val
175176
177+ array_inet : ( val, name) =>
178+ import decode_array from require " pgmoon.arrays"
179+ decode_array val, nil , @
180+
176181 array_boolean : ( val, name) =>
177182 import decode_array from require " pgmoon.arrays"
178183 decode_array val, tobool, @
Original file line number Diff line number Diff line change @@ -1018,6 +1018,16 @@ describe "pgmoon with server", ->
10181018 } }
10191019 } , ( pg\ query " select * from arrays_test" )
10201020
1021+ it " loads inet arrays from table" , ->
1022+ assert pg\ query " create table arrays_test (addresses inet[])"
1023+ assert pg\ query " insert into arrays_test (addresses) values ('{192.168.1.1,10.0.0.1}')"
1024+ assert pg\ query " insert into arrays_test (addresses) values ('{127.0.0.1,::1,2001:db8::1}')"
1025+
1026+ assert . same {
1027+ { addresses : { " 192.168.1.1" , " 10.0.0.1" } }
1028+ { addresses : { " 127.0.0.1" , " ::1" , " 2001:db8::1" } }
1029+ } , ( pg\ query " select * from arrays_test" )
1030+
10211031
10221032 it " converts null" , ->
10231033 pg. convert_null = true
You can’t perform that action at this time.
0 commit comments