From 600ff8b1adf6d4af85ba241c06c90ff5da8d8964 Mon Sep 17 00:00:00 2001 From: Daniel Muller Date: Wed, 25 Feb 2026 15:15:13 -0700 Subject: [PATCH] Expose target table for UPDATE and DELETE queries in plugin proto Add update_table and delete_from_table fields to the Query message in the plugin codegen proto, matching the existing insert_into_table field. The compiler already resolves the target table for UPDATE and DELETE queries internally; this change wires that information through to plugins. Closes #4317 --- internal/cmd/shim.go | 18 +++ internal/compiler/analyze.go | 12 ++ internal/compiler/parse.go | 43 ++++-- internal/compiler/query.go | 6 + .../testdata/codegen_json/gen/codegen.json | 95 ++++++++++++- .../codegen_json/postgresql/query.sql | 4 + .../gen/codegen.json | 20 ++- internal/plugin/codegen.pb.go | 132 +++++++++++------- protos/plugin/codegen.proto | 2 + 9 files changed, 260 insertions(+), 72 deletions(-) diff --git a/internal/cmd/shim.go b/internal/cmd/shim.go index 654500429a..51029894c8 100644 --- a/internal/cmd/shim.go +++ b/internal/cmd/shim.go @@ -152,6 +152,22 @@ func pluginQueries(r *compiler.Result) []*plugin.Query { Name: q.InsertIntoTable.Name, } } + var ut *plugin.Identifier + if q.UpdateTable != nil { + ut = &plugin.Identifier{ + Catalog: q.UpdateTable.Catalog, + Schema: q.UpdateTable.Schema, + Name: q.UpdateTable.Name, + } + } + var dft *plugin.Identifier + if q.DeleteFromTable != nil { + dft = &plugin.Identifier{ + Catalog: q.DeleteFromTable.Catalog, + Schema: q.DeleteFromTable.Schema, + Name: q.DeleteFromTable.Name, + } + } out = append(out, &plugin.Query{ Name: q.Metadata.Name, Cmd: q.Metadata.Cmd, @@ -161,6 +177,8 @@ func pluginQueries(r *compiler.Result) []*plugin.Query { Params: params, Filename: q.Metadata.Filename, InsertIntoTable: iit, + UpdateTable: ut, + DeleteFromTable: dft, }) } return out diff --git a/internal/compiler/analyze.go b/internal/compiler/analyze.go index 0d7d507575..a1a9c5f7d7 100644 --- a/internal/compiler/analyze.go +++ b/internal/compiler/analyze.go @@ -152,6 +152,18 @@ func (c *Compiler) _analyzeQuery(raw *ast.RawStmt, query string, failfast bool) if err := check(err); err != nil { return nil, err } + case *ast.UpdateStmt: + if n.Relations != nil && len(n.Relations.Items) > 0 { + if rv, ok := n.Relations.Items[0].(*ast.RangeVar); ok { + table, _ = ParseTableName(rv) + } + } + case *ast.DeleteStmt: + if n.Relations != nil && len(n.Relations.Items) > 0 { + if rv, ok := n.Relations.Items[0].(*ast.RangeVar); ok { + table, _ = ParseTableName(rv) + } + } } if err := check(validate.FuncCall(c.catalog, c.combo, raw)); err != nil { diff --git a/internal/compiler/parse.go b/internal/compiler/parse.go index 751cb3271a..9b50b70695 100644 --- a/internal/compiler/parse.go +++ b/internal/compiler/parse.go @@ -108,10 +108,23 @@ func (c *Compiler) parseQuery(stmt ast.Node, src string, o opts.Parser) (*Query, }) } - // Determine the insert table if applicable + // Determine the target table if applicable var table *ast.TableName - if insert, ok := expandedRaw.Stmt.(*ast.InsertStmt); ok { - table, _ = ParseTableName(insert.Relation) + switch n := expandedRaw.Stmt.(type) { + case *ast.InsertStmt: + table, _ = ParseTableName(n.Relation) + case *ast.UpdateStmt: + if n.Relations != nil && len(n.Relations.Items) > 0 { + if rv, ok := n.Relations.Items[0].(*ast.RangeVar); ok { + table, _ = ParseTableName(rv) + } + } + case *ast.DeleteStmt: + if n.Relations != nil && len(n.Relations.Items) > 0 { + if rv, ok := n.Relations.Items[0].(*ast.RangeVar); ok { + table, _ = ParseTableName(rv) + } + } } anlys = &analysis{ @@ -171,14 +184,22 @@ func (c *Compiler) parseQuery(stmt ast.Node, src string, o opts.Parser) (*Query, md.Comments = comments - return &Query{ - RawStmt: raw, - Metadata: md, - Params: anlys.Parameters, - Columns: anlys.Columns, - SQL: trimmed, - InsertIntoTable: anlys.Table, - }, nil + q := &Query{ + RawStmt: raw, + Metadata: md, + Params: anlys.Parameters, + Columns: anlys.Columns, + SQL: trimmed, + } + switch raw.Stmt.(type) { + case *ast.InsertStmt: + q.InsertIntoTable = anlys.Table + case *ast.UpdateStmt: + q.UpdateTable = anlys.Table + case *ast.DeleteStmt: + q.DeleteFromTable = anlys.Table + } + return q, nil } func rangeVars(root ast.Node) []*ast.RangeVar { diff --git a/internal/compiler/query.go b/internal/compiler/query.go index b3cf9d6154..ec01da3719 100644 --- a/internal/compiler/query.go +++ b/internal/compiler/query.go @@ -51,6 +51,12 @@ type Query struct { // Needed for CopyFrom InsertIntoTable *ast.TableName + // Target table for UPDATE queries + UpdateTable *ast.TableName + + // Target table for DELETE queries + DeleteFromTable *ast.TableName + // Needed for vet RawStmt *ast.RawStmt } diff --git a/internal/endtoend/testdata/codegen_json/gen/codegen.json b/internal/endtoend/testdata/codegen_json/gen/codegen.json index 754d2af289..6f2900658f 100644 --- a/internal/endtoend/testdata/codegen_json/gen/codegen.json +++ b/internal/endtoend/testdata/codegen_json/gen/codegen.json @@ -65079,7 +65079,9 @@ ], "comments": [], "filename": "query.sql", - "insert_into_table": null + "insert_into_table": null, + "update_table": null, + "delete_from_table": null }, { "text": "SELECT id, name, bio FROM authors\nORDER BY name", @@ -65168,7 +65170,9 @@ "params": [], "comments": [], "filename": "query.sql", - "insert_into_table": null + "insert_into_table": null, + "update_table": null, + "delete_from_table": null }, { "text": "INSERT INTO authors (\n name, bio\n) VALUES (\n $1, $2\n)\nRETURNING id, name, bio", @@ -65320,7 +65324,84 @@ "catalog": "", "schema": "", "name": "authors" - } + }, + "update_table": null, + "delete_from_table": null + }, + { + "text": "UPDATE authors SET bio = $1\nWHERE id = $2", + "name": "UpdateAuthorBio", + "cmd": ":exec", + "columns": [], + "params": [ + { + "number": 1, + "column": { + "name": "bio", + "not_null": false, + "is_array": false, + "comment": "", + "length": -1, + "is_named_param": false, + "is_func_call": false, + "scope": "", + "table": { + "catalog": "", + "schema": "public", + "name": "authors" + }, + "table_alias": "", + "type": { + "catalog": "", + "schema": "", + "name": "text" + }, + "is_sqlc_slice": false, + "embed_table": null, + "original_name": "bio", + "unsigned": false, + "array_dims": 0 + } + }, + { + "number": 2, + "column": { + "name": "id", + "not_null": true, + "is_array": false, + "comment": "", + "length": -1, + "is_named_param": false, + "is_func_call": false, + "scope": "", + "table": { + "catalog": "", + "schema": "", + "name": "authors" + }, + "table_alias": "", + "type": { + "catalog": "", + "schema": "", + "name": "bigserial" + }, + "is_sqlc_slice": false, + "embed_table": null, + "original_name": "id", + "unsigned": false, + "array_dims": 0 + } + } + ], + "comments": [], + "filename": "query.sql", + "insert_into_table": null, + "update_table": { + "catalog": "", + "schema": "", + "name": "authors" + }, + "delete_from_table": null }, { "text": "DELETE FROM authors\nWHERE id = $1", @@ -65360,7 +65441,13 @@ ], "comments": [], "filename": "query.sql", - "insert_into_table": null + "insert_into_table": null, + "update_table": null, + "delete_from_table": { + "catalog": "", + "schema": "", + "name": "authors" + } } ], "sqlc_version": "v1.30.0", diff --git a/internal/endtoend/testdata/codegen_json/postgresql/query.sql b/internal/endtoend/testdata/codegen_json/postgresql/query.sql index 75e38b2caf..2abeaead0f 100644 --- a/internal/endtoend/testdata/codegen_json/postgresql/query.sql +++ b/internal/endtoend/testdata/codegen_json/postgresql/query.sql @@ -14,6 +14,10 @@ INSERT INTO authors ( ) RETURNING *; +-- name: UpdateAuthorBio :exec +UPDATE authors SET bio = $1 +WHERE id = $2; + -- name: DeleteAuthor :exec DELETE FROM authors WHERE id = $1; diff --git a/internal/endtoend/testdata/process_plugin_sqlc_gen_json/gen/codegen.json b/internal/endtoend/testdata/process_plugin_sqlc_gen_json/gen/codegen.json index 0c7282ac9c..157f35b648 100644 --- a/internal/endtoend/testdata/process_plugin_sqlc_gen_json/gen/codegen.json +++ b/internal/endtoend/testdata/process_plugin_sqlc_gen_json/gen/codegen.json @@ -65081,7 +65081,9 @@ ], "comments": [], "filename": "query.sql", - "insert_into_table": null + "insert_into_table": null, + "update_table": null, + "delete_from_table": null }, { "text": "SELECT id, name, bio FROM authors\nORDER BY name", @@ -65170,7 +65172,9 @@ "params": [], "comments": [], "filename": "query.sql", - "insert_into_table": null + "insert_into_table": null, + "update_table": null, + "delete_from_table": null }, { "text": "INSERT INTO authors (\n name, bio\n) VALUES (\n $1, $2\n)\nRETURNING id, name, bio", @@ -65322,7 +65326,9 @@ "catalog": "", "schema": "", "name": "authors" - } + }, + "update_table": null, + "delete_from_table": null }, { "text": "DELETE FROM authors\nWHERE id = $1", @@ -65362,7 +65368,13 @@ ], "comments": [], "filename": "query.sql", - "insert_into_table": null + "insert_into_table": null, + "update_table": null, + "delete_from_table": { + "catalog": "", + "schema": "", + "name": "authors" + } } ], "sqlc_version": "v1.30.0", diff --git a/internal/plugin/codegen.pb.go b/internal/plugin/codegen.pb.go index 525ffc72ef..44568bcc17 100644 --- a/internal/plugin/codegen.pb.go +++ b/internal/plugin/codegen.pb.go @@ -816,6 +816,8 @@ type Query struct { Comments []string `protobuf:"bytes,6,rep,name=comments,proto3" json:"comments,omitempty"` Filename string `protobuf:"bytes,7,opt,name=filename,proto3" json:"filename,omitempty"` InsertIntoTable *Identifier `protobuf:"bytes,8,opt,name=insert_into_table,proto3" json:"insert_into_table,omitempty"` + UpdateTable *Identifier `protobuf:"bytes,9,opt,name=update_table,proto3" json:"update_table,omitempty"` + DeleteFromTable *Identifier `protobuf:"bytes,10,opt,name=delete_from_table,proto3" json:"delete_from_table,omitempty"` } func (x *Query) Reset() { @@ -906,6 +908,20 @@ func (x *Query) GetInsertIntoTable() *Identifier { return nil } +func (x *Query) GetUpdateTable() *Identifier { + if x != nil { + return x.UpdateTable + } + return nil +} + +func (x *Query) GetDeleteFromTable() *Identifier { + if x != nil { + return x.DeleteFromTable + } + return nil +} + type Parameter struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1308,8 +1324,8 @@ var file_plugin_codegen_proto_rawDesc = []byte{ 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5f, 0x64, 0x69, 0x6d, 0x73, 0x18, 0x11, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x09, 0x61, 0x72, 0x72, 0x61, 0x79, 0x44, 0x69, 0x6d, 0x73, 0x22, 0x94, - 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, + 0x01, 0x28, 0x05, 0x52, 0x09, 0x61, 0x72, 0x72, 0x61, 0x79, 0x44, 0x69, 0x6d, 0x73, 0x22, 0x8e, + 0x03, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, @@ -1326,45 +1342,53 @@ var file_plugin_codegen_proto_rawDesc = []byte{ 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x6f, 0x5f, - 0x74, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x4b, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, - 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x06, 0x63, 0x6f, - 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, - 0x6d, 0x6e, 0x22, 0x87, 0x02, 0x0a, 0x0f, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, - 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, - 0x27, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, - 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, - 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x0e, - 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, - 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x36, 0x0a, 0x10, - 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, - 0x69, 0x6c, 0x65, 0x73, 0x32, 0x4f, 0x0a, 0x0e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x08, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, - 0x74, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x65, 0x6e, 0x65, - 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x7c, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x42, 0x0c, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x73, 0x71, 0x6c, 0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xa2, 0x02, 0x03, - 0x50, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xca, 0x02, 0x06, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xe2, 0x02, 0x12, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5c, 0x47, - 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x06, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x36, 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, + 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, + 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x40, 0x0a, + 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x74, 0x61, 0x62, + 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x64, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x22, + 0x4b, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, + 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, + 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x22, 0x87, 0x02, 0x0a, + 0x0f, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x2c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x29, + 0x0a, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, + 0x52, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x27, 0x0a, 0x07, 0x71, 0x75, 0x65, + 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, + 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, + 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, + 0x0a, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x6f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x36, 0x0a, 0x10, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, + 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, + 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x32, 0x4f, + 0x0a, 0x0e, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x3d, 0x0a, 0x08, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x12, 0x17, 0x2e, 0x70, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, + 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x7c, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x42, 0x0c, 0x43, + 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2d, 0x64, + 0x65, 0x76, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x58, 0x58, 0xaa, 0x02, 0x06, + 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xca, 0x02, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xe2, + 0x02, 0x12, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1414,18 +1438,20 @@ var file_plugin_codegen_proto_depIdxs = []int32{ 9, // 12: plugin.Query.columns:type_name -> plugin.Column 11, // 13: plugin.Query.params:type_name -> plugin.Parameter 8, // 14: plugin.Query.insert_into_table:type_name -> plugin.Identifier - 9, // 15: plugin.Parameter.column:type_name -> plugin.Column - 1, // 16: plugin.GenerateRequest.settings:type_name -> plugin.Settings - 3, // 17: plugin.GenerateRequest.catalog:type_name -> plugin.Catalog - 10, // 18: plugin.GenerateRequest.queries:type_name -> plugin.Query - 0, // 19: plugin.GenerateResponse.files:type_name -> plugin.File - 12, // 20: plugin.CodegenService.Generate:input_type -> plugin.GenerateRequest - 13, // 21: plugin.CodegenService.Generate:output_type -> plugin.GenerateResponse - 21, // [21:22] is the sub-list for method output_type - 20, // [20:21] is the sub-list for method input_type - 20, // [20:20] is the sub-list for extension type_name - 20, // [20:20] is the sub-list for extension extendee - 0, // [0:20] is the sub-list for field type_name + 8, // 15: plugin.Query.update_table:type_name -> plugin.Identifier + 8, // 16: plugin.Query.delete_from_table:type_name -> plugin.Identifier + 9, // 17: plugin.Parameter.column:type_name -> plugin.Column + 1, // 18: plugin.GenerateRequest.settings:type_name -> plugin.Settings + 3, // 19: plugin.GenerateRequest.catalog:type_name -> plugin.Catalog + 10, // 20: plugin.GenerateRequest.queries:type_name -> plugin.Query + 0, // 21: plugin.GenerateResponse.files:type_name -> plugin.File + 12, // 22: plugin.CodegenService.Generate:input_type -> plugin.GenerateRequest + 13, // 23: plugin.CodegenService.Generate:output_type -> plugin.GenerateResponse + 23, // [23:24] is the sub-list for method output_type + 22, // [22:23] is the sub-list for method input_type + 22, // [22:22] is the sub-list for extension type_name + 22, // [22:22] is the sub-list for extension extendee + 0, // [0:22] is the sub-list for field type_name } func init() { file_plugin_codegen_proto_init() } diff --git a/protos/plugin/codegen.proto b/protos/plugin/codegen.proto index e6faf19bad..68f452ec16 100644 --- a/protos/plugin/codegen.proto +++ b/protos/plugin/codegen.proto @@ -111,6 +111,8 @@ message Query { repeated string comments = 6 [json_name = "comments"]; string filename = 7 [json_name = "filename"]; Identifier insert_into_table = 8 [json_name = "insert_into_table"]; + Identifier update_table = 9 [json_name = "update_table"]; + Identifier delete_from_table = 10 [json_name = "delete_from_table"]; } message Parameter {