Skip to content

JOIN ON inside UPDATE ... FROM and DELETE ... USING is not validated in strict mode #281

Description

@tiagolauer

JOIN ... ON conditions inside UPDATE ... FROM and DELETE ... USING are not validated in strict mode:

StrictRow<DB, 'update users set name = $1 from orders o join refunds r on r.nope = o.id where users.id = o.user_id'>
// Record<string, never> - r.nope accepted silently

Same with delete from users using orders o join refunds r on r.nope = o.id .... The joined sources themselves are registered (returning r.id works in the valid variant), it is only the ON expressions that go unchecked. The README says strict mode checks JOIN ... ON conditions and makes no carve-out for write statements.

Root cause: the UPDATE and DELETE branches hardcode fromText: '' (src/parse.ts:324 and 334), so ApplyWhereCheck's ExtractJoinOnText (src/parse.ts:922-938) never sees their join text. Passing the real FROM/USING clause text through instead of the empty string should close it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions