latticesql 1.6.8 → 1.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/postgres-worker.cjs +52 -0
- package/package.json +1 -1
package/dist/postgres-worker.cjs
CHANGED
|
@@ -23,6 +23,58 @@ function ensureClient() {
|
|
|
23
23
|
extErr instanceof Error ? extErr.message : extErr
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
|
+
try {
|
|
27
|
+
await client.query(
|
|
28
|
+
`CREATE OR REPLACE FUNCTION json_extract(doc text, path text)
|
|
29
|
+
RETURNS text
|
|
30
|
+
LANGUAGE sql
|
|
31
|
+
IMMUTABLE
|
|
32
|
+
AS $fn$
|
|
33
|
+
SELECT doc::jsonb #>> string_to_array(regexp_replace(path, '^\\$\\.?', ''), '.')
|
|
34
|
+
$fn$;`
|
|
35
|
+
);
|
|
36
|
+
} catch (jeErr) {
|
|
37
|
+
console.warn(
|
|
38
|
+
"[PostgresAdapter] could not register json_extract polyfill:",
|
|
39
|
+
jeErr instanceof Error ? jeErr.message : jeErr
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
await client.query(
|
|
44
|
+
`CREATE OR REPLACE FUNCTION strftime(format text, modifier text)
|
|
45
|
+
RETURNS text
|
|
46
|
+
LANGUAGE plpgsql
|
|
47
|
+
IMMUTABLE
|
|
48
|
+
AS $fn$
|
|
49
|
+
DECLARE ts timestamptz;
|
|
50
|
+
BEGIN
|
|
51
|
+
IF modifier = 'now' THEN
|
|
52
|
+
ts := now();
|
|
53
|
+
ELSE
|
|
54
|
+
ts := modifier::timestamptz;
|
|
55
|
+
END IF;
|
|
56
|
+
RETURN to_char(
|
|
57
|
+
ts AT TIME ZONE 'UTC',
|
|
58
|
+
replace(replace(replace(replace(replace(replace(replace(replace(
|
|
59
|
+
format,
|
|
60
|
+
'%Y', 'YYYY'),
|
|
61
|
+
'%m', 'MM'),
|
|
62
|
+
'%d', 'DD'),
|
|
63
|
+
'%H', 'HH24'),
|
|
64
|
+
'%M', 'MI'),
|
|
65
|
+
'%S', 'SS'),
|
|
66
|
+
'%f', 'MS'),
|
|
67
|
+
'T', '"T"')
|
|
68
|
+
);
|
|
69
|
+
END;
|
|
70
|
+
$fn$;`
|
|
71
|
+
);
|
|
72
|
+
} catch (sfErr) {
|
|
73
|
+
console.warn(
|
|
74
|
+
"[PostgresAdapter] could not register strftime polyfill:",
|
|
75
|
+
sfErr instanceof Error ? sfErr.message : sfErr
|
|
76
|
+
);
|
|
77
|
+
}
|
|
26
78
|
return { ok: true };
|
|
27
79
|
}
|
|
28
80
|
case "close": {
|
package/package.json
CHANGED