Skip to content

Commit

Permalink
build: Upgrade to github.com/sqlc-dev/[email protected]
Browse files Browse the repository at this point in the history
* build: Upgrade to github.com/sqlc-dev/[email protected]

* go mod tidy
  • Loading branch information
kyleconroy authored Nov 2, 2023
1 parent c82d80b commit 1138826
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 33 deletions.
13 changes: 10 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ module github.com/sqlc-dev/sqlc-gen-kotlin
go 1.19

require (
buf.build/gen/go/sqlc/sqlc/protocolbuffers/go v1.31.0-20231002190240-3f2d312ab6fd.1
github.com/jinzhu/inflection v1.0.0
github.com/sqlc-dev/sqlc-go v1.22.0
github.com/sqlc-dev/plugin-sdk-go v1.23.0
)

require google.golang.org/protobuf v1.31.0 // indirect
require (
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
19 changes: 15 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
buf.build/gen/go/sqlc/sqlc/protocolbuffers/go v1.31.0-20231002190240-3f2d312ab6fd.1 h1:94JzirpGhebc3++MqmvWY0fi9TJxlle5M52NO4pTEZY=
buf.build/gen/go/sqlc/sqlc/protocolbuffers/go v1.31.0-20231002190240-3f2d312ab6fd.1/go.mod h1:x7kMRcmAiYQXko+NDqLP2agondNlbHKUNGPXqU1nrOU=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/sqlc-dev/sqlc-go v1.22.0 h1:ivUplxHRkw1WZ++rs80OfoJLYbpXMXYGtc79e7z/0HA=
github.com/sqlc-dev/sqlc-go v1.22.0/go.mod h1:/4snw3ucbglJfyLRxp8X2weM4pwT8w1NlEKm4PzxAuQ=
github.com/sqlc-dev/plugin-sdk-go v1.23.0 h1:iSeJhnXPlbDXlbzUEebw/DxsGzE9rdDJArl8Hvt0RMM=
github.com/sqlc-dev/plugin-sdk-go v1.23.0/go.mod h1:I1r4THOfyETD+LI2gogN2LX8wCjwUZrgy/NU4In3llA=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
21 changes: 9 additions & 12 deletions internal/core/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"strconv"
"strings"

"buf.build/gen/go/sqlc/sqlc/protocolbuffers/go/protos/plugin"
"github.com/sqlc-dev/sqlc-go/metadata"
"github.com/sqlc-dev/sqlc-go/sdk"
"github.com/sqlc-dev/plugin-sdk-go/metadata"
"github.com/sqlc-dev/plugin-sdk-go/plugin"
"github.com/sqlc-dev/plugin-sdk-go/sdk"

"github.com/sqlc-dev/sqlc-gen-kotlin/internal/inflection"
)
Expand Down Expand Up @@ -230,7 +230,7 @@ func ktEnumValueName(value string) string {
return strings.ToUpper(id)
}

func BuildEnums(req *plugin.CodeGenRequest) []Enum {
func BuildEnums(req *plugin.GenerateRequest) []Enum {
var enums []Enum
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
Expand Down Expand Up @@ -264,9 +264,6 @@ func BuildEnums(req *plugin.CodeGenRequest) []Enum {
}

func dataClassName(name string, settings *plugin.Settings) string {
if rename := settings.Rename[name]; rename != "" {
return rename
}
out := ""
for _, p := range strings.Split(name, "_") {
out += strings.Title(p)
Expand All @@ -278,7 +275,7 @@ func memberName(name string, settings *plugin.Settings) string {
return sdk.LowerTitle(dataClassName(name, settings))
}

func BuildDataClasses(conf Config, req *plugin.CodeGenRequest) []Struct {
func BuildDataClasses(conf Config, req *plugin.GenerateRequest) []Struct {
var structs []Struct
for _, schema := range req.Catalog.Schemas {
if schema.Name == "pg_catalog" || schema.Name == "information_schema" {
Expand Down Expand Up @@ -367,7 +364,7 @@ func (t ktType) IsUUID() bool {
return t.Name == "UUID"
}

func makeType(req *plugin.CodeGenRequest, col *plugin.Column) ktType {
func makeType(req *plugin.GenerateRequest, col *plugin.Column) ktType {
typ, isEnum := ktInnerType(req, col)
return ktType{
Name: typ,
Expand All @@ -379,7 +376,7 @@ func makeType(req *plugin.CodeGenRequest, col *plugin.Column) ktType {
}
}

func ktInnerType(req *plugin.CodeGenRequest, col *plugin.Column) (string, bool) {
func ktInnerType(req *plugin.GenerateRequest, col *plugin.Column) (string, bool) {
// TODO: Extend the engine interface to handle types
switch req.Settings.Engine {
case "mysql":
Expand All @@ -396,7 +393,7 @@ type goColumn struct {
*plugin.Column
}

func ktColumnsToStruct(req *plugin.CodeGenRequest, name string, columns []goColumn, namer func(*plugin.Column, int) string) *Struct {
func ktColumnsToStruct(req *plugin.GenerateRequest, name string, columns []goColumn, namer func(*plugin.Column, int) string) *Struct {
gs := Struct{
Name: name,
}
Expand Down Expand Up @@ -480,7 +477,7 @@ func parseInts(s []string) ([]int, error) {
return refs, nil
}

func BuildQueries(req *plugin.CodeGenRequest, structs []Struct) ([]Query, error) {
func BuildQueries(req *plugin.GenerateRequest, structs []Struct) ([]Query, error) {
qs := make([]Query, 0, len(req.Queries))
for _, query := range req.Queries {
if query.Name == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"sort"
"strings"

"buf.build/gen/go/sqlc/sqlc/protocolbuffers/go/protos/plugin"
"github.com/sqlc-dev/plugin-sdk-go/plugin"
)

type Importer struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/maps.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package core

import (
"github.com/sqlc-dev/sqlc-go/sdk"
"github.com/sqlc-dev/plugin-sdk-go/sdk"
)

func DoubleSlashComment(f string) string {
Expand Down
6 changes: 3 additions & 3 deletions internal/core/mysql_type.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package core

import (
"buf.build/gen/go/sqlc/sqlc/protocolbuffers/go/protos/plugin"
"github.com/sqlc-dev/sqlc-go/sdk"
"github.com/sqlc-dev/plugin-sdk-go/plugin"
"github.com/sqlc-dev/plugin-sdk-go/sdk"
)

func mysqlType(req *plugin.CodeGenRequest, col *plugin.Column) (string, bool) {
func mysqlType(req *plugin.GenerateRequest, col *plugin.Column) (string, bool) {
columnType := sdk.DataType(col.Type)

switch columnType {
Expand Down
6 changes: 3 additions & 3 deletions internal/core/postgresql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package core
import (
"log"

"buf.build/gen/go/sqlc/sqlc/protocolbuffers/go/protos/plugin"
"github.com/sqlc-dev/sqlc-go/sdk"
"github.com/sqlc-dev/plugin-sdk-go/plugin"
"github.com/sqlc-dev/plugin-sdk-go/sdk"
)

func postgresType(req *plugin.CodeGenRequest, col *plugin.Column) (string, bool) {
func postgresType(req *plugin.GenerateRequest, col *plugin.Column) (string, bool) {
columnType := sdk.DataType(col.Type)

switch columnType {
Expand Down
9 changes: 4 additions & 5 deletions internal/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import (
"strings"
"text/template"

"buf.build/gen/go/sqlc/sqlc/protocolbuffers/go/protos/plugin"

"github.com/sqlc-dev/plugin-sdk-go/plugin"
"github.com/sqlc-dev/plugin-sdk-go/sdk"
"github.com/sqlc-dev/sqlc-gen-kotlin/internal/core"
"github.com/sqlc-dev/sqlc-go/sdk"
)

//go:embed tmpl/ktmodels.tmpl
Expand All @@ -28,7 +27,7 @@ func Offset(v int) int {
return v + 1
}

func Generate(ctx context.Context, req *plugin.CodeGenRequest) (*plugin.CodeGenResponse, error) {
func Generate(ctx context.Context, req *plugin.GenerateRequest) (*plugin.GenerateResponse, error) {
var conf core.Config
if len(req.PluginOptions) > 0 {
if err := json.Unmarshal(req.PluginOptions, &conf); err != nil {
Expand Down Expand Up @@ -101,7 +100,7 @@ func Generate(ctx context.Context, req *plugin.CodeGenRequest) (*plugin.CodeGenR
return nil, err
}

resp := plugin.CodeGenResponse{}
resp := plugin.GenerateResponse{}

for filename, code := range output {
resp.Files = append(resp.Files, &plugin.File{
Expand Down
2 changes: 1 addition & 1 deletion plugin/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/sqlc-dev/sqlc-go/codegen"
"github.com/sqlc-dev/plugin-sdk-go/codegen"

kotlin "github.com/sqlc-dev/sqlc-gen-kotlin/internal"
)
Expand Down

0 comments on commit 1138826

Please sign in to comment.