Skip to content

Commit 2cc7e92

Browse files
[#44] Use INNER JOIN in refs_view
The refs property_path/property_type ids are always populated and their lookup rows written in the same transaction, so the joins always match. INNER JOIN expresses that invariant and removes the theoretical NULL that LEFT JOIN implied, making find-refs' property_path read unconditionally safe.
1 parent ec18914 commit 2cc7e92

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Analyzer/Resources/Init.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ CREATE TABLE IF NOT EXISTS refs
5858

5959
-- Reproduces the pre-normalization refs shape (property_path/property_type as text)
6060
-- so queries can read the strings without joining the lookup tables by hand.
61+
-- INNER JOIN: every refs row is written with both ids present and their lookup rows
62+
-- inserted in the same transaction, so the joins always match (the ids are foreign keys).
6163
CREATE VIEW refs_view AS
6264
SELECT r.object, r.referenced_object, pn.name AS property_path, pt.name AS property_type
6365
FROM refs r
64-
LEFT JOIN property_names pn ON r.property_path = pn.id
65-
LEFT JOIN property_types pt ON r.property_type = pt.id;
66+
INNER JOIN property_names pn ON r.property_path = pn.id
67+
INNER JOIN property_types pt ON r.property_type = pt.id;
6668

6769
CREATE VIEW object_view AS
6870
SELECT o.id, o.object_id, ab.name AS asset_bundle, sf.name AS serialized_file, t.name AS type, o.name, o.game_object, o.size,

0 commit comments

Comments
 (0)