Skip to content

Feature Request: Expose target table for UPDATE and DELETE queries in plugin proto #4317

@mrmeku

Description

@mrmeku

What do you want to change?

The Query message in plugin/codegen.proto has an InsertIntoTable field that gives plugins the parsed target table for INSERT statements. However, there is no equivalent for UPDATE or DELETE queries. That makes me sad! I'd love to be able to know what table is being updated or deleted

Meanwhile, sqlc's compiler already resolves the target table for UPDATE and DELETE internally — it needs to in order to resolve column types in SET clauses and WHERE conditions. The information exists; it's just not wired through to the plugin interface.

Proposed Change

Add two fields to the Query message in protos/plugin/codegen.proto:
protobufmessage Query {
...
Identifier update_table = 9; // new
Identifier delete_from_table = 10; // new
}
These would be populated the same way insert_into_table is — set when the query type is UPDATE or DELETE respectively, nil otherwise.

What database engines need to be changed?

No response

What programming language backends need to be changed?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions