diff --git a/Makefile b/Makefile index d393ad90b8..160df6e4e5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build build-endtoend test test-ci test-examples test-endtoend regen start psql mysqlsh +.PHONY: build build-endtoend test test-ci test-examples test-endtoend regen start psql mysqlsh proto build: go build ./... @@ -44,16 +44,5 @@ psql: mysqlsh: mysqlsh --sql --user root --password mysecretpassword --database dinotest 127.0.0.1:3306 -# $ protoc --version -# libprotoc 3.19.1 -# $ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest -# $ go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto -proto: internal/plugin/codegen.pb.go - -internal/plugin/codegen.pb.go: protos/plugin/codegen.proto - protoc -I ./protos \ - --go_out=. \ - --go_opt=module=github.com/kyleconroy/sqlc \ - --go-vtproto_out=. \ - --go-vtproto_opt=module=github.com/kyleconroy/sqlc,features=marshal+unmarshal+size \ - ./protos/plugin/codegen.proto +proto: + buf generate diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 0000000000..4b7ebb7130 --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,10 @@ +version: v1 +managed: + enabled: true +plugins: + - remote: buf.build/protocolbuffers/plugins/go:v1.28.1-1 + out: internal + opt: paths=source_relative + - remote: buf.build/planetscale/plugins/vtproto:v0.3.0 + out: internal + opt: paths=source_relative \ No newline at end of file diff --git a/buf.work.yaml b/buf.work.yaml new file mode 100644 index 0000000000..0ad435358d --- /dev/null +++ b/buf.work.yaml @@ -0,0 +1,3 @@ +version: v1 +directories: + - protos \ No newline at end of file diff --git a/internal/plugin/codegen.pb.go b/internal/plugin/codegen.pb.go index e95ce2f399..c443da7210 100644 --- a/internal/plugin/codegen.pb.go +++ b/internal/plugin/codegen.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.19.4 +// protoc (unknown) // source: plugin/codegen.proto package plugin @@ -1758,11 +1758,16 @@ var file_plugin_codegen_proto_rawDesc = []byte{ 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x35, 0x0a, 0x0f, 0x43, 0x6f, 0x64, 0x65, 0x47, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, - 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x42, 0x2c, 0x5a, 0x2a, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x79, 0x6c, 0x65, 0x63, - 0x6f, 0x6e, 0x72, 0x6f, 0x79, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x42, 0x7e, 0x0a, 0x0a, + 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x42, 0x0c, 0x43, 0x6f, 0x64, 0x65, + 0x67, 0x65, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x79, 0x6c, 0x65, 0x63, 0x6f, 0x6e, 0x72, 0x6f, + 0x79, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, + 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x50, + 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xca, 0x02, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xe2, 0x02, + 0x12, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/internal/plugin/codegen_vtproto.pb.go b/internal/plugin/codegen_vtproto.pb.go index 3c86c30179..736d61ffd9 100644 --- a/internal/plugin/codegen_vtproto.pb.go +++ b/internal/plugin/codegen_vtproto.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.2.0 +// protoc-gen-go-vtproto version: v0.3.0 // source: plugin/codegen.proto package plugin @@ -18,6 +18,547 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +func (this *File) EqualVT(that *File) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Name != that.Name { + return false + } + if string(this.Contents) != string(that.Contents) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Override) EqualVT(that *Override) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.CodeType != that.CodeType { + return false + } + if this.DbType != that.DbType { + return false + } + if this.Nullable != that.Nullable { + return false + } + if this.Column != that.Column { + return false + } + if !this.Table.EqualVT(that.Table) { + return false + } + if this.ColumnName != that.ColumnName { + return false + } + if !this.GoType.EqualVT(that.GoType) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ParsedGoType) EqualVT(that *ParsedGoType) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.ImportPath != that.ImportPath { + return false + } + if this.Package != that.Package { + return false + } + if this.TypeName != that.TypeName { + return false + } + if this.BasicType != that.BasicType { + return false + } + if len(this.StructTags) != len(that.StructTags) { + return false + } + for i := range this.StructTags { + if this.StructTags[i] != that.StructTags[i] { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Settings) EqualVT(that *Settings) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Version != that.Version { + return false + } + if this.Engine != that.Engine { + return false + } + if len(this.Schema) != len(that.Schema) { + return false + } + for i := range this.Schema { + if this.Schema[i] != that.Schema[i] { + return false + } + } + if len(this.Queries) != len(that.Queries) { + return false + } + for i := range this.Queries { + if this.Queries[i] != that.Queries[i] { + return false + } + } + if len(this.Rename) != len(that.Rename) { + return false + } + for i := range this.Rename { + if this.Rename[i] != that.Rename[i] { + return false + } + } + if len(this.Overrides) != len(that.Overrides) { + return false + } + for i := range this.Overrides { + if !this.Overrides[i].EqualVT(that.Overrides[i]) { + return false + } + } + if !this.Go.EqualVT(that.Go) { + return false + } + if !this.Json.EqualVT(that.Json) { + return false + } + if !this.Codegen.EqualVT(that.Codegen) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Codegen) EqualVT(that *Codegen) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Out != that.Out { + return false + } + if this.Plugin != that.Plugin { + return false + } + if string(this.Options) != string(that.Options) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *GoCode) EqualVT(that *GoCode) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.EmitInterface != that.EmitInterface { + return false + } + if this.EmitJsonTags != that.EmitJsonTags { + return false + } + if this.EmitDbTags != that.EmitDbTags { + return false + } + if this.EmitPreparedQueries != that.EmitPreparedQueries { + return false + } + if this.EmitExactTableNames != that.EmitExactTableNames { + return false + } + if this.EmitEmptySlices != that.EmitEmptySlices { + return false + } + if this.EmitExportedQueries != that.EmitExportedQueries { + return false + } + if this.EmitResultStructPointers != that.EmitResultStructPointers { + return false + } + if this.EmitParamsStructPointers != that.EmitParamsStructPointers { + return false + } + if this.EmitMethodsWithDbArgument != that.EmitMethodsWithDbArgument { + return false + } + if this.JsonTagsCaseStyle != that.JsonTagsCaseStyle { + return false + } + if this.Package != that.Package { + return false + } + if this.Out != that.Out { + return false + } + if this.SqlPackage != that.SqlPackage { + return false + } + if this.OutputDbFileName != that.OutputDbFileName { + return false + } + if this.OutputModelsFileName != that.OutputModelsFileName { + return false + } + if this.OutputQuerierFileName != that.OutputQuerierFileName { + return false + } + if this.OutputFilesSuffix != that.OutputFilesSuffix { + return false + } + if this.EmitEnumValidMethod != that.EmitEnumValidMethod { + return false + } + if this.EmitAllEnumValues != that.EmitAllEnumValues { + return false + } + if len(this.InflectionExcludeTableNames) != len(that.InflectionExcludeTableNames) { + return false + } + for i := range this.InflectionExcludeTableNames { + if this.InflectionExcludeTableNames[i] != that.InflectionExcludeTableNames[i] { + return false + } + } + if this.EmitPointersForNullTypes != that.EmitPointersForNullTypes { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *JSONCode) EqualVT(that *JSONCode) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Out != that.Out { + return false + } + if this.Indent != that.Indent { + return false + } + if this.Filename != that.Filename { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Catalog) EqualVT(that *Catalog) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Comment != that.Comment { + return false + } + if this.DefaultSchema != that.DefaultSchema { + return false + } + if this.Name != that.Name { + return false + } + if len(this.Schemas) != len(that.Schemas) { + return false + } + for i := range this.Schemas { + if !this.Schemas[i].EqualVT(that.Schemas[i]) { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Schema) EqualVT(that *Schema) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Comment != that.Comment { + return false + } + if this.Name != that.Name { + return false + } + if len(this.Tables) != len(that.Tables) { + return false + } + for i := range this.Tables { + if !this.Tables[i].EqualVT(that.Tables[i]) { + return false + } + } + if len(this.Enums) != len(that.Enums) { + return false + } + for i := range this.Enums { + if !this.Enums[i].EqualVT(that.Enums[i]) { + return false + } + } + if len(this.CompositeTypes) != len(that.CompositeTypes) { + return false + } + for i := range this.CompositeTypes { + if !this.CompositeTypes[i].EqualVT(that.CompositeTypes[i]) { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CompositeType) EqualVT(that *CompositeType) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Name != that.Name { + return false + } + if this.Comment != that.Comment { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Enum) EqualVT(that *Enum) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Name != that.Name { + return false + } + if len(this.Vals) != len(that.Vals) { + return false + } + for i := range this.Vals { + if this.Vals[i] != that.Vals[i] { + return false + } + } + if this.Comment != that.Comment { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Table) EqualVT(that *Table) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if !this.Rel.EqualVT(that.Rel) { + return false + } + if len(this.Columns) != len(that.Columns) { + return false + } + for i := range this.Columns { + if !this.Columns[i].EqualVT(that.Columns[i]) { + return false + } + } + if this.Comment != that.Comment { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Identifier) EqualVT(that *Identifier) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Catalog != that.Catalog { + return false + } + if this.Schema != that.Schema { + return false + } + if this.Name != that.Name { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Column) EqualVT(that *Column) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Name != that.Name { + return false + } + if this.NotNull != that.NotNull { + return false + } + if this.IsArray != that.IsArray { + return false + } + if this.Comment != that.Comment { + return false + } + if this.Length != that.Length { + return false + } + if this.IsNamedParam != that.IsNamedParam { + return false + } + if this.IsFuncCall != that.IsFuncCall { + return false + } + if this.Scope != that.Scope { + return false + } + if !this.Table.EqualVT(that.Table) { + return false + } + if this.TableAlias != that.TableAlias { + return false + } + if !this.Type.EqualVT(that.Type) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Query) EqualVT(that *Query) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Text != that.Text { + return false + } + if this.Name != that.Name { + return false + } + if this.Cmd != that.Cmd { + return false + } + if len(this.Columns) != len(that.Columns) { + return false + } + for i := range this.Columns { + if !this.Columns[i].EqualVT(that.Columns[i]) { + return false + } + } + if len(this.Params) != len(that.Params) { + return false + } + for i := range this.Params { + if !this.Params[i].EqualVT(that.Params[i]) { + return false + } + } + if len(this.Comments) != len(that.Comments) { + return false + } + for i := range this.Comments { + if this.Comments[i] != that.Comments[i] { + return false + } + } + if this.Filename != that.Filename { + return false + } + if !this.InsertIntoTable.EqualVT(that.InsertIntoTable) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Parameter) EqualVT(that *Parameter) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if this.Number != that.Number { + return false + } + if !this.Column.EqualVT(that.Column) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CodeGenRequest) EqualVT(that *CodeGenRequest) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if !this.Settings.EqualVT(that.Settings) { + return false + } + if !this.Catalog.EqualVT(that.Catalog) { + return false + } + if len(this.Queries) != len(that.Queries) { + return false + } + for i := range this.Queries { + if !this.Queries[i].EqualVT(that.Queries[i]) { + return false + } + } + if this.SqlcVersion != that.SqlcVersion { + return false + } + if string(this.PluginOptions) != string(that.PluginOptions) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CodeGenResponse) EqualVT(that *CodeGenResponse) bool { + if this == nil { + return that == nil || fmt.Sprintf("%v", that) == "" + } else if that == nil { + return fmt.Sprintf("%v", this) == "" + } + if len(this.Files) != len(that.Files) { + return false + } + for i := range this.Files { + if !this.Files[i].EqualVT(that.Files[i]) { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + func (m *File) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil diff --git a/protos/buf.yaml b/protos/buf.yaml new file mode 100644 index 0000000000..c07f71c53b --- /dev/null +++ b/protos/buf.yaml @@ -0,0 +1,8 @@ +version: v1 +name: github.com/kyleconroy/sqlc +breaking: +lint: + use: + - DEFAULT + except: + - PACKAGE_VERSION_SUFFIX \ No newline at end of file