Skip to content

Commit

Permalink
Fix e2e test for JSON values
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-dp committed Apr 23, 2024
1 parent 5e24ff8 commit 337ee9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion e2e/satellite_client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,14 @@ export const get_jsonb_raw = async (electric: Electric, id: string) => {
sql: `SELECT jsb FROM jsons WHERE id = ${builder.makePositionalParam(1)};`,
args: [id]
}) as unknown as Array<{ jsb: string }>
return res[0]?.jsb

const js = res[0]?.jsb

if (builder.dialect === 'Postgres') {
return js
}

return JSON.parse(js) // SQLite stores JSON as string so parse it
}

export const get_json = async (electric: Electric, id: string) => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/03.19_node_satellite_can_sync_json.lux
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# when parsed as JSON, whitespace is trimmed but key order is kept
#[invoke node_get_json "row1" "{ a: 1, c: true, b: \"foo\", d: null, e: [1,2,3] }"]
# jsonb trims white space and sorts keys
[invoke node_get_jsonb_raw "row1" "[{\"a\": 1}, {\"b\": 5, \"d\": false}]"]
[invoke node_get_jsonb_raw "row1" "[ { a: 1 }, { b: 5, d: false } ]"]
[invoke node_get_jsonb "row1" "[ { a: 1 }, { b: 5, d: false } ]"]

# write JSON null value and DB NULL value
Expand Down Expand Up @@ -121,7 +121,7 @@
# when parsed as JSON, whitespace is trimmed but key order is kept
#[invoke node_get_json "row1" "{ a: 1, c: true, b: \"foo\", d: null, e: [1,2,3] }"]
# jsonb trims white space and sorts keys
[invoke node_get_jsonb_raw "row1" "[{\"a\": 1}, {\"b\": 5, \"d\": false}]"]
[invoke node_get_jsonb_raw "row1" "[ { a: 1 }, { b: 5, d: false } ]"]
[invoke node_get_jsonb "row1" "[ { a: 1 }, { b: 5, d: false } ]"]

#[invoke node_get_json "row2" "{ __is_electric_json_null__: true }"]
Expand Down

0 comments on commit 337ee9d

Please sign in to comment.