Skip to content

Commit

Permalink
Merge branch 'main' of github.com:stac-utils/pgstac into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bitner committed Aug 11, 2021
2 parents fc80333 + be27663 commit 3e18fd2
Show file tree
Hide file tree
Showing 7 changed files with 1,634 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pypgstac/pypgstac/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""PyPGStac Version."""
__version__ = "0.3.0"
__version__ = "0.3.1"
29 changes: 29 additions & 0 deletions pypgstac/pypgstac/migrations/pgstac.0.3.0-0.3.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SET SEARCH_PATH to pgstac, public;
set check_function_bodies = off;

CREATE OR REPLACE FUNCTION pgstac.sort_sqlorderby(_search jsonb DEFAULT NULL::jsonb, reverse boolean DEFAULT false)
RETURNS text
LANGUAGE sql
AS $function$
WITH sorts AS (
SELECT
(items_path(value->>'field')).path as key,
parse_sort_dir(value->>'direction', reverse) as dir
FROM jsonb_array_elements(
'[]'::jsonb
||
coalesce(_search->'sortby','[{"field":"datetime", "direction":"desc"}]')
||
'[{"field":"id","direction":"desc"}]'::jsonb
)
)
SELECT array_to_string(
array_agg(concat(key, ' ', dir)),
', '
) FROM sorts;
$function$
;



INSERT INTO migrations (version) VALUES ('0.3.1');
Loading

0 comments on commit 3e18fd2

Please sign in to comment.