Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions internal/dinosql/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ func (r Result) columnsToStruct(name string, columns []goColumn, settings config
if o, ok := suffixes[c.id]; ok {
suffix = o
} else if v := seen[c.Name]; v > 0 {
suffix = v+1
suffix = v + 1
}
suffixes[c.id] = suffix
if suffix > 0 {
Expand Down Expand Up @@ -1065,7 +1065,7 @@ import (
)

{{range .Enums}}
{{if .Comment}}// {{.Comment}}{{end}}
{{if .Comment}}{{comment .Comment}}{{end}}
type {{.Name}} string

const (
Expand All @@ -1081,7 +1081,7 @@ func (e *{{.Name}}) Scan(src interface{}) error {
{{end}}

{{range .Structs}}
{{if .Comment}}// {{.Comment}}{{end}}
{{if .Comment}}{{comment .Comment}}{{end}}
type {{.Name}} struct { {{- range .Fields}}
{{- if .Comment}}
// {{.Comment}}{{else}}
Expand Down Expand Up @@ -1224,9 +1224,14 @@ func LowerTitle(s string) string {
return string(a)
}

func DoubleSlashComment(s string) string {
return "// " + strings.ReplaceAll(s, "\n", "\n// ")
}

func Generate(r Generateable, settings config.CombinedSettings) (map[string]string, error) {
funcMap := template.FuncMap{
"lowerTitle": LowerTitle,
"comment": DoubleSlashComment,
"imports": Imports(r, settings),
}

Expand Down
22 changes: 11 additions & 11 deletions internal/dinosql/kotlin/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,6 @@ func ktParamName(c core.Column, number int) string {
return fmt.Sprintf("dollar_%d", number)
}


func ktColumnName(c core.Column, pos int) string {
if c.Name != "" {
return c.Name
Expand Down Expand Up @@ -812,7 +811,7 @@ package {{.Package}}
{{end}}

{{range .Enums}}
{{if .Comment}}// {{.Comment}}{{end}}
{{if .Comment}}{{comment .Comment}}{{end}}
enum class {{.Name}}(val value: String) {
{{- range $i, $e := .Constants}}
{{- if $i }},{{end}}
Expand All @@ -827,7 +826,7 @@ enum class {{.Name}}(val value: String) {
{{end}}

{{range .KtDataClasses}}
{{if .Comment}}// {{.Comment}}{{end}}
{{if .Comment}}{{comment .Comment}}{{end}}
data class {{.Name}} ( {{- range $i, $e := .Fields}}
{{- if $i }},{{end}}
{{- if .Comment}}
Expand Down Expand Up @@ -974,6 +973,7 @@ func ktFormat(s string) string {
func KtGenerate(r KtGenerateable, settings config.CombinedSettings) (map[string]string, error) {
funcMap := template.FuncMap{
"lowerTitle": dinosql.LowerTitle,
"comment": dinosql.DoubleSlashComment,
"imports": KtImports(r, settings),
"offset": Offset,
}
Expand All @@ -984,12 +984,12 @@ func KtGenerate(r KtGenerateable, settings config.CombinedSettings) (map[string]

pkg := settings.Package
tctx := ktTmplCtx{
Settings: settings.Global,
Q: `"""`,
Package: pkg.Gen.Kotlin.Package,
KtQueries: r.KtQueries(settings),
Enums: r.KtEnums(settings),
KtDataClasses: r.KtDataClasses(settings),
Settings: settings.Global,
Q: `"""`,
Package: pkg.Gen.Kotlin.Package,
KtQueries: r.KtQueries(settings),
Enums: r.KtEnums(settings),
KtDataClasses: r.KtDataClasses(settings),
}

output := map[string]string{}
Expand All @@ -1014,8 +1014,8 @@ func KtGenerate(r KtGenerateable, settings config.CombinedSettings) (map[string]
return nil, err
}
if err := execute("Queries.kt", ifaceFile); err != nil {
return nil, err
}
return nil, err
}
if err := execute("QueriesImpl.kt", sqlFile); err != nil {
return nil, err
}
Expand Down