diff --git a/internal/cmd/verify.go b/internal/cmd/verify.go index 3a19d27f86..5bb165a7ea 100644 --- a/internal/cmd/verify.go +++ b/internal/cmd/verify.go @@ -2,14 +2,22 @@ package cmd import ( "context" + "database/sql" "fmt" + "log/slog" "os" + _ "github.com/jackc/pgx/v5/stdlib" "github.com/spf13/cobra" + "google.golang.org/protobuf/proto" - "github.com/sqlc-dev/sqlc/internal/bundler" + "github.com/sqlc-dev/sqlc/internal/config" + "github.com/sqlc-dev/sqlc/internal/dbmanager" + "github.com/sqlc-dev/sqlc/internal/migrations" + "github.com/sqlc-dev/sqlc/internal/plugin" "github.com/sqlc-dev/sqlc/internal/quickdb" - quickdbv1 "github.com/sqlc-dev/sqlc/internal/quickdb/v1" + pb "github.com/sqlc-dev/sqlc/internal/quickdb/v1" + "github.com/sqlc-dev/sqlc/internal/sql/sqlpath" ) func init() { @@ -32,7 +40,6 @@ var verifyCmd = &cobra.Command{ Against: against, } if err := Verify(cmd.Context(), dir, name, opts); err != nil { - fmt.Fprintf(stderr, "error verifying: %s\n", err) os.Exit(1) } return nil @@ -41,50 +48,103 @@ var verifyCmd = &cobra.Command{ func Verify(ctx context.Context, dir, filename string, opts *Options) error { stderr := opts.Stderr - configPath, conf, err := readConfig(stderr, dir, filename) + _, conf, err := readConfig(stderr, dir, filename) if err != nil { return err } + client, err := quickdb.NewClientFromConfig(conf.Cloud) if err != nil { return fmt.Errorf("client init failed: %w", err) } - p := &pusher{} - if err := Process(ctx, p, dir, filename, opts); err != nil { - return err - } - req, err := bundler.BuildRequest(ctx, dir, configPath, p.results, nil) - if err != nil { - return err - } - if val := os.Getenv("CI"); val != "" { - req.Annotations["env.ci"] = val - } - if val := os.Getenv("GITHUB_RUN_ID"); val != "" { - req.Annotations["github.run.id"] = val - } - resp, err := client.VerifyQuerySets(ctx, &quickdbv1.VerifyQuerySetsRequest{ - Against: opts.Against, - SqlcVersion: req.SqlcVersion, - QuerySets: req.QuerySets, - Config: req.Config, - Annotations: req.Annotations, + manager := dbmanager.NewClient(conf.Servers) + + // Get query sets from a previous archive by tag. If no tag is provided, get + // the latest query sets. + previous, err := client.GetQuerySets(ctx, &pb.GetQuerySetsRequest{ + Tag: opts.Against, }) if err != nil { return err } - summaryPath := os.Getenv("GITHUB_STEP_SUMMARY") - if resp.Summary != "" { - if _, err := os.Stat(summaryPath); err == nil { - if err := os.WriteFile(summaryPath, []byte(resp.Summary), 0644); err != nil { + + // Create a mapping of name to query set + existing := map[string]config.SQL{} + for _, qs := range conf.SQL { + existing[qs.Name] = qs + } + + for _, qs := range previous.QuerySets { + // TODO: Create a function for this so that we can return early on errors + + check := func() error { + if qs.Name == "" { + return fmt.Errorf("unnamed query set") + } + + current, found := existing[qs.Name] + if !found { + return fmt.Errorf("unknown query set: %s", qs.Name) + } + + // Read the schema files into memory, removing rollback statements + var ddl []string + files, err := sqlpath.Glob(current.Schema) + if err != nil { return err } + for _, schema := range files { + contents, err := os.ReadFile(schema) + if err != nil { + return fmt.Errorf("read file: %w", err) + } + ddl = append(ddl, migrations.RemoveRollbackStatements(string(contents))) + } + + var codegen plugin.GenerateRequest + if err := proto.Unmarshal(qs.CodegenRequest.Contents, &codegen); err != nil { + return err + } + + // Create (or re-use) a database to verify against + resp, err := manager.CreateDatabase(ctx, &dbmanager.CreateDatabaseRequest{ + Migrations: ddl, + }) + if err != nil { + return err + } + + db, err := sql.Open("pgx", resp.Uri) + if err != nil { + return err + } + defer db.Close() + + for _, query := range codegen.Queries { + stmt, err := db.PrepareContext(ctx, query.Text) + if err != nil { + fmt.Fprintf(stderr, "Failed to prepare the following query:\n") + fmt.Fprintf(stderr, "%s\n", query.Text) + fmt.Fprintf(stderr, "Error was: %s\n", err) + continue + } + if err := stmt.Close(); err != nil { + slog.Error("stmt.Close failed", "err", err) + } + } + + return nil + } + + if err := check(); err != nil { + fmt.Fprintf(stderr, "FAIL\t%s\n", qs.Name) + } else { + fmt.Fprintf(stderr, "ok\t%s\n", qs.Name) } } - fmt.Fprintf(stderr, resp.Output) - if resp.Errored { - return fmt.Errorf("BREAKING CHANGES DETECTED") - } + + // return fmt.Errorf("BREAKING CHANGES DETECTED") + return nil } diff --git a/internal/quickdb/v1/quickdb.pb.go b/internal/quickdb/v1/quickdb.pb.go index 39b61a4c18..690dfc16f1 100755 --- a/internal/quickdb/v1/quickdb.pb.go +++ b/internal/quickdb/v1/quickdb.pb.go @@ -641,6 +641,100 @@ func (x *VerifyQuerySetsResponse) GetSummary() string { return "" } +type GetQuerySetsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` +} + +func (x *GetQuerySetsRequest) Reset() { + *x = GetQuerySetsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_quickdb_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetQuerySetsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetQuerySetsRequest) ProtoMessage() {} + +func (x *GetQuerySetsRequest) ProtoReflect() protoreflect.Message { + mi := &file_v1_quickdb_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetQuerySetsRequest.ProtoReflect.Descriptor instead. +func (*GetQuerySetsRequest) Descriptor() ([]byte, []int) { + return file_v1_quickdb_proto_rawDescGZIP(), []int{10} +} + +func (x *GetQuerySetsRequest) GetTag() string { + if x != nil { + return x.Tag + } + return "" +} + +type GetQuerySetsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + QuerySets []*QuerySet `protobuf:"bytes,1,rep,name=query_sets,json=querySets,proto3" json:"query_sets,omitempty"` +} + +func (x *GetQuerySetsResponse) Reset() { + *x = GetQuerySetsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_quickdb_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetQuerySetsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetQuerySetsResponse) ProtoMessage() {} + +func (x *GetQuerySetsResponse) ProtoReflect() protoreflect.Message { + mi := &file_v1_quickdb_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetQuerySetsResponse.ProtoReflect.Descriptor instead. +func (*GetQuerySetsResponse) Descriptor() ([]byte, []int) { + return file_v1_quickdb_proto_rawDescGZIP(), []int{11} +} + +func (x *GetQuerySetsResponse) GetQuerySets() []*QuerySet { + if x != nil { + return x.QuerySets + } + return nil +} + var File_v1_quickdb_proto protoreflect.FileDescriptor var file_v1_quickdb_proto_rawDesc = []byte{ @@ -749,56 +843,72 @@ var file_v1_quickdb_proto_rawDesc = []byte{ 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x6d, - 0x6d, 0x61, 0x72, 0x79, 0x32, 0x9d, 0x04, 0x0a, 0x05, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x12, 0x92, - 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, - 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x3a, 0x2e, 0x72, 0x65, 0x6d, - 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, - 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, - 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, - 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, - 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, - 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x8c, 0x01, 0x0a, 0x15, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, - 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x38, 0x2e, + 0x6d, 0x61, 0x72, 0x79, 0x22, 0x27, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, + 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x5b, 0x0a, + 0x14, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x0a, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, + 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x72, 0x65, 0x6d, 0x6f, + 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, + 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x74, 0x52, + 0x09, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x74, 0x73, 0x32, 0x90, 0x05, 0x0a, 0x05, 0x51, + 0x75, 0x69, 0x63, 0x6b, 0x12, 0x92, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, + 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, + 0x12, 0x3a, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, + 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, + 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x72, + 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, + 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x8c, 0x01, 0x0a, 0x15, 0x44, 0x72, + 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, + 0x61, 0x73, 0x65, 0x12, 0x38, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, + 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, + 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, + 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, - 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, - 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x72, 0x6f, 0x70, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, - 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x74, 0x0a, 0x0d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, - 0x69, 0x76, 0x65, 0x12, 0x30, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, - 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, - 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, - 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, - 0x76, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7a, 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x69, - 0x66, 0x79, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x74, 0x73, 0x12, 0x32, 0x2e, 0x72, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x74, 0x0a, 0x0d, 0x55, 0x70, 0x6c, 0x6f, + 0x61, 0x64, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x12, 0x30, 0x2e, 0x72, 0x65, 0x6d, 0x6f, + 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, + 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x72, 0x63, + 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, - 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x33, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, - 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x65, 0x72, - 0x69, 0x66, 0x79, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xeb, 0x01, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x72, 0x65, 0x6d, + 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x41, + 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7a, + 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x74, + 0x73, 0x12, 0x32, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, + 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x56, + 0x65, 0x72, 0x69, 0x66, 0x79, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, + 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, + 0x76, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, 0x0a, 0x0c, 0x47, 0x65, + 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x65, 0x74, 0x73, 0x12, 0x2f, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, - 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x73, 0x71, 0x6c, - 0x63, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x71, 0x75, - 0x69, 0x63, 0x6b, 0x64, 0x62, 0x76, 0x31, 0xa2, 0x02, 0x04, 0x52, 0x53, 0x44, 0x51, 0xaa, 0x02, - 0x1a, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x53, 0x71, 0x6c, 0x63, 0x2e, 0x44, 0x65, 0x76, - 0x2e, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x1a, 0x52, 0x65, - 0x6d, 0x6f, 0x74, 0x65, 0x5c, 0x53, 0x71, 0x6c, 0x63, 0x5c, 0x44, 0x65, 0x76, 0x5c, 0x51, 0x75, - 0x69, 0x63, 0x6b, 0x64, 0x62, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x26, 0x52, 0x65, 0x6d, 0x6f, 0x74, - 0x65, 0x5c, 0x53, 0x71, 0x6c, 0x63, 0x5c, 0x44, 0x65, 0x76, 0x5c, 0x51, 0x75, 0x69, 0x63, 0x6b, - 0x64, 0x62, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x1e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3a, 0x3a, 0x53, 0x71, 0x6c, 0x63, - 0x3a, 0x3a, 0x44, 0x65, 0x76, 0x3a, 0x3a, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x72, 0x65, + 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, + 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xeb, 0x01, + 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x73, 0x71, 0x6c, + 0x63, 0x2e, 0x64, 0x65, 0x76, 0x2e, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x2e, 0x76, 0x31, + 0x42, 0x0c, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x71, 0x6c, + 0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x73, 0x71, 0x6c, 0x63, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x76, 0x31, + 0xa2, 0x02, 0x04, 0x52, 0x53, 0x44, 0x51, 0xaa, 0x02, 0x1a, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, + 0x2e, 0x53, 0x71, 0x6c, 0x63, 0x2e, 0x44, 0x65, 0x76, 0x2e, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x64, + 0x62, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x1a, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5c, 0x53, 0x71, + 0x6c, 0x63, 0x5c, 0x44, 0x65, 0x76, 0x5c, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x5c, 0x56, + 0x31, 0xe2, 0x02, 0x26, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5c, 0x53, 0x71, 0x6c, 0x63, 0x5c, + 0x44, 0x65, 0x76, 0x5c, 0x51, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x5c, 0x56, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1e, 0x52, 0x65, 0x6d, + 0x6f, 0x74, 0x65, 0x3a, 0x3a, 0x53, 0x71, 0x6c, 0x63, 0x3a, 0x3a, 0x44, 0x65, 0x76, 0x3a, 0x3a, + 0x51, 0x75, 0x69, 0x63, 0x6b, 0x64, 0x62, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -813,7 +923,7 @@ func file_v1_quickdb_proto_rawDescGZIP() []byte { return file_v1_quickdb_proto_rawDescData } -var file_v1_quickdb_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_v1_quickdb_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_v1_quickdb_proto_goTypes = []interface{}{ (*CreateEphemeralDatabaseRequest)(nil), // 0: remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseRequest (*CreateEphemeralDatabaseResponse)(nil), // 1: remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseResponse @@ -825,8 +935,10 @@ var file_v1_quickdb_proto_goTypes = []interface{}{ (*UploadArchiveResponse)(nil), // 7: remote.sqlc.dev.quickdb.v1.UploadArchiveResponse (*VerifyQuerySetsRequest)(nil), // 8: remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest (*VerifyQuerySetsResponse)(nil), // 9: remote.sqlc.dev.quickdb.v1.VerifyQuerySetsResponse - nil, // 10: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.AnnotationsEntry - nil, // 11: remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest.AnnotationsEntry + (*GetQuerySetsRequest)(nil), // 10: remote.sqlc.dev.quickdb.v1.GetQuerySetsRequest + (*GetQuerySetsResponse)(nil), // 11: remote.sqlc.dev.quickdb.v1.GetQuerySetsResponse + nil, // 12: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.AnnotationsEntry + nil, // 13: remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest.AnnotationsEntry } var file_v1_quickdb_proto_depIdxs = []int32{ 4, // 0: remote.sqlc.dev.quickdb.v1.QuerySet.schema:type_name -> remote.sqlc.dev.quickdb.v1.File @@ -834,25 +946,28 @@ var file_v1_quickdb_proto_depIdxs = []int32{ 4, // 2: remote.sqlc.dev.quickdb.v1.QuerySet.codegen_request:type_name -> remote.sqlc.dev.quickdb.v1.File 4, // 3: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.inputs:type_name -> remote.sqlc.dev.quickdb.v1.File 4, // 4: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.outputs:type_name -> remote.sqlc.dev.quickdb.v1.File - 10, // 5: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.annotations:type_name -> remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.AnnotationsEntry + 12, // 5: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.annotations:type_name -> remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.AnnotationsEntry 5, // 6: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.query_sets:type_name -> remote.sqlc.dev.quickdb.v1.QuerySet 4, // 7: remote.sqlc.dev.quickdb.v1.UploadArchiveRequest.config:type_name -> remote.sqlc.dev.quickdb.v1.File 5, // 8: remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest.query_sets:type_name -> remote.sqlc.dev.quickdb.v1.QuerySet 4, // 9: remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest.config:type_name -> remote.sqlc.dev.quickdb.v1.File - 11, // 10: remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest.annotations:type_name -> remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest.AnnotationsEntry - 0, // 11: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseRequest - 2, // 12: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseRequest - 6, // 13: remote.sqlc.dev.quickdb.v1.Quick.UploadArchive:input_type -> remote.sqlc.dev.quickdb.v1.UploadArchiveRequest - 8, // 14: remote.sqlc.dev.quickdb.v1.Quick.VerifyQuerySets:input_type -> remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest - 1, // 15: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseResponse - 3, // 16: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseResponse - 7, // 17: remote.sqlc.dev.quickdb.v1.Quick.UploadArchive:output_type -> remote.sqlc.dev.quickdb.v1.UploadArchiveResponse - 9, // 18: remote.sqlc.dev.quickdb.v1.Quick.VerifyQuerySets:output_type -> remote.sqlc.dev.quickdb.v1.VerifyQuerySetsResponse - 15, // [15:19] is the sub-list for method output_type - 11, // [11:15] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 13, // 10: remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest.annotations:type_name -> remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest.AnnotationsEntry + 5, // 11: remote.sqlc.dev.quickdb.v1.GetQuerySetsResponse.query_sets:type_name -> remote.sqlc.dev.quickdb.v1.QuerySet + 0, // 12: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseRequest + 2, // 13: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:input_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseRequest + 6, // 14: remote.sqlc.dev.quickdb.v1.Quick.UploadArchive:input_type -> remote.sqlc.dev.quickdb.v1.UploadArchiveRequest + 8, // 15: remote.sqlc.dev.quickdb.v1.Quick.VerifyQuerySets:input_type -> remote.sqlc.dev.quickdb.v1.VerifyQuerySetsRequest + 10, // 16: remote.sqlc.dev.quickdb.v1.Quick.GetQuerySets:input_type -> remote.sqlc.dev.quickdb.v1.GetQuerySetsRequest + 1, // 17: remote.sqlc.dev.quickdb.v1.Quick.CreateEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.CreateEphemeralDatabaseResponse + 3, // 18: remote.sqlc.dev.quickdb.v1.Quick.DropEphemeralDatabase:output_type -> remote.sqlc.dev.quickdb.v1.DropEphemeralDatabaseResponse + 7, // 19: remote.sqlc.dev.quickdb.v1.Quick.UploadArchive:output_type -> remote.sqlc.dev.quickdb.v1.UploadArchiveResponse + 9, // 20: remote.sqlc.dev.quickdb.v1.Quick.VerifyQuerySets:output_type -> remote.sqlc.dev.quickdb.v1.VerifyQuerySetsResponse + 11, // 21: remote.sqlc.dev.quickdb.v1.Quick.GetQuerySets:output_type -> remote.sqlc.dev.quickdb.v1.GetQuerySetsResponse + 17, // [17:22] is the sub-list for method output_type + 12, // [12:17] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_v1_quickdb_proto_init() } @@ -981,6 +1096,30 @@ func file_v1_quickdb_proto_init() { return nil } } + file_v1_quickdb_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetQuerySetsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_v1_quickdb_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetQuerySetsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -988,7 +1127,7 @@ func file_v1_quickdb_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_v1_quickdb_proto_rawDesc, NumEnums: 0, - NumMessages: 12, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/quickdb/v1/quickdb_grpc.pb.go b/internal/quickdb/v1/quickdb_grpc.pb.go index 97b25abe65..f8f4a131fc 100644 --- a/internal/quickdb/v1/quickdb_grpc.pb.go +++ b/internal/quickdb/v1/quickdb_grpc.pb.go @@ -23,6 +23,7 @@ const ( Quick_DropEphemeralDatabase_FullMethodName = "/remote.sqlc.dev.quickdb.v1.Quick/DropEphemeralDatabase" Quick_UploadArchive_FullMethodName = "/remote.sqlc.dev.quickdb.v1.Quick/UploadArchive" Quick_VerifyQuerySets_FullMethodName = "/remote.sqlc.dev.quickdb.v1.Quick/VerifyQuerySets" + Quick_GetQuerySets_FullMethodName = "/remote.sqlc.dev.quickdb.v1.Quick/GetQuerySets" ) // QuickClient is the client API for Quick service. @@ -33,6 +34,7 @@ type QuickClient interface { DropEphemeralDatabase(ctx context.Context, in *DropEphemeralDatabaseRequest, opts ...grpc.CallOption) (*DropEphemeralDatabaseResponse, error) UploadArchive(ctx context.Context, in *UploadArchiveRequest, opts ...grpc.CallOption) (*UploadArchiveResponse, error) VerifyQuerySets(ctx context.Context, in *VerifyQuerySetsRequest, opts ...grpc.CallOption) (*VerifyQuerySetsResponse, error) + GetQuerySets(ctx context.Context, in *GetQuerySetsRequest, opts ...grpc.CallOption) (*GetQuerySetsResponse, error) } type quickClient struct { @@ -79,6 +81,15 @@ func (c *quickClient) VerifyQuerySets(ctx context.Context, in *VerifyQuerySetsRe return out, nil } +func (c *quickClient) GetQuerySets(ctx context.Context, in *GetQuerySetsRequest, opts ...grpc.CallOption) (*GetQuerySetsResponse, error) { + out := new(GetQuerySetsResponse) + err := c.cc.Invoke(ctx, Quick_GetQuerySets_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QuickServer is the server API for Quick service. // All implementations must embed UnimplementedQuickServer // for forward compatibility @@ -87,6 +98,7 @@ type QuickServer interface { DropEphemeralDatabase(context.Context, *DropEphemeralDatabaseRequest) (*DropEphemeralDatabaseResponse, error) UploadArchive(context.Context, *UploadArchiveRequest) (*UploadArchiveResponse, error) VerifyQuerySets(context.Context, *VerifyQuerySetsRequest) (*VerifyQuerySetsResponse, error) + GetQuerySets(context.Context, *GetQuerySetsRequest) (*GetQuerySetsResponse, error) mustEmbedUnimplementedQuickServer() } @@ -106,6 +118,9 @@ func (UnimplementedQuickServer) UploadArchive(context.Context, *UploadArchiveReq func (UnimplementedQuickServer) VerifyQuerySets(context.Context, *VerifyQuerySetsRequest) (*VerifyQuerySetsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method VerifyQuerySets not implemented") } +func (UnimplementedQuickServer) GetQuerySets(context.Context, *GetQuerySetsRequest) (*GetQuerySetsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetQuerySets not implemented") +} func (UnimplementedQuickServer) mustEmbedUnimplementedQuickServer() {} // UnsafeQuickServer may be embedded to opt out of forward compatibility for this service. @@ -191,6 +206,24 @@ func _Quick_VerifyQuerySets_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Quick_GetQuerySets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetQuerySetsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QuickServer).GetQuerySets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Quick_GetQuerySets_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QuickServer).GetQuerySets(ctx, req.(*GetQuerySetsRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Quick_ServiceDesc is the grpc.ServiceDesc for Quick service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -214,6 +247,10 @@ var Quick_ServiceDesc = grpc.ServiceDesc{ MethodName: "VerifyQuerySets", Handler: _Quick_VerifyQuerySets_Handler, }, + { + MethodName: "GetQuerySets", + Handler: _Quick_GetQuerySets_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "v1/quickdb.proto",