dzql 0.10.0 → 0.12.0

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.
@@ -254,40 +254,17 @@ $$;
254
254
  -- A field of a collection's row the same in two values: a timestamptz by the
255
255
  -- instant it names, whatever zone its text was written in (a ledger's entry
256
256
  -- keeps the session's TimeZone of its write), anything else as _delta_same.
257
- CREATE OR REPLACE FUNCTION _delta_same_framework(p_coll TEXT, p_field TEXT, a JSONB, b JSONB)
258
- RETURNS BOOLEAN LANGUAGE sql STABLE AS $$
259
- SELECT CASE
260
- WHEN jsonb_typeof(a) = 'string' AND jsonb_typeof(b) = 'string'
261
- AND (SELECT _delta_cols(collection_key, columns_def)->p_field->>'type' FROM _delta_collections WHERE collection_key = p_coll) = 'timestamptz'
262
- THEN (a #>> '{}')::timestamptz = (b #>> '{}')::timestamptz
263
- ELSE _delta_same(a, b)
264
- END;
265
- $$;
266
-
267
- -- the framework's, until dzql's compiler (`compileLedger`) writes each
268
- -- collection's time fields in
257
+ -- generateSql writes each collection's time fields in (compileLedger); before
258
+ -- it is applied there is no collection, and values are the same as JSON.
269
259
  CREATE OR REPLACE FUNCTION _delta_same(p_coll TEXT, p_field TEXT, a JSONB, b JSONB)
270
- RETURNS BOOLEAN LANGUAGE sql STABLE AS $$ SELECT _delta_same_framework(p_coll, p_field, a, b); $$;
260
+ RETURNS BOOLEAN LANGUAGE sql STABLE AS $$ SELECT _delta_same(a, b); $$;
271
261
 
272
262
  -- _delta_row_standing: row `p_id` of a collection as it stands, without its
273
263
  -- validity, as {row} (row null: not there); NULL for a collection there is not.
274
- -- What a walk guards a row beyond its document by.
275
- CREATE OR REPLACE FUNCTION _delta_row_standing_framework(p_coll TEXT, p_id BIGINT)
276
- RETURNS JSONB AS $$
277
- DECLARE
278
- v_coll RECORD;
279
- v_row JSONB;
280
- BEGIN
281
- SELECT * INTO v_coll FROM _delta_collections WHERE collection_key = p_coll;
282
- IF NOT FOUND THEN RETURN NULL; END IF;
283
- EXECUTE format('SELECT _delta_strip_temporal(to_jsonb(t.*)) FROM %I t WHERE t.id = $1', _delta_source_view(v_coll.table_name, v_coll.temporal))
284
- INTO v_row USING p_id;
285
- RETURN jsonb_build_object('row', v_row);
286
- END;
287
- $$ LANGUAGE plpgsql STABLE;
288
-
264
+ -- What a walk guards a row beyond its document by. generateSql writes one for
265
+ -- each collection (compileLedger).
289
266
  CREATE OR REPLACE FUNCTION _delta_row_standing(p_coll TEXT, p_id BIGINT)
290
- RETURNS JSONB LANGUAGE sql STABLE AS $$ SELECT _delta_row_standing_framework(p_coll, p_id); $$;
267
+ RETURNS JSONB LANGUAGE sql STABLE AS $$ SELECT NULL::jsonb; $$;
291
268
 
292
269
  -- _delta_walk_key: a row's key in a walk -- the keyOf of planWalk in
293
270
  -- src/server/ledger.ts. A single document's root is one row at two paths,