Skip to content

Commit d1f4df4

Browse files
authored
Update to version 0.3.2 (#44)
* Update version to 0.3.2 * Update CHANGELOG for 0.3.2 Let a TODO for previous versions without change entries
1 parent e3303e2 commit d1f4df4

File tree

6 files changed

+1673
-8
lines changed

6 files changed

+1673
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Changelog
22

3-
## [Unreleased]
3+
## [v0.3.2]
44

5-
### Added
5+
## Fixed
66

7-
### Changed
7+
- Fixed CQL term to be "collections", not "collection" ([#43](https://github.com/stac-utils/pgstac/pull/43))
88

9-
### Removed
9+
## [v0.3.1]
1010

11-
## Fixed
11+
_TODO_
1212

1313
## [v0.2.8]
1414

pypgstac/pypgstac/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""PyPGStac Version."""
2-
__version__ = "0.3.1"
2+
__version__ = "0.3.2"
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
SET SEARCH_PATH to pgstac, public;
2+
set check_function_bodies = off;
3+
4+
CREATE OR REPLACE FUNCTION pgstac.add_filters_to_cql(j jsonb)
5+
RETURNS jsonb
6+
LANGUAGE plpgsql
7+
AS $function$
8+
DECLARE
9+
newprop jsonb;
10+
newprops jsonb := '[]'::jsonb;
11+
BEGIN
12+
IF j ? 'id' THEN
13+
newprop := jsonb_build_object(
14+
'in',
15+
jsonb_build_array(
16+
'{"property":"id"}'::jsonb,
17+
j->'id'
18+
)
19+
);
20+
newprops := jsonb_insert(newprops, '{1}', newprop);
21+
END IF;
22+
IF j ? 'collections' THEN
23+
newprop := jsonb_build_object(
24+
'in',
25+
jsonb_build_array(
26+
'{"property":"collection"}'::jsonb,
27+
j->'collections'
28+
)
29+
);
30+
newprops := jsonb_insert(newprops, '{1}', newprop);
31+
END IF;
32+
33+
IF j ? 'datetime' THEN
34+
newprop := format(
35+
'{"anyinteracts":[{"property":"datetime"}, %s]}',
36+
j->'datetime'
37+
);
38+
newprops := jsonb_insert(newprops, '{1}', newprop);
39+
END IF;
40+
41+
IF j ? 'bbox' THEN
42+
newprop := format(
43+
'{"intersects":[{"property":"geometry"}, %s]}',
44+
j->'bbox'
45+
);
46+
newprops := jsonb_insert(newprops, '{1}', newprop);
47+
END IF;
48+
49+
IF j ? 'intersects' THEN
50+
newprop := format(
51+
'{"intersects":[{"property":"geometry"}, %s]}',
52+
j->'intersects'
53+
);
54+
newprops := jsonb_insert(newprops, '{1}', newprop);
55+
END IF;
56+
57+
RAISE NOTICE 'newprops: %', newprops;
58+
59+
IF newprops IS NOT NULL AND jsonb_array_length(newprops) > 0 THEN
60+
return jsonb_set(
61+
j,
62+
'{filter}',
63+
cql_and_append(j, jsonb_build_object('and', newprops))
64+
) - '{id,collections,datetime,bbox,intersects}'::text[];
65+
END IF;
66+
67+
return j;
68+
END;
69+
$function$
70+
;
71+
72+
73+
74+
INSERT INTO migrations (version) VALUES ('0.3.2');

0 commit comments

Comments
 (0)