Skip to content

Commit 5d3b4dd

Browse files
committed
Update SM Black Boxed Queries.md
1 parent b65da4d commit 5d3b4dd

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

SM Black Boxed Queries.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ There is one problem with this query and usage pattern, however. The *string_dat
3030
This way, a single string parameter passes an arbitrary number of input pairs (path variable and an associated ID) to the parameterized query. The number of required parameters no longer depends on the input, and the updated code can be black-boxed. The only remaining task is to add a new interface query, *json_object_data*, at the top and add code, converting *json_object_data* input to *string_data* format. The following snippet replaces the original *string_data* block:
3131

3232
~~~sql
33-
json_object_data(json_str) AS (
34-
VALUES
35-
('{' ||
36-
'"1":"\\usr\\share\\man\\::bin:etc/mc:", ' ||
37-
'"2":"/dev/stderr/:/dev/stdout/"' ||
38-
'}')
39-
),
33+
json_object_data(json_str) AS (
34+
VALUES
35+
('{' ||
36+
'"1":"\\usr\\share\\man\\::bin:etc/mc:", ' ||
37+
'"2":"/dev/stderr/:/dev/stdout/"' ||
38+
'}')
39+
),
4040
string_data AS (
4141
SELECT "key" AS string_id, "value" AS string
4242
FROM json_object_data AS jd, json_each(jd.json_str)
@@ -48,11 +48,11 @@ Furthermore, *json_object_data* and *string_data* can be collapsed, simplifying
4848
~~~sql
4949
string_data AS (
5050
SELECT "key" AS string_id, "value" AS string FROM json_each(
51-
'{' ||
52-
'"1":"\\usr\\share\\man\\::bin:etc/mc:", ' ||
53-
'"2":"/dev/stderr/:/dev/stdout/"' ||
54-
'}'
55-
)
51+
'{' ||
52+
'"1":"\\usr\\share\\man\\::bin:etc/mc:", ' ||
53+
'"2":"/dev/stderr/:/dev/stdout/"' ||
54+
'}'
55+
)
5656
),
5757
~~~
5858

@@ -63,11 +63,11 @@ WITH
6363
params(sep, path_sep) AS (VALUES (':', '\/')),
6464
string_data AS (
6565
SELECT "key" AS string_id, "value" AS string FROM json_each(
66-
'{' ||
67-
'"1":"\\usr\\share\\man\\::bin:etc/mc:", ' ||
68-
'"2":"/dev/stderr/:/dev/stdout/"' ||
69-
'}'
70-
)
66+
'{' ||
67+
'"1":"\\usr\\share\\man\\::bin:etc/mc:", ' ||
68+
'"2":"/dev/stderr/:/dev/stdout/"' ||
69+
'}'
70+
)
7171
),
7272
clean_strings AS (
7373
SELECT strs.string_id,

0 commit comments

Comments
 (0)