diff --git a/.cursor/rules/sql-rules.mdc b/.cursor/rules/sql-rules.mdc deleted file mode 100644 index 865d1ba..0000000 --- a/.cursor/rules/sql-rules.mdc +++ /dev/null @@ -1,39 +0,0 @@ ---- -description: SQL conventions — no table aliases; columns are always prefixed -globs: "**/*.{js,sql,php}" -alwaysApply: false ---- - -# SQL rules - -All tables use **prefixed column names** (`sim_uuid`, `own_usr_id`, `usr_uuid`, `ekfs_agent_id`, …). There is never column ambiguity across joins, so **do not use table aliases**. - -## Do not - -- Short table aliases: `s`, `o`, `u`, `ekfs`, etc. -- Qualified columns when an alias was the only reason: `s.sim_uuid`, `o.own_sim_uuid` - -## Do - -- Join on bare prefixed column names. -- Use full table names (or `${qualified}` template vars) in `FROM` / `JOIN` only — no alias after the table. - -```sql --- BAD -SELECT s.sim_name, BIN_TO_UUID(s.sim_uuid) AS simulationUuid -FROM `p42SIM`.simulations s -INNER JOIN `p42GUI`.simowners o ON o.own_sim_uuid = s.sim_uuid -INNER JOIN `p42GUI`.users u ON o.own_usr_id = u.usr_id -WHERE u.usr_uuid = ? AND s.sim_uuid = UUID_TO_BIN(?) - --- GOOD -SELECT sim_name, BIN_TO_UUID(sim_uuid) AS simulationUuid -FROM `p42SIM`.simulations -INNER JOIN `p42GUI`.simowners ON own_sim_uuid = sim_uuid -INNER JOIN `p42GUI`.users ON own_usr_id = usr_id -WHERE usr_uuid = ? AND sim_uuid = UUID_TO_BIN(?) -``` - -`AS` on **result columns** (e.g. `AS simulationUuid` for the API) is fine — that is not a table alias. - -When adding a query, read an existing join in the same repo first and match its style.