Skip to content

Commit 91f82bd

Browse files
vistartclaude
andauthored
feat(postgres): add comprehensive PostgreSQL function support (array, network, UUID, hstore, range) (#26)
* feat(postgres): add array, network, UUID functions and fix range constructors New function modules: - array.py: 17 array functions (array_agg, array_append, etc.) - network.py: 15 network functions (inet_client_addr, inet_merge, etc.) - uuid.py: 7 UUID functions (uuid_generate_v1, uuid_generate_v4, etc.) Fix range constructors to use sentinel pattern for bounds parameter: - int4range, int8range, numrange, tsrange, tstzrange, daterange - Omit bounds when using default inclusive '[]', include when explicitly specified Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(postgres): add comprehensive hstore function support Add PostgreSQL hstore extension functions including: - Constructors: hstore_from_record, hstore_from_key_value - Key/Value extraction: akeys, skeys, avals, svals, each - Conversion: hstore_to_array, hstore_to_matrix, hstore_to_json, hstore_to_jsonb, hstore_to_json_loose, hstore_to_jsonb_loose - Existence: hstore_exist, hstore_defined - Delete: hstore_delete, hstore_delete_keys, hstore_delete_pairs - Record: hstore_populate_record - Operators: hstore_get_value, hstore_get_values, hstore_concat, hstore_key_exists, hstore_all_keys_exist, hstore_any_key_exists, hstore_contains, hstore_contained_by, hstore_subtract_*, hstore_to_array_operator, hstore_to_matrix_operator, hstore_record_update - Subscript: hstore_subscript_get, hstore_subscript_set Note: Generic function names (exist, delete, defined, slice, populate_record, record_update) are prefixed with hstore_ to avoid confusion with unrelated functionality. * refactor(postgres): rename hstore extraction functions with hstore_ prefix Rename generic function names to avoid confusion: - akeys → hstore_akeys - skeys → hstore_skeys - avals → hstore_avals - svals → hstore_svals - each → hstore_each All hstore functions now consistently use the hstore_ prefix. * chore: add changelog fragment for PR #26 * test(postgres): add hstore function tests for full coverage --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 644956a commit 91f82bd

12 files changed

Lines changed: 2687 additions & 0 deletions

File tree

‎changelog.d/26.added.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added comprehensive PostgreSQL function support: array (18), network address (16), UUID (8), hstore (33), and range constructors (6).

‎src/rhosocial/activerecord/backend/impl/postgres/functions/__init__.py‎

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,99 @@
146146
avg,
147147
)
148148

149+
# Array functions
150+
from .array import (
151+
array_agg,
152+
array_append,
153+
array_cat,
154+
array_dims,
155+
array_fill,
156+
array_length,
157+
array_lower,
158+
array_ndims,
159+
array_position,
160+
array_positions,
161+
array_prepend,
162+
array_remove,
163+
array_replace,
164+
array_to_string,
165+
array_upper,
166+
unnest,
167+
array_agg_distinct,
168+
string_to_array,
169+
)
170+
171+
# Network address functions
172+
from .network import (
173+
inet_client_addr,
174+
inet_client_port,
175+
inet_server_addr,
176+
inet_server_port,
177+
inet_merge,
178+
inet_and,
179+
inet_or,
180+
inetnot,
181+
inet_set_mask,
182+
inet_masklen,
183+
inet_netmask,
184+
inet_network,
185+
inet_recv,
186+
inet_show,
187+
cidr_netmask,
188+
macaddr8_set7bit,
189+
)
190+
191+
# UUID functions
192+
from .uuid import (
193+
uuid_generate_v1,
194+
uuid_generate_v1mc,
195+
uuid_generate_v3,
196+
uuid_generate_v4,
197+
uuid_generate_v5,
198+
uuid_nil,
199+
uuid_max,
200+
)
201+
202+
# hstore functions
203+
from .hstore import (
204+
hstore_from_record,
205+
hstore_from_key_value,
206+
hstore_akeys,
207+
hstore_skeys,
208+
hstore_avals,
209+
hstore_svals,
210+
hstore_each,
211+
hstore_to_array,
212+
hstore_to_matrix,
213+
hstore_to_json,
214+
hstore_to_jsonb,
215+
hstore_to_json_loose,
216+
hstore_to_jsonb_loose,
217+
hstore_slice,
218+
hstore_exist,
219+
hstore_defined,
220+
hstore_delete,
221+
hstore_delete_keys,
222+
hstore_delete_pairs,
223+
hstore_populate_record,
224+
hstore_get_value,
225+
hstore_get_values,
226+
hstore_concat,
227+
hstore_key_exists,
228+
hstore_all_keys_exist,
229+
hstore_any_key_exists,
230+
hstore_contains,
231+
hstore_contained_by,
232+
hstore_subtract_key,
233+
hstore_subtract_keys,
234+
hstore_subtract_pairs,
235+
hstore_to_array_operator,
236+
hstore_to_matrix_operator,
237+
hstore_record_update,
238+
hstore_subscript_get,
239+
hstore_subscript_set,
240+
)
241+
149242

150243
__all__ = [
151244
# Range functions
@@ -247,4 +340,92 @@
247340
"max_",
248341
"min_",
249342
"avg",
343+
# Array functions
344+
"array_agg",
345+
"array_append",
346+
"array_cat",
347+
"array_dims",
348+
"array_fill",
349+
"array_length",
350+
"array_lower",
351+
"array_ndims",
352+
"array_position",
353+
"array_positions",
354+
"array_prepend",
355+
"array_remove",
356+
"array_replace",
357+
"array_to_string",
358+
"array_upper",
359+
"unnest",
360+
"array_agg_distinct",
361+
"string_to_array",
362+
# Network address functions
363+
"inet_client_addr",
364+
"inet_client_port",
365+
"inet_server_addr",
366+
"inet_server_port",
367+
"inet_merge",
368+
"inet_and",
369+
"inet_or",
370+
"inetnot",
371+
"inet_set_mask",
372+
"inet_masklen",
373+
"inet_netmask",
374+
"inet_network",
375+
"inet_recv",
376+
"inet_show",
377+
"cidr_netmask",
378+
"macaddr8_set7bit",
379+
# UUID functions
380+
"uuid_generate_v1",
381+
"uuid_generate_v1mc",
382+
"uuid_generate_v3",
383+
"uuid_generate_v4",
384+
"uuid_generate_v5",
385+
"uuid_nil",
386+
"uuid_max",
387+
# hstore functions
388+
"hstore_from_record",
389+
"hstore_from_key_value",
390+
"hstore_akeys",
391+
"hstore_skeys",
392+
"hstore_avals",
393+
"hstore_svals",
394+
"hstore_each",
395+
"hstore_to_array",
396+
"hstore_to_matrix",
397+
"hstore_to_json",
398+
"hstore_to_jsonb",
399+
"hstore_to_json_loose",
400+
"hstore_to_jsonb_loose",
401+
"hstore_slice",
402+
"hstore_exist",
403+
"hstore_defined",
404+
"hstore_delete",
405+
"hstore_delete_keys",
406+
"hstore_delete_pairs",
407+
"hstore_populate_record",
408+
"hstore_get_value",
409+
"hstore_get_values",
410+
"hstore_concat",
411+
"hstore_key_exists",
412+
"hstore_all_keys_exist",
413+
"hstore_any_key_exists",
414+
"hstore_contains",
415+
"hstore_contained_by",
416+
"hstore_subtract_key",
417+
"hstore_subtract_keys",
418+
"hstore_subtract_pairs",
419+
"hstore_to_array_operator",
420+
"hstore_to_matrix_operator",
421+
"hstore_record_update",
422+
"hstore_subscript_get",
423+
"hstore_subscript_set",
424+
# Range constructors
425+
"int4range",
426+
"int8range",
427+
"numrange",
428+
"tsrange",
429+
"tstzrange",
430+
"daterange",
250431
]

0 commit comments

Comments
 (0)