Skip to content

Commit d8e2bc8

Browse files
committed
docs update; remove message RSQLite create, update from file
1 parent 5519bcf commit d8e2bc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+290
-223
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# nodbi 0.11.0.9000
2+
3+
## Bug fixes
4+
* Removing message about RSQLite handling NDJSON file name as value
5+
16
# nodbi 0.11.0
27

38
## Potentially breaking changes

R/src_postgres.R

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,29 @@ src_postgres <- function(dbname = "test",
7373
# add plpgsql function for docdb_update(), which should only raise
7474
# an error if the plpgsql extension is not installed in dbname
7575
out <- try(
76-
# credits: Joao Haas, https://stackoverflow.com/a/65093455
77-
DBI::dbExecute(conn = con, statement = 'CREATE OR REPLACE FUNCTION
78-
jsonb_merge_patch("target" jsonb, "patch" jsonb)
79-
RETURNS jsonb AS $$
80-
BEGIN
81-
RETURN COALESCE(jsonb_object_agg(
82-
COALESCE("tkey", "pkey"),
83-
CASE
84-
WHEN "tval" ISNULL THEN "pval"
85-
WHEN "pval" ISNULL THEN "tval"
86-
WHEN jsonb_typeof("tval") != \'object\'
87-
OR jsonb_typeof("pval") != \'object\' THEN "pval"
88-
ELSE jsonb_merge_patch("tval", "pval")
89-
END
90-
), \'{}\'::jsonb)
91-
FROM jsonb_each("target") e1("tkey", "tval")
92-
FULL JOIN jsonb_each("patch") e2("pkey", "pval")
93-
ON "tkey" = "pkey"
94-
WHERE jsonb_typeof("pval") != \'null\' OR "pval" ISNULL;
95-
END;
96-
$$ LANGUAGE plpgsql;
97-
'), silent = TRUE)
76+
DBI::dbExecute(conn = con, statement = '
77+
CREATE OR REPLACE FUNCTION
78+
jsonb_patch("injsn" jsonb, "delta" jsonb)
79+
RETURNS jsonb LANGUAGE plpgsql AS $$
80+
BEGIN
81+
RETURN
82+
COALESCE(
83+
JSONB_OBJECT_AGG(
84+
COALESCE("keyInjsn", "keyDelta"),
85+
CASE
86+
WHEN "valInjsn" IS NULL THEN "valDelta"
87+
WHEN "valDelta" IS NULL THEN "valInjsn"
88+
WHEN (jsonb_typeof("valInjsn") <> \'object\') OR
89+
(jsonb_typeof("valDelta") <> \'object\') THEN "valDelta"
90+
ELSE jsonb_patch("valInjsn", "valDelta")
91+
END
92+
), \'{}\'::jsonb)
93+
FROM jsonb_each(injsn) AS fromInjsn("keyInjsn", "valInjsn")
94+
FULL JOIN jsonb_each(delta) AS fromDelta("keyDelta", "valDelta")
95+
ON "keyInjsn" = "keyDelta"
96+
WHERE (jsonb_typeof("valDelta") <> \'null\') OR ("valDelta" ISNULL);
97+
END;
98+
$$;'), silent = TRUE)
9899

99100
if (inherits(out, "try-error") &&
100101
!grepl("tuple concurrently updated", out)) {

R/src_sqlite.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ src_sqlite <- function(dbname = ":memory:", ...) {
4343
featUuid <- pkgNeeded("RSQLite", "2.3.7.9014", FALSE)
4444
if (featUuid) {
4545
RSQLite::initExtension(db = con, extension = "uuid")
46-
message(
47-
"RSQLite version has enabled accelerating ",
48-
"docdb_create() and docdb_update() functions ",
49-
"when used with value = <NDJSON file name>."
50-
)
5146
}
5247

5348
# set timeout for concurrency to 10s

0 commit comments

Comments
 (0)