Skip to content

Commit 78e7ad0

Browse files
authored
Fix database hydration (#115)
* Add test showing invalid item from load * Use content_hydrate instead of merge_jsonb The problem is in the ordering of arguments to content_hydrate; this shows true failures across other hydrate tests * Fix argument ordering in content_hydrate * Update version to 0.6.3 * Update CHANGELOG
1 parent 465f62a commit 78e7ad0

File tree

11 files changed

+3522
-6
lines changed

11 files changed

+3522
-6
lines changed

CHANGELOG.md

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

3-
## Unreleased
3+
## [v0.6.3]
4+
5+
### Fixed
6+
7+
- Fixed content_hydrate argument ordering which caused incorrect behavior in database hydration [#115](https://github.com/stac-utils/pgstac/pull/115)
48

59
### Added
610

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
SET SEARCH_PATH to pgstac, public;
2+
drop function if exists "pgstac"."content_hydrate"(_base_item jsonb, _item jsonb, fields jsonb);
3+
4+
set check_function_bodies = off;
5+
6+
CREATE OR REPLACE FUNCTION pgstac.content_hydrate(_item jsonb, _base_item jsonb, fields jsonb DEFAULT '{}'::jsonb)
7+
RETURNS jsonb
8+
LANGUAGE sql
9+
IMMUTABLE PARALLEL SAFE
10+
AS $function$
11+
SELECT merge_jsonb(
12+
jsonb_fields(_item, fields),
13+
jsonb_fields(_base_item, fields)
14+
);
15+
$function$
16+
;
17+
18+
19+
20+
SELECT set_version('0.6.3');

0 commit comments

Comments
 (0)