├── .gitignore ├── Makefile ├── README.md ├── field.go ├── gen.go ├── go.mod ├── go.sum ├── internal ├── metadata │ └── meta.go ├── plugin │ ├── codegen.pb.go │ └── codegen_vtproto.pb.go └── sdk │ ├── sdk.go │ ├── utils.go │ └── utils_test.go ├── main.go ├── protos └── plugin │ └── codegen.proto ├── query.go ├── result.go ├── struct.go ├── template.go ├── templates └── template.tmpl ├── testdata ├── query.sql ├── schema.sql └── sqlc.json └── ts_type.go /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | testdata/gen/ 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | internal/plugin/codegen.pb.go: protos/plugin/codegen.proto 2 | protoc -I ./protos \ 3 | --go_out=. \ 4 | --go_opt=module=github.com/stephen/sqlc-ts \ 5 | --go-vtproto_out=. \ 6 | --go-vtproto_opt=module=github.com/stephen/sqlc-ts,features=marshal+unmarshal+size \ 7 | ./protos/plugin/codegen.proto 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sqlc-ts 2 | 3 | sqlc-ts is a [sqlc plugin](https://docs.sqlc.dev/en/stable/guides/plugins.html) to generate queries that are compatible with [@stephen/sql.js](https://github.com/stephen/sql.js). 4 | 5 | This plugin is early-stage and is not quite production ready. 6 | 7 | ## Installation & Usage 8 | 9 | ```bash 10 | $ go install github.com/kyleconroy/sqlc/cmd/sqlc@latest 11 | $ go install github.com/stephen/sqlc-ts@latest 12 | ``` 13 | 14 | ```json5 15 | // sqlc.json 16 | { 17 | "version": "2", 18 | "plugins": [ 19 | { 20 | "name": "ts", 21 | "process": { 22 | "cmd": "sqlc-ts" 23 | } 24 | } 25 | ], 26 | "sql": [ 27 | { 28 | "schema": "schema.sql", 29 | "queries": "query.sql", 30 | "engine": "sqlite", 31 | "codegen": [ 32 | { 33 | "out": "gen", 34 | "plugin": "ts" 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | ``` 41 | 42 | See `testdata/` for a full example that can be run with: 43 | ```bash 44 | $ sqlc generate -f ./testdata/sqlc.json && cat ./testdata/gen/query.sql.ts | less 45 | ``` 46 | -------------------------------------------------------------------------------- /field.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | type Field struct { 9 | Name string // CamelCased name for Go 10 | DBName string // Name as used in the DB 11 | Type string 12 | TypecheckTemplate string 13 | Comment string 14 | } 15 | 16 | func (f Field) HasTypecheck() bool { 17 | return f.TypecheckTemplate == "" 18 | } 19 | 20 | func (f Field) Typecheck(i int) string { 21 | return strings.ReplaceAll(f.TypecheckTemplate, "%", fmt.Sprintf("row[%d]", i)) 22 | } 23 | 24 | func SetCaseStyle(name string, style string) string { 25 | switch style { 26 | case "camel": 27 | return toCamelCase(name) 28 | case "pascal": 29 | return toPascalCase(name) 30 | case "snake": 31 | return toSnakeCase(name) 32 | default: 33 | panic(fmt.Sprintf("unsupported JSON tags case style: '%s'", style)) 34 | } 35 | } 36 | 37 | func toSnakeCase(s string) string { 38 | return strings.ToLower(s) 39 | } 40 | 41 | func toCamelCase(s string) string { 42 | return toCamelInitCase(s, false) 43 | } 44 | 45 | func toPascalCase(s string) string { 46 | return toCamelInitCase(s, true) 47 | } 48 | 49 | func toCamelInitCase(name string, initUpper bool) string { 50 | out := "" 51 | for i, p := range strings.Split(name, "_") { 52 | if !initUpper && i == 0 { 53 | out += p 54 | continue 55 | } 56 | if p == "id" { 57 | out += "ID" 58 | } else { 59 | out += strings.Title(p) 60 | } 61 | } 62 | return out 63 | } 64 | -------------------------------------------------------------------------------- /gen.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "strings" 7 | "text/template" 8 | 9 | "github.com/pkg/errors" 10 | "github.com/stephen/sqlc-ts/internal/plugin" 11 | "github.com/stephen/sqlc-ts/internal/sdk" 12 | ) 13 | 14 | func Generate(req *plugin.CodeGenRequest) (*plugin.CodeGenResponse, error) { 15 | structs := buildStructs(req) 16 | queries, err := buildQueries(req, structs) 17 | if err != nil { 18 | return nil, errors.Errorf("error generating queries: %w", err) 19 | } 20 | return generate(req, structs, queries) 21 | } 22 | 23 | type tmplCtx struct { 24 | Q string 25 | Structs []Struct 26 | Queries []Query 27 | 28 | // XXX: race 29 | SourceName string 30 | } 31 | 32 | func (t *tmplCtx) OutputQuery(sourceName string) bool { 33 | return t.SourceName == sourceName 34 | } 35 | 36 | func generate(req *plugin.CodeGenRequest, structs []Struct, queries []Query) (*plugin.CodeGenResponse, error) { 37 | funcMap := template.FuncMap{ 38 | "lowerTitle": sdk.LowerTitle, 39 | "comment": sdk.DoubleSlashComment, 40 | "escape": sdk.EscapeBacktick, 41 | "hasPrefix": strings.HasPrefix, 42 | } 43 | 44 | tmpl := template.Must( 45 | template.New("table"). 46 | Funcs(funcMap). 47 | ParseFS( 48 | templates, 49 | "templates/*.tmpl", 50 | ), 51 | ) 52 | 53 | tctx := tmplCtx{ 54 | Q: "`", 55 | Queries: queries, 56 | Structs: structs, 57 | } 58 | 59 | output := map[string]string{} 60 | 61 | execute := func(name, templateName string) error { 62 | var b bytes.Buffer 63 | w := bufio.NewWriter(&b) 64 | tctx.SourceName = name 65 | err := tmpl.ExecuteTemplate(w, templateName, &tctx) 66 | w.Flush() 67 | if err != nil { 68 | return err 69 | } 70 | code := b.Bytes() 71 | if !strings.HasSuffix(name, ".ts") { 72 | name += ".ts" 73 | } 74 | output[name] = string(code) 75 | return nil 76 | } 77 | 78 | files := map[string]struct{}{} 79 | for _, gq := range queries { 80 | files[gq.SourceName] = struct{}{} 81 | } 82 | 83 | for source := range files { 84 | if err := execute(source, "queryFile"); err != nil { 85 | return nil, err 86 | } 87 | } 88 | resp := plugin.CodeGenResponse{} 89 | 90 | for filename, code := range output { 91 | resp.Files = append(resp.Files, &plugin.File{ 92 | Name: filename, 93 | Contents: []byte(code), 94 | }) 95 | } 96 | 97 | return &resp, nil 98 | } 99 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/stephen/sqlc-ts 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/davecgh/go-spew v1.1.1 7 | github.com/jinzhu/inflection v1.0.0 8 | github.com/pkg/errors v0.9.1 9 | google.golang.org/protobuf v1.28.1 10 | ) 11 | 12 | require github.com/google/go-cmp v0.5.9 // indirect 13 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= 4 | github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 5 | github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= 6 | github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 7 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 8 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 9 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 10 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 11 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 12 | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= 13 | google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= 14 | google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 15 | -------------------------------------------------------------------------------- /internal/metadata/meta.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | const ( 4 | CmdExec = ":exec" 5 | CmdExecResult = ":execresult" 6 | CmdExecRows = ":execrows" 7 | CmdMany = ":many" 8 | CmdOne = ":one" 9 | CmdCopyFrom = ":copyfrom" 10 | CmdBatchExec = ":batchexec" 11 | CmdBatchMany = ":batchmany" 12 | CmdBatchOne = ":batchone" 13 | ) 14 | -------------------------------------------------------------------------------- /internal/plugin/codegen.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.27.1 4 | // protoc v3.19.1 5 | // source: plugin/codegen.proto 6 | 7 | package plugin 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type File struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 29 | Contents []byte `protobuf:"bytes,2,opt,name=contents,proto3" json:"contents,omitempty"` 30 | } 31 | 32 | func (x *File) Reset() { 33 | *x = File{} 34 | if protoimpl.UnsafeEnabled { 35 | mi := &file_plugin_codegen_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | } 40 | 41 | func (x *File) String() string { 42 | return protoimpl.X.MessageStringOf(x) 43 | } 44 | 45 | func (*File) ProtoMessage() {} 46 | 47 | func (x *File) ProtoReflect() protoreflect.Message { 48 | mi := &file_plugin_codegen_proto_msgTypes[0] 49 | if protoimpl.UnsafeEnabled && x != nil { 50 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 51 | if ms.LoadMessageInfo() == nil { 52 | ms.StoreMessageInfo(mi) 53 | } 54 | return ms 55 | } 56 | return mi.MessageOf(x) 57 | } 58 | 59 | // Deprecated: Use File.ProtoReflect.Descriptor instead. 60 | func (*File) Descriptor() ([]byte, []int) { 61 | return file_plugin_codegen_proto_rawDescGZIP(), []int{0} 62 | } 63 | 64 | func (x *File) GetName() string { 65 | if x != nil { 66 | return x.Name 67 | } 68 | return "" 69 | } 70 | 71 | func (x *File) GetContents() []byte { 72 | if x != nil { 73 | return x.Contents 74 | } 75 | return nil 76 | } 77 | 78 | type Override struct { 79 | state protoimpl.MessageState 80 | sizeCache protoimpl.SizeCache 81 | unknownFields protoimpl.UnknownFields 82 | 83 | // name of the type to use, e.g. `github.com/segmentio/ksuid.KSUID` or `mymodule.Type` 84 | CodeType string `protobuf:"bytes,1,opt,name=code_type,proto3" json:"code_type,omitempty"` 85 | // name of the type to use, e.g. `text` 86 | DbType string `protobuf:"bytes,3,opt,name=db_type,proto3" json:"db_type,omitempty"` 87 | // True if the override should apply to a nullable database type 88 | Nullable bool `protobuf:"varint,5,opt,name=nullable,proto3" json:"nullable,omitempty"` 89 | // fully qualified name of the column, e.g. `accounts.id` 90 | Column string `protobuf:"bytes,6,opt,name=column,proto3" json:"column,omitempty"` 91 | Table *Identifier `protobuf:"bytes,7,opt,name=table,proto3" json:"table,omitempty"` 92 | ColumnName string `protobuf:"bytes,8,opt,name=column_name,proto3" json:"column_name,omitempty"` 93 | PythonType *PythonType `protobuf:"bytes,9,opt,name=python_type,json=pythonType,proto3" json:"python_type,omitempty"` 94 | GoType *ParsedGoType `protobuf:"bytes,10,opt,name=go_type,json=goType,proto3" json:"go_type,omitempty"` 95 | } 96 | 97 | func (x *Override) Reset() { 98 | *x = Override{} 99 | if protoimpl.UnsafeEnabled { 100 | mi := &file_plugin_codegen_proto_msgTypes[1] 101 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 102 | ms.StoreMessageInfo(mi) 103 | } 104 | } 105 | 106 | func (x *Override) String() string { 107 | return protoimpl.X.MessageStringOf(x) 108 | } 109 | 110 | func (*Override) ProtoMessage() {} 111 | 112 | func (x *Override) ProtoReflect() protoreflect.Message { 113 | mi := &file_plugin_codegen_proto_msgTypes[1] 114 | if protoimpl.UnsafeEnabled && x != nil { 115 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 116 | if ms.LoadMessageInfo() == nil { 117 | ms.StoreMessageInfo(mi) 118 | } 119 | return ms 120 | } 121 | return mi.MessageOf(x) 122 | } 123 | 124 | // Deprecated: Use Override.ProtoReflect.Descriptor instead. 125 | func (*Override) Descriptor() ([]byte, []int) { 126 | return file_plugin_codegen_proto_rawDescGZIP(), []int{1} 127 | } 128 | 129 | func (x *Override) GetCodeType() string { 130 | if x != nil { 131 | return x.CodeType 132 | } 133 | return "" 134 | } 135 | 136 | func (x *Override) GetDbType() string { 137 | if x != nil { 138 | return x.DbType 139 | } 140 | return "" 141 | } 142 | 143 | func (x *Override) GetNullable() bool { 144 | if x != nil { 145 | return x.Nullable 146 | } 147 | return false 148 | } 149 | 150 | func (x *Override) GetColumn() string { 151 | if x != nil { 152 | return x.Column 153 | } 154 | return "" 155 | } 156 | 157 | func (x *Override) GetTable() *Identifier { 158 | if x != nil { 159 | return x.Table 160 | } 161 | return nil 162 | } 163 | 164 | func (x *Override) GetColumnName() string { 165 | if x != nil { 166 | return x.ColumnName 167 | } 168 | return "" 169 | } 170 | 171 | func (x *Override) GetPythonType() *PythonType { 172 | if x != nil { 173 | return x.PythonType 174 | } 175 | return nil 176 | } 177 | 178 | func (x *Override) GetGoType() *ParsedGoType { 179 | if x != nil { 180 | return x.GoType 181 | } 182 | return nil 183 | } 184 | 185 | type PythonType struct { 186 | state protoimpl.MessageState 187 | sizeCache protoimpl.SizeCache 188 | unknownFields protoimpl.UnknownFields 189 | 190 | Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` 191 | Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` 192 | } 193 | 194 | func (x *PythonType) Reset() { 195 | *x = PythonType{} 196 | if protoimpl.UnsafeEnabled { 197 | mi := &file_plugin_codegen_proto_msgTypes[2] 198 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 199 | ms.StoreMessageInfo(mi) 200 | } 201 | } 202 | 203 | func (x *PythonType) String() string { 204 | return protoimpl.X.MessageStringOf(x) 205 | } 206 | 207 | func (*PythonType) ProtoMessage() {} 208 | 209 | func (x *PythonType) ProtoReflect() protoreflect.Message { 210 | mi := &file_plugin_codegen_proto_msgTypes[2] 211 | if protoimpl.UnsafeEnabled && x != nil { 212 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 213 | if ms.LoadMessageInfo() == nil { 214 | ms.StoreMessageInfo(mi) 215 | } 216 | return ms 217 | } 218 | return mi.MessageOf(x) 219 | } 220 | 221 | // Deprecated: Use PythonType.ProtoReflect.Descriptor instead. 222 | func (*PythonType) Descriptor() ([]byte, []int) { 223 | return file_plugin_codegen_proto_rawDescGZIP(), []int{2} 224 | } 225 | 226 | func (x *PythonType) GetModule() string { 227 | if x != nil { 228 | return x.Module 229 | } 230 | return "" 231 | } 232 | 233 | func (x *PythonType) GetName() string { 234 | if x != nil { 235 | return x.Name 236 | } 237 | return "" 238 | } 239 | 240 | type ParsedGoType struct { 241 | state protoimpl.MessageState 242 | sizeCache protoimpl.SizeCache 243 | unknownFields protoimpl.UnknownFields 244 | 245 | ImportPath string `protobuf:"bytes,1,opt,name=import_path,json=importPath,proto3" json:"import_path,omitempty"` 246 | Package string `protobuf:"bytes,2,opt,name=package,proto3" json:"package,omitempty"` 247 | TypeName string `protobuf:"bytes,3,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` 248 | BasicType bool `protobuf:"varint,4,opt,name=basic_type,json=basicType,proto3" json:"basic_type,omitempty"` 249 | } 250 | 251 | func (x *ParsedGoType) Reset() { 252 | *x = ParsedGoType{} 253 | if protoimpl.UnsafeEnabled { 254 | mi := &file_plugin_codegen_proto_msgTypes[3] 255 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 256 | ms.StoreMessageInfo(mi) 257 | } 258 | } 259 | 260 | func (x *ParsedGoType) String() string { 261 | return protoimpl.X.MessageStringOf(x) 262 | } 263 | 264 | func (*ParsedGoType) ProtoMessage() {} 265 | 266 | func (x *ParsedGoType) ProtoReflect() protoreflect.Message { 267 | mi := &file_plugin_codegen_proto_msgTypes[3] 268 | if protoimpl.UnsafeEnabled && x != nil { 269 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 270 | if ms.LoadMessageInfo() == nil { 271 | ms.StoreMessageInfo(mi) 272 | } 273 | return ms 274 | } 275 | return mi.MessageOf(x) 276 | } 277 | 278 | // Deprecated: Use ParsedGoType.ProtoReflect.Descriptor instead. 279 | func (*ParsedGoType) Descriptor() ([]byte, []int) { 280 | return file_plugin_codegen_proto_rawDescGZIP(), []int{3} 281 | } 282 | 283 | func (x *ParsedGoType) GetImportPath() string { 284 | if x != nil { 285 | return x.ImportPath 286 | } 287 | return "" 288 | } 289 | 290 | func (x *ParsedGoType) GetPackage() string { 291 | if x != nil { 292 | return x.Package 293 | } 294 | return "" 295 | } 296 | 297 | func (x *ParsedGoType) GetTypeName() string { 298 | if x != nil { 299 | return x.TypeName 300 | } 301 | return "" 302 | } 303 | 304 | func (x *ParsedGoType) GetBasicType() bool { 305 | if x != nil { 306 | return x.BasicType 307 | } 308 | return false 309 | } 310 | 311 | type Settings struct { 312 | state protoimpl.MessageState 313 | sizeCache protoimpl.SizeCache 314 | unknownFields protoimpl.UnknownFields 315 | 316 | Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` 317 | Engine string `protobuf:"bytes,2,opt,name=engine,proto3" json:"engine,omitempty"` 318 | Schema []string `protobuf:"bytes,3,rep,name=schema,proto3" json:"schema,omitempty"` 319 | Queries []string `protobuf:"bytes,4,rep,name=queries,proto3" json:"queries,omitempty"` 320 | Rename map[string]string `protobuf:"bytes,5,rep,name=rename,proto3" json:"rename,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` 321 | Overrides []*Override `protobuf:"bytes,6,rep,name=overrides,proto3" json:"overrides,omitempty"` 322 | // TODO: Refactor codegen settings 323 | Python *PythonCode `protobuf:"bytes,8,opt,name=python,proto3" json:"python,omitempty"` 324 | Kotlin *KotlinCode `protobuf:"bytes,9,opt,name=kotlin,proto3" json:"kotlin,omitempty"` 325 | Go *GoCode `protobuf:"bytes,10,opt,name=go,proto3" json:"go,omitempty"` 326 | } 327 | 328 | func (x *Settings) Reset() { 329 | *x = Settings{} 330 | if protoimpl.UnsafeEnabled { 331 | mi := &file_plugin_codegen_proto_msgTypes[4] 332 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 333 | ms.StoreMessageInfo(mi) 334 | } 335 | } 336 | 337 | func (x *Settings) String() string { 338 | return protoimpl.X.MessageStringOf(x) 339 | } 340 | 341 | func (*Settings) ProtoMessage() {} 342 | 343 | func (x *Settings) ProtoReflect() protoreflect.Message { 344 | mi := &file_plugin_codegen_proto_msgTypes[4] 345 | if protoimpl.UnsafeEnabled && x != nil { 346 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 347 | if ms.LoadMessageInfo() == nil { 348 | ms.StoreMessageInfo(mi) 349 | } 350 | return ms 351 | } 352 | return mi.MessageOf(x) 353 | } 354 | 355 | // Deprecated: Use Settings.ProtoReflect.Descriptor instead. 356 | func (*Settings) Descriptor() ([]byte, []int) { 357 | return file_plugin_codegen_proto_rawDescGZIP(), []int{4} 358 | } 359 | 360 | func (x *Settings) GetVersion() string { 361 | if x != nil { 362 | return x.Version 363 | } 364 | return "" 365 | } 366 | 367 | func (x *Settings) GetEngine() string { 368 | if x != nil { 369 | return x.Engine 370 | } 371 | return "" 372 | } 373 | 374 | func (x *Settings) GetSchema() []string { 375 | if x != nil { 376 | return x.Schema 377 | } 378 | return nil 379 | } 380 | 381 | func (x *Settings) GetQueries() []string { 382 | if x != nil { 383 | return x.Queries 384 | } 385 | return nil 386 | } 387 | 388 | func (x *Settings) GetRename() map[string]string { 389 | if x != nil { 390 | return x.Rename 391 | } 392 | return nil 393 | } 394 | 395 | func (x *Settings) GetOverrides() []*Override { 396 | if x != nil { 397 | return x.Overrides 398 | } 399 | return nil 400 | } 401 | 402 | func (x *Settings) GetPython() *PythonCode { 403 | if x != nil { 404 | return x.Python 405 | } 406 | return nil 407 | } 408 | 409 | func (x *Settings) GetKotlin() *KotlinCode { 410 | if x != nil { 411 | return x.Kotlin 412 | } 413 | return nil 414 | } 415 | 416 | func (x *Settings) GetGo() *GoCode { 417 | if x != nil { 418 | return x.Go 419 | } 420 | return nil 421 | } 422 | 423 | type PythonCode struct { 424 | state protoimpl.MessageState 425 | sizeCache protoimpl.SizeCache 426 | unknownFields protoimpl.UnknownFields 427 | 428 | EmitExactTableNames bool `protobuf:"varint,1,opt,name=emit_exact_table_names,json=emitExactTableNames,proto3" json:"emit_exact_table_names,omitempty"` 429 | EmitSyncQuerier bool `protobuf:"varint,2,opt,name=emit_sync_querier,json=emitSyncQuerier,proto3" json:"emit_sync_querier,omitempty"` 430 | EmitAsyncQuerier bool `protobuf:"varint,3,opt,name=emit_async_querier,json=emitAsyncQuerier,proto3" json:"emit_async_querier,omitempty"` 431 | Package string `protobuf:"bytes,4,opt,name=package,proto3" json:"package,omitempty"` 432 | Out string `protobuf:"bytes,5,opt,name=out,proto3" json:"out,omitempty"` 433 | } 434 | 435 | func (x *PythonCode) Reset() { 436 | *x = PythonCode{} 437 | if protoimpl.UnsafeEnabled { 438 | mi := &file_plugin_codegen_proto_msgTypes[5] 439 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 440 | ms.StoreMessageInfo(mi) 441 | } 442 | } 443 | 444 | func (x *PythonCode) String() string { 445 | return protoimpl.X.MessageStringOf(x) 446 | } 447 | 448 | func (*PythonCode) ProtoMessage() {} 449 | 450 | func (x *PythonCode) ProtoReflect() protoreflect.Message { 451 | mi := &file_plugin_codegen_proto_msgTypes[5] 452 | if protoimpl.UnsafeEnabled && x != nil { 453 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 454 | if ms.LoadMessageInfo() == nil { 455 | ms.StoreMessageInfo(mi) 456 | } 457 | return ms 458 | } 459 | return mi.MessageOf(x) 460 | } 461 | 462 | // Deprecated: Use PythonCode.ProtoReflect.Descriptor instead. 463 | func (*PythonCode) Descriptor() ([]byte, []int) { 464 | return file_plugin_codegen_proto_rawDescGZIP(), []int{5} 465 | } 466 | 467 | func (x *PythonCode) GetEmitExactTableNames() bool { 468 | if x != nil { 469 | return x.EmitExactTableNames 470 | } 471 | return false 472 | } 473 | 474 | func (x *PythonCode) GetEmitSyncQuerier() bool { 475 | if x != nil { 476 | return x.EmitSyncQuerier 477 | } 478 | return false 479 | } 480 | 481 | func (x *PythonCode) GetEmitAsyncQuerier() bool { 482 | if x != nil { 483 | return x.EmitAsyncQuerier 484 | } 485 | return false 486 | } 487 | 488 | func (x *PythonCode) GetPackage() string { 489 | if x != nil { 490 | return x.Package 491 | } 492 | return "" 493 | } 494 | 495 | func (x *PythonCode) GetOut() string { 496 | if x != nil { 497 | return x.Out 498 | } 499 | return "" 500 | } 501 | 502 | type KotlinCode struct { 503 | state protoimpl.MessageState 504 | sizeCache protoimpl.SizeCache 505 | unknownFields protoimpl.UnknownFields 506 | 507 | EmitExactTableNames bool `protobuf:"varint,1,opt,name=emit_exact_table_names,json=emitExactTableNames,proto3" json:"emit_exact_table_names,omitempty"` 508 | Package string `protobuf:"bytes,2,opt,name=package,proto3" json:"package,omitempty"` 509 | Out string `protobuf:"bytes,3,opt,name=out,proto3" json:"out,omitempty"` 510 | } 511 | 512 | func (x *KotlinCode) Reset() { 513 | *x = KotlinCode{} 514 | if protoimpl.UnsafeEnabled { 515 | mi := &file_plugin_codegen_proto_msgTypes[6] 516 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 517 | ms.StoreMessageInfo(mi) 518 | } 519 | } 520 | 521 | func (x *KotlinCode) String() string { 522 | return protoimpl.X.MessageStringOf(x) 523 | } 524 | 525 | func (*KotlinCode) ProtoMessage() {} 526 | 527 | func (x *KotlinCode) ProtoReflect() protoreflect.Message { 528 | mi := &file_plugin_codegen_proto_msgTypes[6] 529 | if protoimpl.UnsafeEnabled && x != nil { 530 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 531 | if ms.LoadMessageInfo() == nil { 532 | ms.StoreMessageInfo(mi) 533 | } 534 | return ms 535 | } 536 | return mi.MessageOf(x) 537 | } 538 | 539 | // Deprecated: Use KotlinCode.ProtoReflect.Descriptor instead. 540 | func (*KotlinCode) Descriptor() ([]byte, []int) { 541 | return file_plugin_codegen_proto_rawDescGZIP(), []int{6} 542 | } 543 | 544 | func (x *KotlinCode) GetEmitExactTableNames() bool { 545 | if x != nil { 546 | return x.EmitExactTableNames 547 | } 548 | return false 549 | } 550 | 551 | func (x *KotlinCode) GetPackage() string { 552 | if x != nil { 553 | return x.Package 554 | } 555 | return "" 556 | } 557 | 558 | func (x *KotlinCode) GetOut() string { 559 | if x != nil { 560 | return x.Out 561 | } 562 | return "" 563 | } 564 | 565 | type GoCode struct { 566 | state protoimpl.MessageState 567 | sizeCache protoimpl.SizeCache 568 | unknownFields protoimpl.UnknownFields 569 | 570 | EmitInterface bool `protobuf:"varint,1,opt,name=emit_interface,json=emitInterface,proto3" json:"emit_interface,omitempty"` 571 | EmitJsonTags bool `protobuf:"varint,2,opt,name=emit_json_tags,json=emitJsonTags,proto3" json:"emit_json_tags,omitempty"` 572 | EmitDbTags bool `protobuf:"varint,3,opt,name=emit_db_tags,json=emitDbTags,proto3" json:"emit_db_tags,omitempty"` 573 | EmitPreparedQueries bool `protobuf:"varint,4,opt,name=emit_prepared_queries,json=emitPreparedQueries,proto3" json:"emit_prepared_queries,omitempty"` 574 | EmitExactTableNames bool `protobuf:"varint,5,opt,name=emit_exact_table_names,json=emitExactTableNames,proto3" json:"emit_exact_table_names,omitempty"` 575 | EmitEmptySlices bool `protobuf:"varint,6,opt,name=emit_empty_slices,json=emitEmptySlices,proto3" json:"emit_empty_slices,omitempty"` 576 | EmitExportedQueries bool `protobuf:"varint,7,opt,name=emit_exported_queries,json=emitExportedQueries,proto3" json:"emit_exported_queries,omitempty"` 577 | EmitResultStructPointers bool `protobuf:"varint,8,opt,name=emit_result_struct_pointers,json=emitResultStructPointers,proto3" json:"emit_result_struct_pointers,omitempty"` 578 | EmitParamsStructPointers bool `protobuf:"varint,9,opt,name=emit_params_struct_pointers,json=emitParamsStructPointers,proto3" json:"emit_params_struct_pointers,omitempty"` 579 | EmitMethodsWithDbArgument bool `protobuf:"varint,10,opt,name=emit_methods_with_db_argument,json=emitMethodsWithDbArgument,proto3" json:"emit_methods_with_db_argument,omitempty"` 580 | JsonTagsCaseStyle string `protobuf:"bytes,11,opt,name=json_tags_case_style,json=jsonTagsCaseStyle,proto3" json:"json_tags_case_style,omitempty"` 581 | Package string `protobuf:"bytes,12,opt,name=package,proto3" json:"package,omitempty"` 582 | Out string `protobuf:"bytes,13,opt,name=out,proto3" json:"out,omitempty"` 583 | SqlPackage string `protobuf:"bytes,14,opt,name=sql_package,json=sqlPackage,proto3" json:"sql_package,omitempty"` 584 | OutputDbFileName string `protobuf:"bytes,15,opt,name=output_db_file_name,json=outputDbFileName,proto3" json:"output_db_file_name,omitempty"` 585 | OutputModelsFileName string `protobuf:"bytes,16,opt,name=output_models_file_name,json=outputModelsFileName,proto3" json:"output_models_file_name,omitempty"` 586 | OutputQuerierFileName string `protobuf:"bytes,17,opt,name=output_querier_file_name,json=outputQuerierFileName,proto3" json:"output_querier_file_name,omitempty"` 587 | OutputFilesSuffix string `protobuf:"bytes,18,opt,name=output_files_suffix,json=outputFilesSuffix,proto3" json:"output_files_suffix,omitempty"` 588 | } 589 | 590 | func (x *GoCode) Reset() { 591 | *x = GoCode{} 592 | if protoimpl.UnsafeEnabled { 593 | mi := &file_plugin_codegen_proto_msgTypes[7] 594 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 595 | ms.StoreMessageInfo(mi) 596 | } 597 | } 598 | 599 | func (x *GoCode) String() string { 600 | return protoimpl.X.MessageStringOf(x) 601 | } 602 | 603 | func (*GoCode) ProtoMessage() {} 604 | 605 | func (x *GoCode) ProtoReflect() protoreflect.Message { 606 | mi := &file_plugin_codegen_proto_msgTypes[7] 607 | if protoimpl.UnsafeEnabled && x != nil { 608 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 609 | if ms.LoadMessageInfo() == nil { 610 | ms.StoreMessageInfo(mi) 611 | } 612 | return ms 613 | } 614 | return mi.MessageOf(x) 615 | } 616 | 617 | // Deprecated: Use GoCode.ProtoReflect.Descriptor instead. 618 | func (*GoCode) Descriptor() ([]byte, []int) { 619 | return file_plugin_codegen_proto_rawDescGZIP(), []int{7} 620 | } 621 | 622 | func (x *GoCode) GetEmitInterface() bool { 623 | if x != nil { 624 | return x.EmitInterface 625 | } 626 | return false 627 | } 628 | 629 | func (x *GoCode) GetEmitJsonTags() bool { 630 | if x != nil { 631 | return x.EmitJsonTags 632 | } 633 | return false 634 | } 635 | 636 | func (x *GoCode) GetEmitDbTags() bool { 637 | if x != nil { 638 | return x.EmitDbTags 639 | } 640 | return false 641 | } 642 | 643 | func (x *GoCode) GetEmitPreparedQueries() bool { 644 | if x != nil { 645 | return x.EmitPreparedQueries 646 | } 647 | return false 648 | } 649 | 650 | func (x *GoCode) GetEmitExactTableNames() bool { 651 | if x != nil { 652 | return x.EmitExactTableNames 653 | } 654 | return false 655 | } 656 | 657 | func (x *GoCode) GetEmitEmptySlices() bool { 658 | if x != nil { 659 | return x.EmitEmptySlices 660 | } 661 | return false 662 | } 663 | 664 | func (x *GoCode) GetEmitExportedQueries() bool { 665 | if x != nil { 666 | return x.EmitExportedQueries 667 | } 668 | return false 669 | } 670 | 671 | func (x *GoCode) GetEmitResultStructPointers() bool { 672 | if x != nil { 673 | return x.EmitResultStructPointers 674 | } 675 | return false 676 | } 677 | 678 | func (x *GoCode) GetEmitParamsStructPointers() bool { 679 | if x != nil { 680 | return x.EmitParamsStructPointers 681 | } 682 | return false 683 | } 684 | 685 | func (x *GoCode) GetEmitMethodsWithDbArgument() bool { 686 | if x != nil { 687 | return x.EmitMethodsWithDbArgument 688 | } 689 | return false 690 | } 691 | 692 | func (x *GoCode) GetJsonTagsCaseStyle() string { 693 | if x != nil { 694 | return x.JsonTagsCaseStyle 695 | } 696 | return "" 697 | } 698 | 699 | func (x *GoCode) GetPackage() string { 700 | if x != nil { 701 | return x.Package 702 | } 703 | return "" 704 | } 705 | 706 | func (x *GoCode) GetOut() string { 707 | if x != nil { 708 | return x.Out 709 | } 710 | return "" 711 | } 712 | 713 | func (x *GoCode) GetSqlPackage() string { 714 | if x != nil { 715 | return x.SqlPackage 716 | } 717 | return "" 718 | } 719 | 720 | func (x *GoCode) GetOutputDbFileName() string { 721 | if x != nil { 722 | return x.OutputDbFileName 723 | } 724 | return "" 725 | } 726 | 727 | func (x *GoCode) GetOutputModelsFileName() string { 728 | if x != nil { 729 | return x.OutputModelsFileName 730 | } 731 | return "" 732 | } 733 | 734 | func (x *GoCode) GetOutputQuerierFileName() string { 735 | if x != nil { 736 | return x.OutputQuerierFileName 737 | } 738 | return "" 739 | } 740 | 741 | func (x *GoCode) GetOutputFilesSuffix() string { 742 | if x != nil { 743 | return x.OutputFilesSuffix 744 | } 745 | return "" 746 | } 747 | 748 | type Catalog struct { 749 | state protoimpl.MessageState 750 | sizeCache protoimpl.SizeCache 751 | unknownFields protoimpl.UnknownFields 752 | 753 | Comment string `protobuf:"bytes,1,opt,name=comment,proto3" json:"comment,omitempty"` 754 | DefaultSchema string `protobuf:"bytes,2,opt,name=default_schema,json=defaultSchema,proto3" json:"default_schema,omitempty"` 755 | Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` 756 | Schemas []*Schema `protobuf:"bytes,4,rep,name=schemas,proto3" json:"schemas,omitempty"` 757 | } 758 | 759 | func (x *Catalog) Reset() { 760 | *x = Catalog{} 761 | if protoimpl.UnsafeEnabled { 762 | mi := &file_plugin_codegen_proto_msgTypes[8] 763 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 764 | ms.StoreMessageInfo(mi) 765 | } 766 | } 767 | 768 | func (x *Catalog) String() string { 769 | return protoimpl.X.MessageStringOf(x) 770 | } 771 | 772 | func (*Catalog) ProtoMessage() {} 773 | 774 | func (x *Catalog) ProtoReflect() protoreflect.Message { 775 | mi := &file_plugin_codegen_proto_msgTypes[8] 776 | if protoimpl.UnsafeEnabled && x != nil { 777 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 778 | if ms.LoadMessageInfo() == nil { 779 | ms.StoreMessageInfo(mi) 780 | } 781 | return ms 782 | } 783 | return mi.MessageOf(x) 784 | } 785 | 786 | // Deprecated: Use Catalog.ProtoReflect.Descriptor instead. 787 | func (*Catalog) Descriptor() ([]byte, []int) { 788 | return file_plugin_codegen_proto_rawDescGZIP(), []int{8} 789 | } 790 | 791 | func (x *Catalog) GetComment() string { 792 | if x != nil { 793 | return x.Comment 794 | } 795 | return "" 796 | } 797 | 798 | func (x *Catalog) GetDefaultSchema() string { 799 | if x != nil { 800 | return x.DefaultSchema 801 | } 802 | return "" 803 | } 804 | 805 | func (x *Catalog) GetName() string { 806 | if x != nil { 807 | return x.Name 808 | } 809 | return "" 810 | } 811 | 812 | func (x *Catalog) GetSchemas() []*Schema { 813 | if x != nil { 814 | return x.Schemas 815 | } 816 | return nil 817 | } 818 | 819 | type Schema struct { 820 | state protoimpl.MessageState 821 | sizeCache protoimpl.SizeCache 822 | unknownFields protoimpl.UnknownFields 823 | 824 | Comment string `protobuf:"bytes,1,opt,name=comment,proto3" json:"comment,omitempty"` 825 | Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` 826 | Tables []*Table `protobuf:"bytes,3,rep,name=tables,proto3" json:"tables,omitempty"` 827 | Enums []*Enum `protobuf:"bytes,4,rep,name=enums,proto3" json:"enums,omitempty"` 828 | CompositeTypes []*CompositeType `protobuf:"bytes,5,rep,name=composite_types,json=compositeTypes,proto3" json:"composite_types,omitempty"` 829 | } 830 | 831 | func (x *Schema) Reset() { 832 | *x = Schema{} 833 | if protoimpl.UnsafeEnabled { 834 | mi := &file_plugin_codegen_proto_msgTypes[9] 835 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 836 | ms.StoreMessageInfo(mi) 837 | } 838 | } 839 | 840 | func (x *Schema) String() string { 841 | return protoimpl.X.MessageStringOf(x) 842 | } 843 | 844 | func (*Schema) ProtoMessage() {} 845 | 846 | func (x *Schema) ProtoReflect() protoreflect.Message { 847 | mi := &file_plugin_codegen_proto_msgTypes[9] 848 | if protoimpl.UnsafeEnabled && x != nil { 849 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 850 | if ms.LoadMessageInfo() == nil { 851 | ms.StoreMessageInfo(mi) 852 | } 853 | return ms 854 | } 855 | return mi.MessageOf(x) 856 | } 857 | 858 | // Deprecated: Use Schema.ProtoReflect.Descriptor instead. 859 | func (*Schema) Descriptor() ([]byte, []int) { 860 | return file_plugin_codegen_proto_rawDescGZIP(), []int{9} 861 | } 862 | 863 | func (x *Schema) GetComment() string { 864 | if x != nil { 865 | return x.Comment 866 | } 867 | return "" 868 | } 869 | 870 | func (x *Schema) GetName() string { 871 | if x != nil { 872 | return x.Name 873 | } 874 | return "" 875 | } 876 | 877 | func (x *Schema) GetTables() []*Table { 878 | if x != nil { 879 | return x.Tables 880 | } 881 | return nil 882 | } 883 | 884 | func (x *Schema) GetEnums() []*Enum { 885 | if x != nil { 886 | return x.Enums 887 | } 888 | return nil 889 | } 890 | 891 | func (x *Schema) GetCompositeTypes() []*CompositeType { 892 | if x != nil { 893 | return x.CompositeTypes 894 | } 895 | return nil 896 | } 897 | 898 | type CompositeType struct { 899 | state protoimpl.MessageState 900 | sizeCache protoimpl.SizeCache 901 | unknownFields protoimpl.UnknownFields 902 | 903 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 904 | Comment string `protobuf:"bytes,2,opt,name=comment,proto3" json:"comment,omitempty"` 905 | } 906 | 907 | func (x *CompositeType) Reset() { 908 | *x = CompositeType{} 909 | if protoimpl.UnsafeEnabled { 910 | mi := &file_plugin_codegen_proto_msgTypes[10] 911 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 912 | ms.StoreMessageInfo(mi) 913 | } 914 | } 915 | 916 | func (x *CompositeType) String() string { 917 | return protoimpl.X.MessageStringOf(x) 918 | } 919 | 920 | func (*CompositeType) ProtoMessage() {} 921 | 922 | func (x *CompositeType) ProtoReflect() protoreflect.Message { 923 | mi := &file_plugin_codegen_proto_msgTypes[10] 924 | if protoimpl.UnsafeEnabled && x != nil { 925 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 926 | if ms.LoadMessageInfo() == nil { 927 | ms.StoreMessageInfo(mi) 928 | } 929 | return ms 930 | } 931 | return mi.MessageOf(x) 932 | } 933 | 934 | // Deprecated: Use CompositeType.ProtoReflect.Descriptor instead. 935 | func (*CompositeType) Descriptor() ([]byte, []int) { 936 | return file_plugin_codegen_proto_rawDescGZIP(), []int{10} 937 | } 938 | 939 | func (x *CompositeType) GetName() string { 940 | if x != nil { 941 | return x.Name 942 | } 943 | return "" 944 | } 945 | 946 | func (x *CompositeType) GetComment() string { 947 | if x != nil { 948 | return x.Comment 949 | } 950 | return "" 951 | } 952 | 953 | type Enum struct { 954 | state protoimpl.MessageState 955 | sizeCache protoimpl.SizeCache 956 | unknownFields protoimpl.UnknownFields 957 | 958 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 959 | Vals []string `protobuf:"bytes,2,rep,name=vals,proto3" json:"vals,omitempty"` 960 | Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"` 961 | } 962 | 963 | func (x *Enum) Reset() { 964 | *x = Enum{} 965 | if protoimpl.UnsafeEnabled { 966 | mi := &file_plugin_codegen_proto_msgTypes[11] 967 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 968 | ms.StoreMessageInfo(mi) 969 | } 970 | } 971 | 972 | func (x *Enum) String() string { 973 | return protoimpl.X.MessageStringOf(x) 974 | } 975 | 976 | func (*Enum) ProtoMessage() {} 977 | 978 | func (x *Enum) ProtoReflect() protoreflect.Message { 979 | mi := &file_plugin_codegen_proto_msgTypes[11] 980 | if protoimpl.UnsafeEnabled && x != nil { 981 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 982 | if ms.LoadMessageInfo() == nil { 983 | ms.StoreMessageInfo(mi) 984 | } 985 | return ms 986 | } 987 | return mi.MessageOf(x) 988 | } 989 | 990 | // Deprecated: Use Enum.ProtoReflect.Descriptor instead. 991 | func (*Enum) Descriptor() ([]byte, []int) { 992 | return file_plugin_codegen_proto_rawDescGZIP(), []int{11} 993 | } 994 | 995 | func (x *Enum) GetName() string { 996 | if x != nil { 997 | return x.Name 998 | } 999 | return "" 1000 | } 1001 | 1002 | func (x *Enum) GetVals() []string { 1003 | if x != nil { 1004 | return x.Vals 1005 | } 1006 | return nil 1007 | } 1008 | 1009 | func (x *Enum) GetComment() string { 1010 | if x != nil { 1011 | return x.Comment 1012 | } 1013 | return "" 1014 | } 1015 | 1016 | type Table struct { 1017 | state protoimpl.MessageState 1018 | sizeCache protoimpl.SizeCache 1019 | unknownFields protoimpl.UnknownFields 1020 | 1021 | Rel *Identifier `protobuf:"bytes,1,opt,name=rel,proto3" json:"rel,omitempty"` 1022 | Columns []*Column `protobuf:"bytes,2,rep,name=columns,proto3" json:"columns,omitempty"` 1023 | Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"` 1024 | } 1025 | 1026 | func (x *Table) Reset() { 1027 | *x = Table{} 1028 | if protoimpl.UnsafeEnabled { 1029 | mi := &file_plugin_codegen_proto_msgTypes[12] 1030 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1031 | ms.StoreMessageInfo(mi) 1032 | } 1033 | } 1034 | 1035 | func (x *Table) String() string { 1036 | return protoimpl.X.MessageStringOf(x) 1037 | } 1038 | 1039 | func (*Table) ProtoMessage() {} 1040 | 1041 | func (x *Table) ProtoReflect() protoreflect.Message { 1042 | mi := &file_plugin_codegen_proto_msgTypes[12] 1043 | if protoimpl.UnsafeEnabled && x != nil { 1044 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1045 | if ms.LoadMessageInfo() == nil { 1046 | ms.StoreMessageInfo(mi) 1047 | } 1048 | return ms 1049 | } 1050 | return mi.MessageOf(x) 1051 | } 1052 | 1053 | // Deprecated: Use Table.ProtoReflect.Descriptor instead. 1054 | func (*Table) Descriptor() ([]byte, []int) { 1055 | return file_plugin_codegen_proto_rawDescGZIP(), []int{12} 1056 | } 1057 | 1058 | func (x *Table) GetRel() *Identifier { 1059 | if x != nil { 1060 | return x.Rel 1061 | } 1062 | return nil 1063 | } 1064 | 1065 | func (x *Table) GetColumns() []*Column { 1066 | if x != nil { 1067 | return x.Columns 1068 | } 1069 | return nil 1070 | } 1071 | 1072 | func (x *Table) GetComment() string { 1073 | if x != nil { 1074 | return x.Comment 1075 | } 1076 | return "" 1077 | } 1078 | 1079 | type Identifier struct { 1080 | state protoimpl.MessageState 1081 | sizeCache protoimpl.SizeCache 1082 | unknownFields protoimpl.UnknownFields 1083 | 1084 | Catalog string `protobuf:"bytes,1,opt,name=catalog,proto3" json:"catalog,omitempty"` 1085 | Schema string `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"` 1086 | Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` 1087 | } 1088 | 1089 | func (x *Identifier) Reset() { 1090 | *x = Identifier{} 1091 | if protoimpl.UnsafeEnabled { 1092 | mi := &file_plugin_codegen_proto_msgTypes[13] 1093 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1094 | ms.StoreMessageInfo(mi) 1095 | } 1096 | } 1097 | 1098 | func (x *Identifier) String() string { 1099 | return protoimpl.X.MessageStringOf(x) 1100 | } 1101 | 1102 | func (*Identifier) ProtoMessage() {} 1103 | 1104 | func (x *Identifier) ProtoReflect() protoreflect.Message { 1105 | mi := &file_plugin_codegen_proto_msgTypes[13] 1106 | if protoimpl.UnsafeEnabled && x != nil { 1107 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1108 | if ms.LoadMessageInfo() == nil { 1109 | ms.StoreMessageInfo(mi) 1110 | } 1111 | return ms 1112 | } 1113 | return mi.MessageOf(x) 1114 | } 1115 | 1116 | // Deprecated: Use Identifier.ProtoReflect.Descriptor instead. 1117 | func (*Identifier) Descriptor() ([]byte, []int) { 1118 | return file_plugin_codegen_proto_rawDescGZIP(), []int{13} 1119 | } 1120 | 1121 | func (x *Identifier) GetCatalog() string { 1122 | if x != nil { 1123 | return x.Catalog 1124 | } 1125 | return "" 1126 | } 1127 | 1128 | func (x *Identifier) GetSchema() string { 1129 | if x != nil { 1130 | return x.Schema 1131 | } 1132 | return "" 1133 | } 1134 | 1135 | func (x *Identifier) GetName() string { 1136 | if x != nil { 1137 | return x.Name 1138 | } 1139 | return "" 1140 | } 1141 | 1142 | type Column struct { 1143 | state protoimpl.MessageState 1144 | sizeCache protoimpl.SizeCache 1145 | unknownFields protoimpl.UnknownFields 1146 | 1147 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 1148 | NotNull bool `protobuf:"varint,3,opt,name=not_null,json=notNull,proto3" json:"not_null,omitempty"` 1149 | IsArray bool `protobuf:"varint,4,opt,name=is_array,json=isArray,proto3" json:"is_array,omitempty"` 1150 | Comment string `protobuf:"bytes,5,opt,name=comment,proto3" json:"comment,omitempty"` 1151 | Length int32 `protobuf:"varint,6,opt,name=length,proto3" json:"length,omitempty"` 1152 | IsNamedParam bool `protobuf:"varint,7,opt,name=is_named_param,json=isNamedParam,proto3" json:"is_named_param,omitempty"` 1153 | IsFuncCall bool `protobuf:"varint,8,opt,name=is_func_call,json=isFuncCall,proto3" json:"is_func_call,omitempty"` 1154 | // XXX: Figure out what PostgreSQL calls `foo.id` 1155 | Scope string `protobuf:"bytes,9,opt,name=scope,proto3" json:"scope,omitempty"` 1156 | Table *Identifier `protobuf:"bytes,10,opt,name=table,proto3" json:"table,omitempty"` 1157 | TableAlias string `protobuf:"bytes,11,opt,name=table_alias,json=tableAlias,proto3" json:"table_alias,omitempty"` 1158 | Type *Identifier `protobuf:"bytes,12,opt,name=type,proto3" json:"type,omitempty"` 1159 | DataType string `protobuf:"bytes,13,opt,name=data_type,json=dataType,proto3" json:"data_type,omitempty"` 1160 | } 1161 | 1162 | func (x *Column) Reset() { 1163 | *x = Column{} 1164 | if protoimpl.UnsafeEnabled { 1165 | mi := &file_plugin_codegen_proto_msgTypes[14] 1166 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1167 | ms.StoreMessageInfo(mi) 1168 | } 1169 | } 1170 | 1171 | func (x *Column) String() string { 1172 | return protoimpl.X.MessageStringOf(x) 1173 | } 1174 | 1175 | func (*Column) ProtoMessage() {} 1176 | 1177 | func (x *Column) ProtoReflect() protoreflect.Message { 1178 | mi := &file_plugin_codegen_proto_msgTypes[14] 1179 | if protoimpl.UnsafeEnabled && x != nil { 1180 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1181 | if ms.LoadMessageInfo() == nil { 1182 | ms.StoreMessageInfo(mi) 1183 | } 1184 | return ms 1185 | } 1186 | return mi.MessageOf(x) 1187 | } 1188 | 1189 | // Deprecated: Use Column.ProtoReflect.Descriptor instead. 1190 | func (*Column) Descriptor() ([]byte, []int) { 1191 | return file_plugin_codegen_proto_rawDescGZIP(), []int{14} 1192 | } 1193 | 1194 | func (x *Column) GetName() string { 1195 | if x != nil { 1196 | return x.Name 1197 | } 1198 | return "" 1199 | } 1200 | 1201 | func (x *Column) GetNotNull() bool { 1202 | if x != nil { 1203 | return x.NotNull 1204 | } 1205 | return false 1206 | } 1207 | 1208 | func (x *Column) GetIsArray() bool { 1209 | if x != nil { 1210 | return x.IsArray 1211 | } 1212 | return false 1213 | } 1214 | 1215 | func (x *Column) GetComment() string { 1216 | if x != nil { 1217 | return x.Comment 1218 | } 1219 | return "" 1220 | } 1221 | 1222 | func (x *Column) GetLength() int32 { 1223 | if x != nil { 1224 | return x.Length 1225 | } 1226 | return 0 1227 | } 1228 | 1229 | func (x *Column) GetIsNamedParam() bool { 1230 | if x != nil { 1231 | return x.IsNamedParam 1232 | } 1233 | return false 1234 | } 1235 | 1236 | func (x *Column) GetIsFuncCall() bool { 1237 | if x != nil { 1238 | return x.IsFuncCall 1239 | } 1240 | return false 1241 | } 1242 | 1243 | func (x *Column) GetScope() string { 1244 | if x != nil { 1245 | return x.Scope 1246 | } 1247 | return "" 1248 | } 1249 | 1250 | func (x *Column) GetTable() *Identifier { 1251 | if x != nil { 1252 | return x.Table 1253 | } 1254 | return nil 1255 | } 1256 | 1257 | func (x *Column) GetTableAlias() string { 1258 | if x != nil { 1259 | return x.TableAlias 1260 | } 1261 | return "" 1262 | } 1263 | 1264 | func (x *Column) GetType() *Identifier { 1265 | if x != nil { 1266 | return x.Type 1267 | } 1268 | return nil 1269 | } 1270 | 1271 | func (x *Column) GetDataType() string { 1272 | if x != nil { 1273 | return x.DataType 1274 | } 1275 | return "" 1276 | } 1277 | 1278 | type Query struct { 1279 | state protoimpl.MessageState 1280 | sizeCache protoimpl.SizeCache 1281 | unknownFields protoimpl.UnknownFields 1282 | 1283 | Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` 1284 | Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` 1285 | Cmd string `protobuf:"bytes,3,opt,name=cmd,proto3" json:"cmd,omitempty"` 1286 | Columns []*Column `protobuf:"bytes,4,rep,name=columns,proto3" json:"columns,omitempty"` 1287 | Params []*Parameter `protobuf:"bytes,5,rep,name=params,json=parameters,proto3" json:"params,omitempty"` 1288 | Comments []string `protobuf:"bytes,6,rep,name=comments,proto3" json:"comments,omitempty"` 1289 | Filename string `protobuf:"bytes,7,opt,name=filename,proto3" json:"filename,omitempty"` 1290 | InsertIntoTable *Identifier `protobuf:"bytes,8,opt,name=insert_into_table,proto3" json:"insert_into_table,omitempty"` 1291 | } 1292 | 1293 | func (x *Query) Reset() { 1294 | *x = Query{} 1295 | if protoimpl.UnsafeEnabled { 1296 | mi := &file_plugin_codegen_proto_msgTypes[15] 1297 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1298 | ms.StoreMessageInfo(mi) 1299 | } 1300 | } 1301 | 1302 | func (x *Query) String() string { 1303 | return protoimpl.X.MessageStringOf(x) 1304 | } 1305 | 1306 | func (*Query) ProtoMessage() {} 1307 | 1308 | func (x *Query) ProtoReflect() protoreflect.Message { 1309 | mi := &file_plugin_codegen_proto_msgTypes[15] 1310 | if protoimpl.UnsafeEnabled && x != nil { 1311 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1312 | if ms.LoadMessageInfo() == nil { 1313 | ms.StoreMessageInfo(mi) 1314 | } 1315 | return ms 1316 | } 1317 | return mi.MessageOf(x) 1318 | } 1319 | 1320 | // Deprecated: Use Query.ProtoReflect.Descriptor instead. 1321 | func (*Query) Descriptor() ([]byte, []int) { 1322 | return file_plugin_codegen_proto_rawDescGZIP(), []int{15} 1323 | } 1324 | 1325 | func (x *Query) GetText() string { 1326 | if x != nil { 1327 | return x.Text 1328 | } 1329 | return "" 1330 | } 1331 | 1332 | func (x *Query) GetName() string { 1333 | if x != nil { 1334 | return x.Name 1335 | } 1336 | return "" 1337 | } 1338 | 1339 | func (x *Query) GetCmd() string { 1340 | if x != nil { 1341 | return x.Cmd 1342 | } 1343 | return "" 1344 | } 1345 | 1346 | func (x *Query) GetColumns() []*Column { 1347 | if x != nil { 1348 | return x.Columns 1349 | } 1350 | return nil 1351 | } 1352 | 1353 | func (x *Query) GetParams() []*Parameter { 1354 | if x != nil { 1355 | return x.Params 1356 | } 1357 | return nil 1358 | } 1359 | 1360 | func (x *Query) GetComments() []string { 1361 | if x != nil { 1362 | return x.Comments 1363 | } 1364 | return nil 1365 | } 1366 | 1367 | func (x *Query) GetFilename() string { 1368 | if x != nil { 1369 | return x.Filename 1370 | } 1371 | return "" 1372 | } 1373 | 1374 | func (x *Query) GetInsertIntoTable() *Identifier { 1375 | if x != nil { 1376 | return x.InsertIntoTable 1377 | } 1378 | return nil 1379 | } 1380 | 1381 | type Parameter struct { 1382 | state protoimpl.MessageState 1383 | sizeCache protoimpl.SizeCache 1384 | unknownFields protoimpl.UnknownFields 1385 | 1386 | Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` 1387 | Column *Column `protobuf:"bytes,2,opt,name=column,proto3" json:"column,omitempty"` 1388 | } 1389 | 1390 | func (x *Parameter) Reset() { 1391 | *x = Parameter{} 1392 | if protoimpl.UnsafeEnabled { 1393 | mi := &file_plugin_codegen_proto_msgTypes[16] 1394 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1395 | ms.StoreMessageInfo(mi) 1396 | } 1397 | } 1398 | 1399 | func (x *Parameter) String() string { 1400 | return protoimpl.X.MessageStringOf(x) 1401 | } 1402 | 1403 | func (*Parameter) ProtoMessage() {} 1404 | 1405 | func (x *Parameter) ProtoReflect() protoreflect.Message { 1406 | mi := &file_plugin_codegen_proto_msgTypes[16] 1407 | if protoimpl.UnsafeEnabled && x != nil { 1408 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1409 | if ms.LoadMessageInfo() == nil { 1410 | ms.StoreMessageInfo(mi) 1411 | } 1412 | return ms 1413 | } 1414 | return mi.MessageOf(x) 1415 | } 1416 | 1417 | // Deprecated: Use Parameter.ProtoReflect.Descriptor instead. 1418 | func (*Parameter) Descriptor() ([]byte, []int) { 1419 | return file_plugin_codegen_proto_rawDescGZIP(), []int{16} 1420 | } 1421 | 1422 | func (x *Parameter) GetNumber() int32 { 1423 | if x != nil { 1424 | return x.Number 1425 | } 1426 | return 0 1427 | } 1428 | 1429 | func (x *Parameter) GetColumn() *Column { 1430 | if x != nil { 1431 | return x.Column 1432 | } 1433 | return nil 1434 | } 1435 | 1436 | type CodeGenRequest struct { 1437 | state protoimpl.MessageState 1438 | sizeCache protoimpl.SizeCache 1439 | unknownFields protoimpl.UnknownFields 1440 | 1441 | Settings *Settings `protobuf:"bytes,1,opt,name=settings,proto3" json:"settings,omitempty"` 1442 | Catalog *Catalog `protobuf:"bytes,2,opt,name=catalog,proto3" json:"catalog,omitempty"` 1443 | Queries []*Query `protobuf:"bytes,3,rep,name=queries,proto3" json:"queries,omitempty"` 1444 | } 1445 | 1446 | func (x *CodeGenRequest) Reset() { 1447 | *x = CodeGenRequest{} 1448 | if protoimpl.UnsafeEnabled { 1449 | mi := &file_plugin_codegen_proto_msgTypes[17] 1450 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1451 | ms.StoreMessageInfo(mi) 1452 | } 1453 | } 1454 | 1455 | func (x *CodeGenRequest) String() string { 1456 | return protoimpl.X.MessageStringOf(x) 1457 | } 1458 | 1459 | func (*CodeGenRequest) ProtoMessage() {} 1460 | 1461 | func (x *CodeGenRequest) ProtoReflect() protoreflect.Message { 1462 | mi := &file_plugin_codegen_proto_msgTypes[17] 1463 | if protoimpl.UnsafeEnabled && x != nil { 1464 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1465 | if ms.LoadMessageInfo() == nil { 1466 | ms.StoreMessageInfo(mi) 1467 | } 1468 | return ms 1469 | } 1470 | return mi.MessageOf(x) 1471 | } 1472 | 1473 | // Deprecated: Use CodeGenRequest.ProtoReflect.Descriptor instead. 1474 | func (*CodeGenRequest) Descriptor() ([]byte, []int) { 1475 | return file_plugin_codegen_proto_rawDescGZIP(), []int{17} 1476 | } 1477 | 1478 | func (x *CodeGenRequest) GetSettings() *Settings { 1479 | if x != nil { 1480 | return x.Settings 1481 | } 1482 | return nil 1483 | } 1484 | 1485 | func (x *CodeGenRequest) GetCatalog() *Catalog { 1486 | if x != nil { 1487 | return x.Catalog 1488 | } 1489 | return nil 1490 | } 1491 | 1492 | func (x *CodeGenRequest) GetQueries() []*Query { 1493 | if x != nil { 1494 | return x.Queries 1495 | } 1496 | return nil 1497 | } 1498 | 1499 | type CodeGenResponse struct { 1500 | state protoimpl.MessageState 1501 | sizeCache protoimpl.SizeCache 1502 | unknownFields protoimpl.UnknownFields 1503 | 1504 | Files []*File `protobuf:"bytes,1,rep,name=files,proto3" json:"files,omitempty"` 1505 | } 1506 | 1507 | func (x *CodeGenResponse) Reset() { 1508 | *x = CodeGenResponse{} 1509 | if protoimpl.UnsafeEnabled { 1510 | mi := &file_plugin_codegen_proto_msgTypes[18] 1511 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1512 | ms.StoreMessageInfo(mi) 1513 | } 1514 | } 1515 | 1516 | func (x *CodeGenResponse) String() string { 1517 | return protoimpl.X.MessageStringOf(x) 1518 | } 1519 | 1520 | func (*CodeGenResponse) ProtoMessage() {} 1521 | 1522 | func (x *CodeGenResponse) ProtoReflect() protoreflect.Message { 1523 | mi := &file_plugin_codegen_proto_msgTypes[18] 1524 | if protoimpl.UnsafeEnabled && x != nil { 1525 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1526 | if ms.LoadMessageInfo() == nil { 1527 | ms.StoreMessageInfo(mi) 1528 | } 1529 | return ms 1530 | } 1531 | return mi.MessageOf(x) 1532 | } 1533 | 1534 | // Deprecated: Use CodeGenResponse.ProtoReflect.Descriptor instead. 1535 | func (*CodeGenResponse) Descriptor() ([]byte, []int) { 1536 | return file_plugin_codegen_proto_rawDescGZIP(), []int{18} 1537 | } 1538 | 1539 | func (x *CodeGenResponse) GetFiles() []*File { 1540 | if x != nil { 1541 | return x.Files 1542 | } 1543 | return nil 1544 | } 1545 | 1546 | var File_plugin_codegen_proto protoreflect.FileDescriptor 1547 | 1548 | var file_plugin_codegen_proto_rawDesc = []byte{ 1549 | 0x0a, 0x14, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 1550 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, 0x36, 1551 | 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 1552 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 1553 | 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 1554 | 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xa6, 0x02, 0x0a, 0x08, 0x4f, 0x76, 0x65, 0x72, 0x72, 1555 | 0x69, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 1556 | 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 1557 | 0x65, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 1558 | 0x28, 0x09, 0x52, 0x07, 0x64, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 1559 | 0x75, 0x6c, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6e, 1560 | 0x75, 0x6c, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 1561 | 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 1562 | 0x28, 0x0a, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 1563 | 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 1564 | 0x65, 0x72, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6c, 1565 | 0x75, 0x6d, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 1566 | 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x33, 0x0a, 0x0b, 0x70, 1567 | 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 1568 | 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x50, 0x79, 0x74, 0x68, 0x6f, 0x6e, 1569 | 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x70, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 1570 | 0x12, 0x2d, 0x0a, 0x07, 0x67, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 1571 | 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 1572 | 0x64, 0x47, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x52, 0x06, 0x67, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x22, 1573 | 0x38, 0x0a, 0x0a, 0x50, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 1574 | 0x06, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 1575 | 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 1576 | 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x85, 0x01, 0x0a, 0x0c, 0x50, 0x61, 1577 | 0x72, 0x73, 0x65, 0x64, 0x47, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6d, 1578 | 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 1579 | 0x0a, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x70, 1580 | 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 1581 | 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 1582 | 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4e, 0x61, 1583 | 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x61, 0x73, 0x69, 0x63, 0x5f, 0x74, 0x79, 0x70, 0x65, 1584 | 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x62, 0x61, 0x73, 0x69, 0x63, 0x54, 0x79, 0x70, 1585 | 0x65, 0x22, 0x87, 0x03, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x18, 1586 | 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 1587 | 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x67, 0x69, 1588 | 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 1589 | 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 1590 | 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, 1591 | 0x69, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 1592 | 0x65, 0x73, 0x12, 0x34, 0x0a, 0x06, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x03, 1593 | 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x65, 0x74, 0x74, 1594 | 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 1595 | 0x52, 0x06, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x09, 0x6f, 0x76, 0x65, 0x72, 1596 | 0x72, 0x69, 0x64, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6c, 1597 | 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x09, 0x6f, 1598 | 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x06, 0x70, 0x79, 0x74, 0x68, 1599 | 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 1600 | 0x6e, 0x2e, 0x50, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x70, 0x79, 1601 | 0x74, 0x68, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x06, 0x6b, 0x6f, 0x74, 0x6c, 0x69, 0x6e, 0x18, 0x09, 1602 | 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x4b, 0x6f, 1603 | 0x74, 0x6c, 0x69, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x6b, 0x6f, 0x74, 0x6c, 0x69, 0x6e, 1604 | 0x12, 0x1e, 0x0a, 0x02, 0x67, 0x6f, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 1605 | 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x47, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x02, 0x67, 0x6f, 1606 | 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 1607 | 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 1608 | 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 1609 | 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc7, 0x01, 0x0a, 0x0a, 1610 | 0x50, 0x79, 0x74, 0x68, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x33, 0x0a, 0x16, 0x65, 0x6d, 1611 | 0x69, 0x74, 0x5f, 0x65, 0x78, 0x61, 0x63, 0x74, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6e, 1612 | 0x61, 0x6d, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x65, 0x6d, 0x69, 0x74, 1613 | 0x45, 0x78, 0x61, 0x63, 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 1614 | 0x2a, 0x0a, 0x11, 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x71, 0x75, 0x65, 1615 | 0x72, 0x69, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x65, 0x6d, 0x69, 0x74, 1616 | 0x53, 0x79, 0x6e, 0x63, 0x51, 0x75, 0x65, 0x72, 0x69, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x12, 0x65, 1617 | 0x6d, 0x69, 0x74, 0x5f, 0x61, 0x73, 0x79, 0x6e, 0x63, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 1618 | 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x65, 0x6d, 0x69, 0x74, 0x41, 0x73, 0x79, 1619 | 0x6e, 0x63, 0x51, 0x75, 0x65, 0x72, 0x69, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x63, 1620 | 0x6b, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 1621 | 0x61, 0x67, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 1622 | 0x52, 0x03, 0x6f, 0x75, 0x74, 0x22, 0x6d, 0x0a, 0x0a, 0x4b, 0x6f, 0x74, 0x6c, 0x69, 0x6e, 0x43, 1623 | 0x6f, 0x64, 0x65, 0x12, 0x33, 0x0a, 0x16, 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x65, 0x78, 0x61, 0x63, 1624 | 0x74, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x01, 0x20, 1625 | 0x01, 0x28, 0x08, 0x52, 0x13, 0x65, 0x6d, 0x69, 0x74, 0x45, 0x78, 0x61, 0x63, 0x74, 0x54, 0x61, 1626 | 0x62, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 1627 | 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 1628 | 0x67, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 1629 | 0x03, 0x6f, 0x75, 0x74, 0x22, 0xcd, 0x06, 0x0a, 0x06, 0x47, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 1630 | 0x25, 0x0a, 0x0e, 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 1631 | 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x65, 0x6d, 0x69, 0x74, 0x49, 0x6e, 0x74, 1632 | 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x6a, 1633 | 0x73, 0x6f, 0x6e, 0x5f, 0x74, 0x61, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 1634 | 0x65, 0x6d, 0x69, 0x74, 0x4a, 0x73, 0x6f, 0x6e, 0x54, 0x61, 0x67, 0x73, 0x12, 0x20, 0x0a, 0x0c, 1635 | 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x64, 0x62, 0x5f, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 1636 | 0x28, 0x08, 0x52, 0x0a, 0x65, 0x6d, 0x69, 0x74, 0x44, 0x62, 0x54, 0x61, 0x67, 0x73, 0x12, 0x32, 1637 | 0x0a, 0x15, 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x70, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x5f, 1638 | 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x65, 1639 | 0x6d, 0x69, 0x74, 0x50, 0x72, 0x65, 0x70, 0x61, 0x72, 0x65, 0x64, 0x51, 0x75, 0x65, 0x72, 0x69, 1640 | 0x65, 0x73, 0x12, 0x33, 0x0a, 0x16, 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x65, 0x78, 0x61, 0x63, 0x74, 1641 | 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 1642 | 0x28, 0x08, 0x52, 0x13, 0x65, 0x6d, 0x69, 0x74, 0x45, 0x78, 0x61, 0x63, 0x74, 0x54, 0x61, 0x62, 1643 | 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x11, 0x65, 0x6d, 0x69, 0x74, 0x5f, 1644 | 0x65, 0x6d, 0x70, 0x74, 0x79, 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 1645 | 0x28, 0x08, 0x52, 0x0f, 0x65, 0x6d, 0x69, 0x74, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x53, 0x6c, 0x69, 1646 | 0x63, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x15, 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x6f, 1647 | 0x72, 0x74, 0x65, 0x64, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 1648 | 0x28, 0x08, 0x52, 0x13, 0x65, 0x6d, 0x69, 0x74, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 1649 | 0x51, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x3d, 0x0a, 0x1b, 0x65, 0x6d, 0x69, 0x74, 0x5f, 1650 | 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x70, 0x6f, 1651 | 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x65, 0x6d, 1652 | 0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x50, 0x6f, 1653 | 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, 0x12, 0x3d, 0x0a, 0x1b, 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x70, 1654 | 0x61, 0x72, 0x61, 0x6d, 0x73, 0x5f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x70, 0x6f, 0x69, 1655 | 0x6e, 0x74, 0x65, 0x72, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x65, 0x6d, 0x69, 1656 | 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x50, 0x6f, 0x69, 1657 | 0x6e, 0x74, 0x65, 0x72, 0x73, 0x12, 0x40, 0x0a, 0x1d, 0x65, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x65, 1658 | 0x74, 0x68, 0x6f, 0x64, 0x73, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x64, 0x62, 0x5f, 0x61, 0x72, 1659 | 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x19, 0x65, 0x6d, 1660 | 0x69, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x57, 0x69, 0x74, 0x68, 0x44, 0x62, 0x41, 1661 | 0x72, 0x67, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x0a, 0x14, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 1662 | 0x74, 0x61, 0x67, 0x73, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x18, 1663 | 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x6a, 0x73, 0x6f, 0x6e, 0x54, 0x61, 0x67, 0x73, 0x43, 1664 | 0x61, 0x73, 0x65, 0x53, 0x74, 0x79, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 1665 | 0x61, 0x67, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 1666 | 0x67, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x75, 0x74, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 1667 | 0x03, 0x6f, 0x75, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x71, 0x6c, 0x5f, 0x70, 0x61, 0x63, 0x6b, 1668 | 0x61, 0x67, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x71, 0x6c, 0x50, 0x61, 1669 | 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x2d, 0x0a, 0x13, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 1670 | 0x64, 0x62, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 1671 | 0x28, 0x09, 0x52, 0x10, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x44, 0x62, 0x46, 0x69, 0x6c, 0x65, 1672 | 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x17, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x6d, 1673 | 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 1674 | 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x4d, 0x6f, 0x64, 1675 | 0x65, 0x6c, 0x73, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x18, 0x6f, 1676 | 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x72, 0x5f, 0x66, 0x69, 1677 | 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x6f, 1678 | 0x75, 0x74, 0x70, 0x75, 0x74, 0x51, 0x75, 0x65, 0x72, 0x69, 0x65, 0x72, 0x46, 0x69, 0x6c, 0x65, 1679 | 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x66, 1680 | 0x69, 0x6c, 0x65, 0x73, 0x5f, 0x73, 0x75, 0x66, 0x66, 0x69, 0x78, 0x18, 0x12, 0x20, 0x01, 0x28, 1681 | 0x09, 0x52, 0x11, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x53, 0x75, 1682 | 0x66, 0x66, 0x69, 0x78, 0x22, 0x88, 0x01, 0x0a, 0x07, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 1683 | 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 1684 | 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x65, 1685 | 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 1686 | 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 1687 | 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 1688 | 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 1689 | 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 1690 | 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x22, 1691 | 0xc1, 0x01, 0x0a, 0x06, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 1692 | 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 1693 | 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 1694 | 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x74, 0x61, 0x62, 0x6c, 1695 | 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 1696 | 0x6e, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x12, 1697 | 0x22, 0x0a, 0x05, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 1698 | 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x05, 0x65, 0x6e, 1699 | 0x75, 0x6d, 0x73, 0x12, 0x3e, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 1700 | 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 1701 | 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x54, 1702 | 0x79, 0x70, 0x65, 0x52, 0x0e, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x54, 0x79, 1703 | 0x70, 0x65, 0x73, 0x22, 0x3d, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 1704 | 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 1705 | 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 1706 | 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 1707 | 0x6e, 0x74, 0x22, 0x48, 0x0a, 0x04, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 1708 | 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 1709 | 0x0a, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x76, 0x61, 1710 | 0x6c, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 1711 | 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x71, 0x0a, 0x05, 1712 | 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x24, 0x0a, 0x03, 0x72, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 1713 | 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 1714 | 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x03, 0x72, 0x65, 0x6c, 0x12, 0x28, 0x0a, 0x07, 0x63, 1715 | 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 1716 | 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x07, 0x63, 0x6f, 1717 | 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 1718 | 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 1719 | 0x52, 0x0a, 0x0a, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x18, 0x0a, 1720 | 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 1721 | 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 1722 | 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 1723 | 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 1724 | 0x61, 0x6d, 0x65, 0x22, 0xf2, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 1725 | 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 1726 | 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x74, 0x5f, 0x6e, 0x75, 0x6c, 0x6c, 0x18, 0x03, 1727 | 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6e, 0x6f, 0x74, 0x4e, 0x75, 0x6c, 0x6c, 0x12, 0x19, 0x0a, 1728 | 0x08, 0x69, 0x73, 0x5f, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 1729 | 0x07, 0x69, 0x73, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 1730 | 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 1731 | 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 1732 | 0x28, 0x05, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 1733 | 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x07, 0x20, 0x01, 1734 | 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 1735 | 0x12, 0x20, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 1736 | 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x43, 0x61, 1737 | 0x6c, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 1738 | 0x09, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x05, 0x74, 0x61, 0x62, 0x6c, 1739 | 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 1740 | 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x05, 0x74, 0x61, 0x62, 1741 | 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 1742 | 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x6c, 1743 | 0x69, 0x61, 0x73, 0x12, 0x26, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 1744 | 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 1745 | 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x64, 1746 | 0x61, 0x74, 0x61, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 1747 | 0x64, 0x61, 0x74, 0x61, 0x54, 0x79, 0x70, 0x65, 0x22, 0x94, 0x02, 0x0a, 0x05, 0x51, 0x75, 0x65, 1748 | 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 1749 | 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 1750 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 1751 | 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x6d, 0x64, 0x12, 0x28, 0x0a, 0x07, 1752 | 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 1753 | 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x07, 0x63, 1754 | 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 1755 | 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 1756 | 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 1757 | 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 1758 | 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 1759 | 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 1760 | 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 1761 | 0x11, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 1762 | 0x6c, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 1763 | 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x69, 0x6e, 1764 | 0x73, 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x22, 1765 | 0x4b, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 1766 | 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6e, 0x75, 1767 | 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x02, 1768 | 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 1769 | 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x22, 0x92, 0x01, 0x0a, 1770 | 0x0e, 0x43, 0x6f, 0x64, 0x65, 0x47, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 1771 | 0x2c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 1772 | 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 1773 | 0x6e, 0x67, 0x73, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x29, 0x0a, 1774 | 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 1775 | 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, 1776 | 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x27, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, 1777 | 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 1778 | 0x69, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 1779 | 0x73, 0x22, 0x35, 0x0a, 0x0f, 0x43, 0x6f, 0x64, 0x65, 0x47, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 1780 | 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 1781 | 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x46, 0x69, 0x6c, 1782 | 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x42, 0x2c, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 1783 | 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x79, 0x6c, 0x65, 0x63, 0x6f, 0x6e, 0x72, 0x6f, 1784 | 0x79, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 1785 | 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 1786 | } 1787 | 1788 | var ( 1789 | file_plugin_codegen_proto_rawDescOnce sync.Once 1790 | file_plugin_codegen_proto_rawDescData = file_plugin_codegen_proto_rawDesc 1791 | ) 1792 | 1793 | func file_plugin_codegen_proto_rawDescGZIP() []byte { 1794 | file_plugin_codegen_proto_rawDescOnce.Do(func() { 1795 | file_plugin_codegen_proto_rawDescData = protoimpl.X.CompressGZIP(file_plugin_codegen_proto_rawDescData) 1796 | }) 1797 | return file_plugin_codegen_proto_rawDescData 1798 | } 1799 | 1800 | var file_plugin_codegen_proto_msgTypes = make([]protoimpl.MessageInfo, 20) 1801 | var file_plugin_codegen_proto_goTypes = []interface{}{ 1802 | (*File)(nil), // 0: plugin.File 1803 | (*Override)(nil), // 1: plugin.Override 1804 | (*PythonType)(nil), // 2: plugin.PythonType 1805 | (*ParsedGoType)(nil), // 3: plugin.ParsedGoType 1806 | (*Settings)(nil), // 4: plugin.Settings 1807 | (*PythonCode)(nil), // 5: plugin.PythonCode 1808 | (*KotlinCode)(nil), // 6: plugin.KotlinCode 1809 | (*GoCode)(nil), // 7: plugin.GoCode 1810 | (*Catalog)(nil), // 8: plugin.Catalog 1811 | (*Schema)(nil), // 9: plugin.Schema 1812 | (*CompositeType)(nil), // 10: plugin.CompositeType 1813 | (*Enum)(nil), // 11: plugin.Enum 1814 | (*Table)(nil), // 12: plugin.Table 1815 | (*Identifier)(nil), // 13: plugin.Identifier 1816 | (*Column)(nil), // 14: plugin.Column 1817 | (*Query)(nil), // 15: plugin.Query 1818 | (*Parameter)(nil), // 16: plugin.Parameter 1819 | (*CodeGenRequest)(nil), // 17: plugin.CodeGenRequest 1820 | (*CodeGenResponse)(nil), // 18: plugin.CodeGenResponse 1821 | nil, // 19: plugin.Settings.RenameEntry 1822 | } 1823 | var file_plugin_codegen_proto_depIdxs = []int32{ 1824 | 13, // 0: plugin.Override.table:type_name -> plugin.Identifier 1825 | 2, // 1: plugin.Override.python_type:type_name -> plugin.PythonType 1826 | 3, // 2: plugin.Override.go_type:type_name -> plugin.ParsedGoType 1827 | 19, // 3: plugin.Settings.rename:type_name -> plugin.Settings.RenameEntry 1828 | 1, // 4: plugin.Settings.overrides:type_name -> plugin.Override 1829 | 5, // 5: plugin.Settings.python:type_name -> plugin.PythonCode 1830 | 6, // 6: plugin.Settings.kotlin:type_name -> plugin.KotlinCode 1831 | 7, // 7: plugin.Settings.go:type_name -> plugin.GoCode 1832 | 9, // 8: plugin.Catalog.schemas:type_name -> plugin.Schema 1833 | 12, // 9: plugin.Schema.tables:type_name -> plugin.Table 1834 | 11, // 10: plugin.Schema.enums:type_name -> plugin.Enum 1835 | 10, // 11: plugin.Schema.composite_types:type_name -> plugin.CompositeType 1836 | 13, // 12: plugin.Table.rel:type_name -> plugin.Identifier 1837 | 14, // 13: plugin.Table.columns:type_name -> plugin.Column 1838 | 13, // 14: plugin.Column.table:type_name -> plugin.Identifier 1839 | 13, // 15: plugin.Column.type:type_name -> plugin.Identifier 1840 | 14, // 16: plugin.Query.columns:type_name -> plugin.Column 1841 | 16, // 17: plugin.Query.params:type_name -> plugin.Parameter 1842 | 13, // 18: plugin.Query.insert_into_table:type_name -> plugin.Identifier 1843 | 14, // 19: plugin.Parameter.column:type_name -> plugin.Column 1844 | 4, // 20: plugin.CodeGenRequest.settings:type_name -> plugin.Settings 1845 | 8, // 21: plugin.CodeGenRequest.catalog:type_name -> plugin.Catalog 1846 | 15, // 22: plugin.CodeGenRequest.queries:type_name -> plugin.Query 1847 | 0, // 23: plugin.CodeGenResponse.files:type_name -> plugin.File 1848 | 24, // [24:24] is the sub-list for method output_type 1849 | 24, // [24:24] is the sub-list for method input_type 1850 | 24, // [24:24] is the sub-list for extension type_name 1851 | 24, // [24:24] is the sub-list for extension extendee 1852 | 0, // [0:24] is the sub-list for field type_name 1853 | } 1854 | 1855 | func init() { file_plugin_codegen_proto_init() } 1856 | func file_plugin_codegen_proto_init() { 1857 | if File_plugin_codegen_proto != nil { 1858 | return 1859 | } 1860 | if !protoimpl.UnsafeEnabled { 1861 | file_plugin_codegen_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 1862 | switch v := v.(*File); i { 1863 | case 0: 1864 | return &v.state 1865 | case 1: 1866 | return &v.sizeCache 1867 | case 2: 1868 | return &v.unknownFields 1869 | default: 1870 | return nil 1871 | } 1872 | } 1873 | file_plugin_codegen_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 1874 | switch v := v.(*Override); i { 1875 | case 0: 1876 | return &v.state 1877 | case 1: 1878 | return &v.sizeCache 1879 | case 2: 1880 | return &v.unknownFields 1881 | default: 1882 | return nil 1883 | } 1884 | } 1885 | file_plugin_codegen_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 1886 | switch v := v.(*PythonType); i { 1887 | case 0: 1888 | return &v.state 1889 | case 1: 1890 | return &v.sizeCache 1891 | case 2: 1892 | return &v.unknownFields 1893 | default: 1894 | return nil 1895 | } 1896 | } 1897 | file_plugin_codegen_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 1898 | switch v := v.(*ParsedGoType); i { 1899 | case 0: 1900 | return &v.state 1901 | case 1: 1902 | return &v.sizeCache 1903 | case 2: 1904 | return &v.unknownFields 1905 | default: 1906 | return nil 1907 | } 1908 | } 1909 | file_plugin_codegen_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 1910 | switch v := v.(*Settings); i { 1911 | case 0: 1912 | return &v.state 1913 | case 1: 1914 | return &v.sizeCache 1915 | case 2: 1916 | return &v.unknownFields 1917 | default: 1918 | return nil 1919 | } 1920 | } 1921 | file_plugin_codegen_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 1922 | switch v := v.(*PythonCode); i { 1923 | case 0: 1924 | return &v.state 1925 | case 1: 1926 | return &v.sizeCache 1927 | case 2: 1928 | return &v.unknownFields 1929 | default: 1930 | return nil 1931 | } 1932 | } 1933 | file_plugin_codegen_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { 1934 | switch v := v.(*KotlinCode); i { 1935 | case 0: 1936 | return &v.state 1937 | case 1: 1938 | return &v.sizeCache 1939 | case 2: 1940 | return &v.unknownFields 1941 | default: 1942 | return nil 1943 | } 1944 | } 1945 | file_plugin_codegen_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { 1946 | switch v := v.(*GoCode); i { 1947 | case 0: 1948 | return &v.state 1949 | case 1: 1950 | return &v.sizeCache 1951 | case 2: 1952 | return &v.unknownFields 1953 | default: 1954 | return nil 1955 | } 1956 | } 1957 | file_plugin_codegen_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { 1958 | switch v := v.(*Catalog); i { 1959 | case 0: 1960 | return &v.state 1961 | case 1: 1962 | return &v.sizeCache 1963 | case 2: 1964 | return &v.unknownFields 1965 | default: 1966 | return nil 1967 | } 1968 | } 1969 | file_plugin_codegen_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { 1970 | switch v := v.(*Schema); i { 1971 | case 0: 1972 | return &v.state 1973 | case 1: 1974 | return &v.sizeCache 1975 | case 2: 1976 | return &v.unknownFields 1977 | default: 1978 | return nil 1979 | } 1980 | } 1981 | file_plugin_codegen_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { 1982 | switch v := v.(*CompositeType); i { 1983 | case 0: 1984 | return &v.state 1985 | case 1: 1986 | return &v.sizeCache 1987 | case 2: 1988 | return &v.unknownFields 1989 | default: 1990 | return nil 1991 | } 1992 | } 1993 | file_plugin_codegen_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { 1994 | switch v := v.(*Enum); i { 1995 | case 0: 1996 | return &v.state 1997 | case 1: 1998 | return &v.sizeCache 1999 | case 2: 2000 | return &v.unknownFields 2001 | default: 2002 | return nil 2003 | } 2004 | } 2005 | file_plugin_codegen_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { 2006 | switch v := v.(*Table); i { 2007 | case 0: 2008 | return &v.state 2009 | case 1: 2010 | return &v.sizeCache 2011 | case 2: 2012 | return &v.unknownFields 2013 | default: 2014 | return nil 2015 | } 2016 | } 2017 | file_plugin_codegen_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { 2018 | switch v := v.(*Identifier); i { 2019 | case 0: 2020 | return &v.state 2021 | case 1: 2022 | return &v.sizeCache 2023 | case 2: 2024 | return &v.unknownFields 2025 | default: 2026 | return nil 2027 | } 2028 | } 2029 | file_plugin_codegen_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { 2030 | switch v := v.(*Column); i { 2031 | case 0: 2032 | return &v.state 2033 | case 1: 2034 | return &v.sizeCache 2035 | case 2: 2036 | return &v.unknownFields 2037 | default: 2038 | return nil 2039 | } 2040 | } 2041 | file_plugin_codegen_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { 2042 | switch v := v.(*Query); i { 2043 | case 0: 2044 | return &v.state 2045 | case 1: 2046 | return &v.sizeCache 2047 | case 2: 2048 | return &v.unknownFields 2049 | default: 2050 | return nil 2051 | } 2052 | } 2053 | file_plugin_codegen_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { 2054 | switch v := v.(*Parameter); i { 2055 | case 0: 2056 | return &v.state 2057 | case 1: 2058 | return &v.sizeCache 2059 | case 2: 2060 | return &v.unknownFields 2061 | default: 2062 | return nil 2063 | } 2064 | } 2065 | file_plugin_codegen_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { 2066 | switch v := v.(*CodeGenRequest); i { 2067 | case 0: 2068 | return &v.state 2069 | case 1: 2070 | return &v.sizeCache 2071 | case 2: 2072 | return &v.unknownFields 2073 | default: 2074 | return nil 2075 | } 2076 | } 2077 | file_plugin_codegen_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { 2078 | switch v := v.(*CodeGenResponse); i { 2079 | case 0: 2080 | return &v.state 2081 | case 1: 2082 | return &v.sizeCache 2083 | case 2: 2084 | return &v.unknownFields 2085 | default: 2086 | return nil 2087 | } 2088 | } 2089 | } 2090 | type x struct{} 2091 | out := protoimpl.TypeBuilder{ 2092 | File: protoimpl.DescBuilder{ 2093 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 2094 | RawDescriptor: file_plugin_codegen_proto_rawDesc, 2095 | NumEnums: 0, 2096 | NumMessages: 20, 2097 | NumExtensions: 0, 2098 | NumServices: 0, 2099 | }, 2100 | GoTypes: file_plugin_codegen_proto_goTypes, 2101 | DependencyIndexes: file_plugin_codegen_proto_depIdxs, 2102 | MessageInfos: file_plugin_codegen_proto_msgTypes, 2103 | }.Build() 2104 | File_plugin_codegen_proto = out.File 2105 | file_plugin_codegen_proto_rawDesc = nil 2106 | file_plugin_codegen_proto_goTypes = nil 2107 | file_plugin_codegen_proto_depIdxs = nil 2108 | } 2109 | -------------------------------------------------------------------------------- /internal/sdk/sdk.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import "github.com/stephen/sqlc-ts/internal/plugin" 4 | 5 | func DataType(n *plugin.Identifier) string { 6 | if n.Schema != "" { 7 | return n.Schema + "." + n.Name 8 | } else { 9 | return n.Name 10 | } 11 | } 12 | 13 | func SameTableName(tableID, f *plugin.Identifier, defaultSchema string) bool { 14 | if tableID == nil { 15 | return false 16 | } 17 | schema := tableID.Schema 18 | if tableID.Schema == "" { 19 | schema = defaultSchema 20 | } 21 | return tableID.Catalog == f.Catalog && schema == f.Schema && tableID.Name == f.Name 22 | } 23 | -------------------------------------------------------------------------------- /internal/sdk/utils.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "strings" 5 | "unicode" 6 | ) 7 | 8 | func LowerTitle(s string) string { 9 | if s == "" { 10 | return s 11 | } 12 | 13 | a := []rune(s) 14 | a[0] = unicode.ToLower(a[0]) 15 | return string(a) 16 | } 17 | 18 | func Title(s string) string { 19 | return strings.Title(s) 20 | } 21 | 22 | // Go string literals cannot contain backtick. If a string contains 23 | // a backtick, replace it the following way: 24 | // 25 | // input: 26 | // SELECT `group` FROM foo 27 | // 28 | // output: 29 | // SELECT ` + "`" + `group` + "`" + ` FROM foo 30 | // 31 | // The escaped string must be rendered inside an existing string literal 32 | // 33 | // A string cannot be escaped twice 34 | func EscapeBacktick(s string) string { 35 | return strings.Replace(s, "`", "`+\"`\"+`", -1) 36 | } 37 | 38 | func DoubleSlashComment(s string) string { 39 | return "// " + strings.ReplaceAll(s, "\n", "\n// ") 40 | } 41 | -------------------------------------------------------------------------------- /internal/sdk/utils_test.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestLowerTitle(t *testing.T) { 8 | 9 | // empty 10 | if LowerTitle("") != "" { 11 | t.Fatal("expected empty title to remain empty") 12 | } 13 | 14 | // all lowercase 15 | if LowerTitle("lowercase") != "lowercase" { 16 | t.Fatal("expected no changes when input is all lowercase") 17 | } 18 | 19 | // all uppercase 20 | if LowerTitle("UPPERCASE") != "uPPERCASE" { 21 | t.Fatal("expected first rune to be lower when input is all uppercase") 22 | } 23 | 24 | // Title Case 25 | if LowerTitle("Title Case") != "title Case" { 26 | t.Fatal("expected first rune to be lower when input is Title Case") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "io" 7 | "os" 8 | 9 | "github.com/stephen/sqlc-ts/internal/plugin" 10 | ) 11 | 12 | func main() { 13 | if err := run(); err != nil { 14 | fmt.Fprintf(os.Stderr, "error generating typescript: %s", err) 15 | os.Exit(2) 16 | } 17 | } 18 | 19 | func run() error { 20 | var req plugin.CodeGenRequest 21 | reqBlob, err := io.ReadAll(os.Stdin) 22 | if err != nil { 23 | return err 24 | } 25 | if err := req.UnmarshalVT(reqBlob); err != nil { 26 | return err 27 | } 28 | resp, err := Generate(&req) 29 | if err != nil { 30 | return err 31 | } 32 | respBlob, err := resp.MarshalVT() 33 | if err != nil { 34 | return err 35 | } 36 | w := bufio.NewWriter(os.Stdout) 37 | if _, err := w.Write(respBlob); err != nil { 38 | return err 39 | } 40 | if err := w.Flush(); err != nil { 41 | return err 42 | } 43 | return nil 44 | } 45 | -------------------------------------------------------------------------------- /protos/plugin/codegen.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package plugin; 4 | 5 | option go_package = "github.com/kyleconroy/sqlc/internal/plugin"; 6 | 7 | message File 8 | { 9 | string name = 1 [json_name="name"]; 10 | bytes contents = 2 [json_name="contents"]; 11 | } 12 | 13 | message Override { 14 | // name of the type to use, e.g. `github.com/segmentio/ksuid.KSUID` or `mymodule.Type` 15 | string code_type = 1 [json_name="code_type"]; 16 | 17 | // name of the type to use, e.g. `text` 18 | string db_type = 3 [json_name="db_type"]; 19 | 20 | // True if the override should apply to a nullable database type 21 | bool nullable = 5 [json_name="nullable"]; 22 | 23 | // fully qualified name of the column, e.g. `accounts.id` 24 | string column = 6 [json_name="column"]; 25 | 26 | Identifier table = 7 [json_name="table"]; 27 | 28 | string column_name = 8 [json_name="column_name"]; 29 | 30 | PythonType python_type = 9; 31 | 32 | ParsedGoType go_type = 10; 33 | } 34 | 35 | message PythonType 36 | { 37 | string module = 1; 38 | string name = 2; 39 | } 40 | 41 | message ParsedGoType 42 | { 43 | string import_path = 1; 44 | string package = 2; 45 | string type_name = 3; 46 | bool basic_type = 4; 47 | } 48 | 49 | message Settings 50 | { 51 | string version = 1 [json_name="version"]; 52 | string engine = 2 [json_name="engine"]; 53 | repeated string schema = 3 [json_name="schema"]; 54 | repeated string queries = 4 [json_name="queries"]; 55 | map rename = 5 [json_name="rename"]; 56 | repeated Override overrides = 6 [json_name="overrides"]; 57 | 58 | // TODO: Refactor codegen settings 59 | PythonCode python = 8; 60 | KotlinCode kotlin = 9; 61 | GoCode go = 10; 62 | } 63 | 64 | message PythonCode 65 | { 66 | bool emit_exact_table_names = 1; 67 | bool emit_sync_querier = 2; 68 | bool emit_async_querier = 3; 69 | string package = 4; 70 | string out = 5; 71 | } 72 | 73 | message KotlinCode 74 | { 75 | bool emit_exact_table_names = 1; 76 | string package = 2; 77 | string out = 3; 78 | } 79 | 80 | message GoCode 81 | { 82 | bool emit_interface = 1; 83 | bool emit_json_tags = 2; 84 | bool emit_db_tags = 3; 85 | bool emit_prepared_queries = 4; 86 | bool emit_exact_table_names = 5; 87 | bool emit_empty_slices = 6; 88 | bool emit_exported_queries = 7; 89 | bool emit_result_struct_pointers = 8; 90 | bool emit_params_struct_pointers = 9; 91 | bool emit_methods_with_db_argument = 10; 92 | string json_tags_case_style = 11; 93 | string package = 12; 94 | string out = 13; 95 | string sql_package = 14; 96 | string output_db_file_name = 15; 97 | string output_models_file_name = 16; 98 | string output_querier_file_name = 17; 99 | string output_files_suffix = 18; 100 | } 101 | 102 | message Catalog 103 | { 104 | string comment = 1; 105 | string default_schema = 2; 106 | string name = 3; 107 | repeated Schema schemas = 4; 108 | } 109 | 110 | message Schema 111 | { 112 | string comment = 1; 113 | string name = 2; 114 | repeated Table tables = 3; 115 | repeated Enum enums = 4; 116 | repeated CompositeType composite_types = 5; 117 | } 118 | 119 | message CompositeType 120 | { 121 | string name = 1; 122 | string comment = 2; 123 | } 124 | 125 | message Enum 126 | { 127 | string name = 1; 128 | repeated string vals = 2; 129 | string comment = 3; 130 | } 131 | 132 | message Table 133 | { 134 | Identifier rel = 1; 135 | repeated Column columns = 2; 136 | string comment = 3; 137 | } 138 | 139 | message Identifier 140 | { 141 | string catalog = 1; 142 | string schema = 2; 143 | string name = 3; 144 | } 145 | 146 | message Column 147 | { 148 | string name = 1; 149 | bool not_null = 3; 150 | bool is_array = 4; 151 | string comment = 5; 152 | int32 length = 6; 153 | bool is_named_param = 7; 154 | bool is_func_call = 8; 155 | 156 | // XXX: Figure out what PostgreSQL calls `foo.id` 157 | string scope = 9; 158 | Identifier table = 10; 159 | string table_alias = 11; 160 | Identifier type = 12; 161 | string data_type = 13; 162 | } 163 | 164 | message Query 165 | { 166 | string text = 1 [json_name="text"]; 167 | string name = 2 [json_name="name"]; 168 | string cmd = 3 [json_name="cmd"]; 169 | repeated Column columns = 4 [json_name="columns"]; 170 | repeated Parameter params = 5 [json_name="parameters"]; 171 | repeated string comments = 6 [json_name="comments"]; 172 | string filename = 7 [json_name="filename"]; 173 | Identifier insert_into_table = 8 [json_name="insert_into_table"]; 174 | } 175 | 176 | message Parameter 177 | { 178 | int32 number = 1 [json_name="number"]; 179 | Column column = 2 [json_name="column"]; 180 | } 181 | 182 | message CodeGenRequest 183 | { 184 | Settings settings = 1 [json_name="settings"]; 185 | Catalog catalog = 2 [json_name="catalog"]; 186 | repeated Query queries = 3 [json_name="queries"]; 187 | } 188 | 189 | message CodeGenResponse 190 | { 191 | repeated File files = 1 [json_name="files"]; 192 | } 193 | -------------------------------------------------------------------------------- /query.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | 7 | "github.com/stephen/sqlc-ts/internal/metadata" 8 | "github.com/stephen/sqlc-ts/internal/plugin" 9 | ) 10 | 11 | type QueryValue struct { 12 | Emit bool 13 | Name string 14 | Struct *Struct 15 | Typ string 16 | 17 | // TypecheckTemplate is currently only set for return values. 18 | TypecheckTemplate string 19 | } 20 | 21 | func (v QueryValue) HasTypecheck() bool { 22 | return v.TypecheckTemplate == "" 23 | } 24 | 25 | func (v QueryValue) Typecheck() string { 26 | return strings.ReplaceAll(v.TypecheckTemplate, "%", "row[0]") 27 | } 28 | 29 | func (v QueryValue) EmitStruct() bool { 30 | return v.Emit 31 | } 32 | 33 | func (v QueryValue) IsStruct() bool { 34 | return v.Struct != nil 35 | } 36 | 37 | func (v QueryValue) isEmpty() bool { 38 | return v.Typ == "" && v.Name == "" && v.Struct == nil 39 | } 40 | 41 | func (v QueryValue) Pair() string { 42 | if v.isEmpty() { 43 | return "" 44 | } 45 | return v.Name + ": " + v.DefineType() 46 | } 47 | 48 | func (v QueryValue) SlicePair() string { 49 | if v.isEmpty() { 50 | return "" 51 | } 52 | return v.Name + " []" + v.DefineType() 53 | } 54 | 55 | func (v QueryValue) Type() string { 56 | if v.Typ != "" { 57 | return v.Typ 58 | } 59 | if v.Struct != nil { 60 | return v.Struct.Name 61 | } 62 | panic("no type for QueryValue: " + v.Name) 63 | } 64 | 65 | func (v *QueryValue) DefineType() string { 66 | t := v.Type() 67 | return t 68 | } 69 | 70 | func (v *QueryValue) ReturnName() string { 71 | return v.Name 72 | } 73 | 74 | func (v QueryValue) UniqueFields() []Field { 75 | seen := map[string]struct{}{} 76 | fields := make([]Field, 0, len(v.Struct.Fields)) 77 | 78 | for _, field := range v.Struct.Fields { 79 | if _, found := seen[field.Name]; found { 80 | continue 81 | } 82 | seen[field.Name] = struct{}{} 83 | fields = append(fields, field) 84 | } 85 | 86 | return fields 87 | } 88 | 89 | func (v QueryValue) Params() string { 90 | if v.isEmpty() { 91 | return "" 92 | } 93 | var out []string 94 | if v.Struct == nil { 95 | out = append(out, v.Name) 96 | } else { 97 | for _, f := range v.Struct.Fields { 98 | out = append(out, v.Name+"."+f.Name) 99 | } 100 | } 101 | if len(out) <= 3 { 102 | return strings.Join(out, ", ") 103 | } 104 | out = append(out, "") 105 | return "\n" + strings.Join(out, ",\n") 106 | } 107 | 108 | func (v QueryValue) ColumnNames() string { 109 | if v.Struct == nil { 110 | return fmt.Sprintf("[]string{%q}", v.Name) 111 | } 112 | escapedNames := make([]string, len(v.Struct.Fields)) 113 | for i, f := range v.Struct.Fields { 114 | escapedNames[i] = fmt.Sprintf("%q", f.DBName) 115 | } 116 | return "[]string{" + strings.Join(escapedNames, ", ") + "}" 117 | } 118 | 119 | func (v QueryValue) Scan() string { 120 | var out []string 121 | if v.Struct == nil { 122 | out = append(out, "&"+v.Name) 123 | } else { 124 | for _, f := range v.Struct.Fields { 125 | out = append(out, "&"+v.Name+"."+f.Name) 126 | } 127 | } 128 | if len(out) <= 3 { 129 | return strings.Join(out, ",") 130 | } 131 | out = append(out, "") 132 | return "\n" + strings.Join(out, ",\n") 133 | } 134 | 135 | // A struct used to generate methods and fields on the Queries struct 136 | type Query struct { 137 | Cmd string 138 | Comments []string 139 | MethodName string 140 | ConstantName string 141 | SQL string 142 | SourceName string 143 | Ret QueryValue 144 | Arg QueryValue 145 | // Used for :copyfrom 146 | Table *plugin.Identifier 147 | } 148 | 149 | func (q Query) hasRetType() bool { 150 | scanned := q.Cmd == metadata.CmdOne || q.Cmd == metadata.CmdMany 151 | return scanned && !q.Ret.isEmpty() 152 | } 153 | 154 | func (q Query) TableIdentifier() string { 155 | escapedNames := make([]string, 0, 3) 156 | for _, p := range []string{q.Table.Catalog, q.Table.Schema, q.Table.Name} { 157 | if p != "" { 158 | escapedNames = append(escapedNames, fmt.Sprintf("%q", p)) 159 | } 160 | } 161 | return "[]string{" + strings.Join(escapedNames, ", ") + "}" 162 | } 163 | -------------------------------------------------------------------------------- /result.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | "strings" 7 | 8 | "github.com/jinzhu/inflection" 9 | "github.com/stephen/sqlc-ts/internal/plugin" 10 | "github.com/stephen/sqlc-ts/internal/sdk" 11 | ) 12 | 13 | func buildStructs(req *plugin.CodeGenRequest) []Struct { 14 | var structs []Struct 15 | for _, schema := range req.Catalog.Schemas { 16 | for _, table := range schema.Tables { 17 | // XXX: go codegen has req.Settings.Go.EmitExactTableNames knob. 18 | structName := inflection.Singular(table.Rel.Name) 19 | s := Struct{ 20 | Table: plugin.Identifier{Schema: schema.Name, Name: table.Rel.Name}, 21 | Name: StructName(structName, req.Settings), 22 | Comment: table.Comment, 23 | } 24 | for _, column := range table.Columns { 25 | s.Fields = append(s.Fields, Field{ 26 | Name: FieldName(column.Name, req.Settings), 27 | Type: tsType(req, column), 28 | Comment: column.Comment, 29 | }) 30 | } 31 | structs = append(structs, s) 32 | } 33 | } 34 | if len(structs) > 0 { 35 | sort.Slice(structs, func(i, j int) bool { return structs[i].Name < structs[j].Name }) 36 | } 37 | return structs 38 | } 39 | 40 | func buildQueries(req *plugin.CodeGenRequest, structs []Struct) ([]Query, error) { 41 | qs := make([]Query, 0, len(req.Queries)) 42 | for _, query := range req.Queries { 43 | if query.Name == "" { 44 | continue 45 | } 46 | if query.Cmd == "" { 47 | continue 48 | } 49 | 50 | name := sdk.LowerTitle(query.Name) 51 | 52 | gq := Query{ 53 | Cmd: query.Cmd, 54 | ConstantName: name + "Stmt", 55 | MethodName: name, 56 | SourceName: query.Filename, 57 | SQL: query.Text, 58 | Comments: query.Comments, 59 | Table: query.InsertIntoTable, 60 | } 61 | 62 | if len(query.Params) == 1 { 63 | p := query.Params[0] 64 | gq.Arg = QueryValue{ 65 | Name: paramName(p), 66 | Typ: tsType(req, p.Column), 67 | } 68 | } else if len(query.Params) > 1 { 69 | var cols []column 70 | for _, p := range query.Params { 71 | cols = append(cols, column{ 72 | id: int(p.Number), 73 | Column: p.Column, 74 | }) 75 | } 76 | s, err := columnsToStruct(req, sdk.Title(gq.MethodName)+"Params", cols, false) 77 | if err != nil { 78 | return nil, err 79 | } 80 | gq.Arg = QueryValue{ 81 | Emit: true, 82 | Name: "arg", 83 | Struct: s, 84 | } 85 | } 86 | 87 | if len(query.Columns) == 1 { 88 | c := query.Columns[0] 89 | name := columnName(c, 0) 90 | if c.IsFuncCall { 91 | name = strings.Replace(name, "$", "_", -1) 92 | } 93 | gq.Ret = QueryValue{ 94 | Name: name, 95 | Typ: tsType(req, c), 96 | TypecheckTemplate: tsTypecheckTemplate(req, c), 97 | } 98 | } else if len(query.Columns) > 1 { 99 | var gs *Struct 100 | var emit bool 101 | 102 | for _, s := range structs { 103 | if len(s.Fields) != len(query.Columns) { 104 | continue 105 | } 106 | same := true 107 | for i, f := range s.Fields { 108 | c := query.Columns[i] 109 | sameName := f.Name == StructName(columnName(c, i), req.Settings) 110 | sameType := f.Type == tsType(req, c) 111 | sameTable := sdk.SameTableName(c.Table, &s.Table, req.Catalog.DefaultSchema) 112 | if !sameName || !sameType || !sameTable { 113 | same = false 114 | } 115 | } 116 | if same { 117 | gs = &s 118 | break 119 | } 120 | } 121 | 122 | if gs == nil { 123 | var columns []column 124 | for i, c := range query.Columns { 125 | columns = append(columns, column{ 126 | id: i, 127 | Column: c, 128 | }) 129 | } 130 | var err error 131 | gs, err = columnsToStruct(req, sdk.Title(gq.MethodName)+"Row", columns, true) 132 | if err != nil { 133 | return nil, err 134 | } 135 | emit = true 136 | } 137 | gq.Ret = QueryValue{ 138 | Emit: emit, 139 | Name: "i", 140 | Struct: gs, 141 | } 142 | } 143 | 144 | qs = append(qs, gq) 145 | } 146 | sort.Slice(qs, func(i, j int) bool { return qs[i].MethodName < qs[j].MethodName }) 147 | return qs, nil 148 | } 149 | 150 | func columnName(c *plugin.Column, pos int) string { 151 | if c.Name != "" { 152 | return c.Name 153 | } 154 | return fmt.Sprintf("column_%d", pos+1) 155 | } 156 | 157 | func argName(name string) string { 158 | out := "" 159 | for i, p := range strings.Split(name, "_") { 160 | if i == 0 { 161 | out += strings.ToLower(p) 162 | } else if p == "id" { 163 | out += "ID" 164 | } else { 165 | out += strings.Title(p) 166 | } 167 | } 168 | return out 169 | } 170 | 171 | func paramName(p *plugin.Parameter) string { 172 | if p.Column.Name != "" { 173 | return argName(p.Column.Name) 174 | } 175 | return fmt.Sprintf("dollar_%d", p.Number) 176 | } 177 | 178 | type column struct { 179 | id int 180 | *plugin.Column 181 | } 182 | 183 | // It's possible that this method will generate duplicate JSON tag values 184 | // 185 | // Columns: count, count, count_2 186 | // Fields: Count, Count_2, Count2 187 | // 188 | // JSON tags: count, count_2, count_2 189 | // 190 | // This is unlikely to happen, so don't fix it yet 191 | func columnsToStruct(req *plugin.CodeGenRequest, name string, columns []column, useID bool) (*Struct, error) { 192 | gs := Struct{ 193 | Name: name, 194 | } 195 | seen := map[string][]int{} 196 | suffixes := map[int]int{} 197 | for i, c := range columns { 198 | colName := columnName(c.Column, i) 199 | fieldName := FieldName(colName, req.Settings) 200 | baseFieldName := fieldName 201 | // Track suffixes by the ID of the column, so that columns referring to the same numbered parameter can be 202 | // reused. 203 | suffix := 0 204 | if o, ok := suffixes[c.id]; ok && useID { 205 | suffix = o 206 | } else if v := len(seen[fieldName]); v > 0 && !c.IsNamedParam { 207 | suffix = v + 1 208 | } 209 | suffixes[c.id] = suffix 210 | if suffix > 0 { 211 | fieldName = fmt.Sprintf("%s_%d", fieldName, suffix) 212 | } 213 | gs.Fields = append(gs.Fields, Field{ 214 | Name: fieldName, 215 | DBName: colName, 216 | Type: tsType(req, c.Column), 217 | TypecheckTemplate: tsTypecheckTemplate(req, c.Column), 218 | }) 219 | if _, found := seen[baseFieldName]; !found { 220 | seen[baseFieldName] = []int{i} 221 | } else { 222 | seen[baseFieldName] = append(seen[baseFieldName], i) 223 | } 224 | } 225 | 226 | // If a field does not have a known type, but another 227 | // field with the same name has a known type, assign 228 | // the known type to the field without a known type 229 | for i, field := range gs.Fields { 230 | if len(seen[field.Name]) > 1 && field.Type == "interface{}" { 231 | for _, j := range seen[field.Name] { 232 | if i == j { 233 | continue 234 | } 235 | otherField := gs.Fields[j] 236 | if otherField.Type != field.Type { 237 | field.Type = otherField.Type 238 | } 239 | gs.Fields[i] = field 240 | } 241 | } 242 | } 243 | 244 | err := checkIncompatibleFieldTypes(gs.Fields) 245 | if err != nil { 246 | return nil, err 247 | } 248 | 249 | return &gs, nil 250 | } 251 | 252 | func checkIncompatibleFieldTypes(fields []Field) error { 253 | fieldTypes := map[string]string{} 254 | for _, field := range fields { 255 | if fieldType, found := fieldTypes[field.Name]; !found { 256 | fieldTypes[field.Name] = field.Type 257 | } else if field.Type != fieldType { 258 | return fmt.Errorf("named param %s has incompatible types: %s, %s", field.Name, field.Type, fieldType) 259 | } 260 | } 261 | return nil 262 | } 263 | -------------------------------------------------------------------------------- /struct.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/stephen/sqlc-ts/internal/plugin" 7 | "github.com/stephen/sqlc-ts/internal/sdk" 8 | ) 9 | 10 | type Struct struct { 11 | Table plugin.Identifier 12 | Name string 13 | Fields []Field 14 | Comment string 15 | } 16 | 17 | func StructName(name string, settings *plugin.Settings) string { 18 | if rename := settings.Rename[name]; rename != "" { 19 | return rename 20 | } 21 | out := "" 22 | for _, p := range strings.Split(name, "_") { 23 | if p == "id" { 24 | out += p 25 | } else { 26 | out += strings.Title(p) 27 | } 28 | } 29 | return out 30 | } 31 | 32 | func FieldName(name string, settings *plugin.Settings) string { 33 | if rename := settings.Rename[name]; rename != "" { 34 | return rename 35 | } 36 | out := "" 37 | for i, p := range strings.Split(name, "_") { 38 | if i == 0 { 39 | out += sdk.LowerTitle(p) 40 | } else { 41 | out += sdk.Title(p) 42 | } 43 | } 44 | return out 45 | } 46 | -------------------------------------------------------------------------------- /template.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "embed" 4 | 5 | //go:embed templates/* 6 | var templates embed.FS 7 | -------------------------------------------------------------------------------- /templates/template.tmpl: -------------------------------------------------------------------------------- 1 | {{define "queryFile"}}// Code generated by sqlc. DO NOT EDIT. 2 | // source: {{.SourceName}} 3 | 4 | import { Database, QueryExecResult } from "@stephen/sql.js"; 5 | 6 | {{template "queryCode" . }} 7 | {{end}} 8 | 9 | {{define "queryCode"}} 10 | {{range .Queries}} 11 | {{if $.OutputQuery .SourceName}} 12 | const {{.ConstantName}} = {{$.Q}}-- name: {{.MethodName}} {{.Cmd}} 13 | {{escape .SQL}} 14 | {{$.Q}}; 15 | 16 | {{if .Arg.EmitStruct}} 17 | export type {{.Arg.Type}} = { {{- range .Arg.UniqueFields}} 18 | {{.Name}}: {{.Type}}; 19 | {{- end}} 20 | } 21 | {{end}} 22 | 23 | {{if .Ret.EmitStruct}} 24 | export type {{.Ret.Type}} = { {{- range .Ret.Struct.Fields}} 25 | {{.Name}}: {{.Type}}; 26 | {{- end}} 27 | } 28 | {{end}} 29 | 30 | {{if eq .Cmd ":one"}} 31 | {{range .Comments}}//{{.}} 32 | {{end -}} 33 | export function {{.MethodName}}(db: Database, {{.Arg.Pair}}): {{.Ret.DefineType}} | null { 34 | const result = db.exec({{.ConstantName}}, [{{.Arg.Params}}]) 35 | if (result.length !== 1) { 36 | throw new Error("expected exec() to return a single query result") 37 | } 38 | 39 | const queryResult = result[0]; 40 | if (queryResult.values.length !== 1) { 41 | return null; 42 | } 43 | 44 | const row = queryResult.values[0]; 45 | {{if .Ret.EmitStruct}} 46 | {{- range $i, $e := .Ret.UniqueFields}} 47 | {{if not $e.HasTypecheck}} 48 | if ({{$e.Typecheck $i}}) { throw new Error(`expected type {{$e.Type}} for column {{$e.Name}}, but got ${typeof row[{{$i}}]}`) }; 49 | {{end}} 50 | {{- end}} 51 | const rv: {{.Ret.DefineType}} = { {{- range $i, $e := .Ret.UniqueFields}} 52 | {{$e.Name}}: row[{{$i}}], 53 | {{- end}} 54 | }; 55 | {{else}} 56 | {{if not .Ret.HasTypecheck}} 57 | if ({{.Ret.Typecheck}}) { throw new Error(`expected type {{.Ret.Typ}} for column {{.Ret.Name}}, but got ${typeof row[0]}`) }; 58 | const rv: {{.Ret.Typ}} = row[0]; 59 | {{end}} 60 | {{end}} 61 | return rv; 62 | } 63 | {{end}} 64 | 65 | {{if eq .Cmd ":many"}} 66 | {{range .Comments}}//{{.}} 67 | {{end -}} 68 | export function {{.MethodName}}(db: Database, {{.Arg.Pair}}): {{.Ret.DefineType}}[] { 69 | const result = db.exec({{.ConstantName}}, [{{.Arg.Params}}]) 70 | if (result.length !== 1) { 71 | throw new Error("expected exec() to return a single query result") 72 | } 73 | 74 | const queryResult = result[0]; 75 | const rvs: {{.Ret.DefineType}}[] = []; 76 | 77 | for (const row of queryResult.values) { 78 | {{if .Ret.EmitStruct}} 79 | {{- range $i, $e := .Ret.UniqueFields}} 80 | {{if not $e.HasTypecheck}} 81 | if ({{$e.Typecheck $i}}) { throw new Error(`expected type {{$e.Type}} for column {{$e.Name}}, but got ${typeof row[{{$i}}]}`) }; 82 | {{end}} 83 | {{- end}} 84 | const rv: {{.Ret.DefineType}} = { {{- range $i, $e := .Ret.UniqueFields}} 85 | {{$e.Name}}: row[{{$i}}], 86 | {{- end}} 87 | }; 88 | {{else}} 89 | {{if not .Ret.HasTypecheck}} 90 | if ({{.Ret.Typecheck}}) { throw new Error(`expected type {{.Ret.Typ}} for column {{.Ret.Name}}, but got ${typeof row[0]}`) }; 91 | {{end}} 92 | const rv: {{.Ret.Typ}} = row[0]; 93 | {{end}} 94 | rvs.push(rv); 95 | } 96 | return rvs; 97 | } 98 | {{end}} 99 | 100 | {{if eq .Cmd ":exec"}} 101 | {{range .Comments}}//{{.}} 102 | {{end -}} 103 | export function {{.MethodName}}(db: Database, {{.Arg.Pair}}): void { 104 | db.exec({{.ConstantName}}, [{{.Arg.Params}}]) 105 | } 106 | {{end}} 107 | 108 | {{if eq .Cmd ":execrows"}} 109 | {{range .Comments}}//{{.}} 110 | {{end -}} 111 | export function {{.MethodName}}(db: Database, {{.Arg.Pair}}): number { 112 | const result = db.exec({{.ConstantName}}, [{{.Arg.Params}}]) 113 | if (result.length !== 1) { 114 | throw new Error("expected exec() to return a single query result") 115 | } 116 | 117 | return result[0].values.length; 118 | } 119 | {{end}} 120 | 121 | {{if eq .Cmd ":execresult"}} 122 | {{range .Comments}}//{{.}} 123 | {{end -}} 124 | export function {{.MethodName}}(db: Database, {{.Arg.Pair}}): QueryExecResult { 125 | const result = db.exec({{.ConstantName}}, [{{.Arg.Params}}]); 126 | if (result.length !== 1) { 127 | throw new Error("expected exec() to return a single query result") 128 | } 129 | 130 | return result[0]; 131 | } 132 | {{end}} 133 | 134 | {{end}} 135 | {{end}} 136 | {{end}} 137 | -------------------------------------------------------------------------------- /testdata/query.sql: -------------------------------------------------------------------------------- 1 | /* name: GetAuthor :one */ 2 | SELECT * FROM authors 3 | WHERE id = ? LIMIT 1; 4 | 5 | /* name: ListAuthors :many */ 6 | SELECT * FROM authors 7 | ORDER BY name; 8 | 9 | /* name: CreateAuthor :execresult */ 10 | INSERT INTO authors ( 11 | name, bio 12 | ) VALUES ( 13 | ?, ? 14 | ); 15 | 16 | /* name: DeleteAuthor :exec */ 17 | DELETE FROM authors 18 | WHERE id = ?; 19 | 20 | /* name: SearchAuthorsByName :many */ 21 | select id from authors where name like '%' || @text || '%'; 22 | 23 | /* name: SearchAuthorsByNameWithUnknown :many */ 24 | select cast(id as INTEGER) from authors where name like '%' || @text || '%'; 25 | 26 | /* name: CountAuthors :one */ 27 | select count(1) from authors; 28 | -------------------------------------------------------------------------------- /testdata/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE authors ( 2 | id INTEGER PRIMARY KEY AUTOINCREMENT, 3 | name text NOT NULL, 4 | bio text 5 | ); 6 | -------------------------------------------------------------------------------- /testdata/sqlc.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2", 3 | "plugins": [ 4 | { 5 | "name": "ts", 6 | "process": { 7 | "cmd": "./bin/sqlc-ts" 8 | } 9 | } 10 | ], 11 | "sql": [ 12 | { 13 | "schema": "schema.sql", 14 | "queries": "query.sql", 15 | "engine": "sqlite", 16 | "codegen": [ 17 | { 18 | "out": "gen", 19 | "plugin": "ts" 20 | } 21 | ] 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /ts_type.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "strings" 7 | 8 | "github.com/stephen/sqlc-ts/internal/plugin" 9 | "github.com/stephen/sqlc-ts/internal/sdk" 10 | ) 11 | 12 | func tsTypecheckTemplate(req *plugin.CodeGenRequest, col *plugin.Column) string { 13 | typ := sqliteType(req, col) 14 | if typ == "unknown" { 15 | return "" 16 | } 17 | 18 | cond := fmt.Sprintf(`typeof %% !== "%s"`, typ) 19 | if !col.NotNull { 20 | cond = fmt.Sprintf(`%s && %% !== null`, cond) 21 | } 22 | 23 | if col.IsArray { 24 | cond = fmt.Sprintf(`!Array.isArray(%%) || %%.some(e => %s)`, strings.ReplaceAll(cond, "%%", "e")) 25 | } 26 | 27 | return cond 28 | } 29 | 30 | func tsType(req *plugin.CodeGenRequest, col *plugin.Column) string { 31 | typ := sqliteType(req, col) 32 | if typ == "unknown" { 33 | return typ 34 | } 35 | 36 | if !col.NotNull { 37 | typ = fmt.Sprintf("%s | null", typ) 38 | } 39 | 40 | if col.IsArray { 41 | typ = fmt.Sprintf("%s[]", typ) 42 | } 43 | 44 | return typ 45 | } 46 | 47 | func sqliteType(req *plugin.CodeGenRequest, col *plugin.Column) string { 48 | dt := strings.ToLower(sdk.DataType(col.Type)) 49 | 50 | switch dt { 51 | case "int", "integer", "tinyint", "smallint", "mediumint", "bigint", "unsignedbigint", "int2", "int8", "numeric", "decimal", "real", "double", "doubleprecision", "float": 52 | return "number" 53 | 54 | case "blob": 55 | return "Uint8Array" 56 | 57 | case "boolean": 58 | return "boolean" 59 | 60 | case "date", "datetime", "timestamp": 61 | return "Date" 62 | 63 | case "any": 64 | // XXX: is this right? 65 | return "unknown" 66 | } 67 | 68 | switch { 69 | case strings.HasPrefix(dt, "character"), 70 | strings.HasPrefix(dt, "varchar"), 71 | strings.HasPrefix(dt, "varyingcharacter"), 72 | strings.HasPrefix(dt, "nchar"), 73 | strings.HasPrefix(dt, "nativecharacter"), 74 | strings.HasPrefix(dt, "nvarchar"), 75 | dt == "text", 76 | dt == "clob": 77 | return "string" 78 | 79 | default: 80 | log.Printf("unknown SQLite type: %s\n", dt) 81 | // XXX: is this right? or prefer any? 82 | return "unknown" 83 | } 84 | } 85 | --------------------------------------------------------------------------------