Skip to content

Commit 9533102

Browse files
committed
Merge tag 'v1.2.0' into streaming
# Conflicts: # internal/tmpl/ktiface.go # internal/tmpl/ktsql.go
2 parents b1447ed + 1138826 commit 9533102

File tree

16 files changed

+107
-711
lines changed

16 files changed

+107
-711
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ jobs:
99
name: test
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-go@v3
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-go@v4
1414
with:
15-
go-version: '1.19'
16-
- run: wget https://github.com/tinygo-org/tinygo/releases/download/v0.26.0/tinygo_0.26.0_amd64.deb
17-
- run: sudo dpkg -i tinygo_0.26.0_amd64.deb
15+
go-version: '1.21.0'
1816
- run: make

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ sqlc-gen-kotlin:
44
cd plugin && go build -o ~/bin/sqlc-gen-kotlin ./main.go
55

66
sqlc-gen-kotlin.wasm:
7-
cd plugin && tinygo build -o sqlc-gen-kotlin.wasm -gc=leaking -scheduler=none -wasm-abi=generic -target=wasi main.go
7+
cd plugin && GOOS=wasip1 GOARCH=wasm go build -o sqlc-gen-kotlin.wasm main.go
88
openssl sha256 plugin/sqlc-gen-kotlin.wasm
99

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Usage
2+
3+
```yaml
4+
version: '2'
5+
plugins:
6+
- name: kt
7+
wasm:
8+
url: https://downloads.sqlc.dev/plugin/sqlc-gen-kotlin_1.1.0.wasm
9+
sha256: 57890144f4effed4fe71855418b87ad26d53dc5ed2030a66ad77e5e3a93d77fb
10+
sql:
11+
- schema: src/main/resources/authors/postgresql/schema.sql
12+
queries: src/main/resources/authors/postgresql/query.sql
13+
engine: postgresql
14+
codegen:
15+
- out: src/main/kotlin/com/example/authors/postgresql
16+
plugin: kt
17+
options:
18+
package: com.example.authors.postgresql
19+
```

go.mod

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
module github.com/tabbed/sqlc-gen-kotlin
1+
module github.com/sqlc-dev/sqlc-gen-kotlin
22

33
go 1.19
44

55
require (
66
github.com/jinzhu/inflection v1.0.0
7-
github.com/mailru/easyjson v0.7.7
8-
github.com/tabbed/sqlc-go v1.16.0
7+
github.com/sqlc-dev/plugin-sdk-go v1.23.0
98
)
109

1110
require (
12-
github.com/josharian/intern v1.0.0 // indirect
13-
google.golang.org/protobuf v1.28.1 // indirect
11+
github.com/golang/protobuf v1.5.3 // indirect
12+
golang.org/x/net v0.14.0 // indirect
13+
golang.org/x/sys v0.11.0 // indirect
14+
golang.org/x/text v0.12.0 // indirect
15+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
16+
google.golang.org/grpc v1.59.0 // indirect
17+
google.golang.org/protobuf v1.31.0 // indirect
1418
)

go.sum

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
2+
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
3+
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
24
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
35
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
46
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
57
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
6-
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
7-
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
8-
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
9-
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
10-
github.com/tabbed/sqlc-go v1.16.0 h1:EwPBXdGn5tyrLjcNiHRoQthWvJeF5NjG9Cx1WK5iFsY=
11-
github.com/tabbed/sqlc-go v1.16.0/go.mod h1:mqMU5duZRGz5Wp/qJXwkERf+MXgGOZ8BmW/tH9KyvWA=
8+
github.com/sqlc-dev/plugin-sdk-go v1.23.0 h1:iSeJhnXPlbDXlbzUEebw/DxsGzE9rdDJArl8Hvt0RMM=
9+
github.com/sqlc-dev/plugin-sdk-go v1.23.0/go.mod h1:I1r4THOfyETD+LI2gogN2LX8wCjwUZrgy/NU4In3llA=
10+
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
11+
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
12+
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
13+
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14+
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
15+
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
1216
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
17+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4=
18+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
19+
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
20+
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
1321
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
14-
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
15-
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
22+
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
23+
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
24+
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=

internal/core/config_easyjson.go

Lines changed: 0 additions & 131 deletions
This file was deleted.

internal/core/gen.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import (
99
"strconv"
1010
"strings"
1111

12-
plugin "github.com/tabbed/sqlc-go/codegen"
13-
"github.com/tabbed/sqlc-go/metadata"
14-
"github.com/tabbed/sqlc-go/sdk"
12+
"github.com/sqlc-dev/plugin-sdk-go/metadata"
13+
"github.com/sqlc-dev/plugin-sdk-go/plugin"
14+
"github.com/sqlc-dev/plugin-sdk-go/sdk"
1515

16-
"github.com/tabbed/sqlc-gen-kotlin/internal/inflection"
16+
"github.com/sqlc-dev/sqlc-gen-kotlin/internal/inflection"
1717
)
1818

1919
var ktIdentPattern = regexp.MustCompile("[^a-zA-Z0-9_]+")
@@ -230,7 +230,7 @@ func ktEnumValueName(value string) string {
230230
return strings.ToUpper(id)
231231
}
232232

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

266266
func dataClassName(name string, settings *plugin.Settings) string {
267-
if rename := settings.Rename[name]; rename != "" {
268-
return rename
269-
}
270267
out := ""
271268
for _, p := range strings.Split(name, "_") {
272269
out += strings.Title(p)
@@ -278,7 +275,7 @@ func memberName(name string, settings *plugin.Settings) string {
278275
return sdk.LowerTitle(dataClassName(name, settings))
279276
}
280277

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

370-
func makeType(req *plugin.CodeGenRequest, col *plugin.Column) ktType {
367+
func makeType(req *plugin.GenerateRequest, col *plugin.Column) ktType {
371368
typ, isEnum := ktInnerType(req, col)
372369
return ktType{
373370
Name: typ,
@@ -379,7 +376,7 @@ func makeType(req *plugin.CodeGenRequest, col *plugin.Column) ktType {
379376
}
380377
}
381378

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

399-
func ktColumnsToStruct(req *plugin.CodeGenRequest, name string, columns []goColumn, namer func(*plugin.Column, int) string) *Struct {
396+
func ktColumnsToStruct(req *plugin.GenerateRequest, name string, columns []goColumn, namer func(*plugin.Column, int) string) *Struct {
400397
gs := Struct{
401398
Name: name,
402399
}
@@ -480,7 +477,7 @@ func parseInts(s []string) ([]int, error) {
480477
return refs, nil
481478
}
482479

483-
func BuildQueries(req *plugin.CodeGenRequest, structs []Struct) ([]Query, error) {
480+
func BuildQueries(req *plugin.GenerateRequest, structs []Struct) ([]Query, error) {
484481
qs := make([]Query, 0, len(req.Queries))
485482
for _, query := range req.Queries {
486483
if query.Name == "" {

internal/core/imports.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"sort"
55
"strings"
66

7-
plugin "github.com/tabbed/sqlc-go/codegen"
7+
"github.com/sqlc-dev/plugin-sdk-go/plugin"
88
)
99

1010
type Importer struct {

internal/core/maps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package core
22

33
import (
4-
"github.com/tabbed/sqlc-go/sdk"
4+
"github.com/sqlc-dev/plugin-sdk-go/sdk"
55
)
66

77
func DoubleSlashComment(f string) string {

internal/core/mysql_type.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package core
22

33
import (
4-
plugin "github.com/tabbed/sqlc-go/codegen"
5-
"github.com/tabbed/sqlc-go/sdk"
4+
"github.com/sqlc-dev/plugin-sdk-go/plugin"
5+
"github.com/sqlc-dev/plugin-sdk-go/sdk"
66
)
77

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

1111
switch columnType {

0 commit comments

Comments
 (0)