no local cursor rules
This commit is contained in:
@@ -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.
|
||||
Reference in New Issue
Block a user