Skip to content

Commit 784c12d

Browse files
committed
Merge branch 'main' of git://github.com/kyleconroy/sqlc
2 parents 0c2e913 + c0b6e9c commit 784c12d

File tree

70 files changed

+1358
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1358
-66
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# STEP 1: Build sqlc
2-
FROM golang:1.16.3 AS builder
2+
FROM golang:1.16.4 AS builder
33

44
COPY . /workspace
55
WORKDIR /workspace

docs/howto/select.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ In PostgreSQL,
189189
[ANY](https://www.postgresql.org/docs/current/functions-comparisons.html#id-1.5.8.28.16)
190190
allows you to check if a value exists in an array expression. Queries using ANY
191191
with a single parameter will generate method signatures with slices as
192-
arguments.
192+
arguments. Use the postgres data types, eg: int, varchar, etc.
193193

194194
```sql
195195
CREATE TABLE authors (

docs/overview/install.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ docker run --rm -v $(pwd):/src -w /src kjconroy/sqlc generate
3434

3535
## Downloads
3636

37-
Get pre-built binaries for *v1.7.0*:
37+
Get pre-built binaries for *v1.8.0*:
3838

39-
- [Linux](https://github.com/kyleconroy/sqlc/releases/download/v1.7.0/sqlc-v1.7.0-linux-amd64.tar.gz)
40-
- [macOS](https://github.com/kyleconroy/sqlc/releases/download/v1.7.0/sqlc-v1.7.0-darwin-amd64.zip)
41-
- [Windows (MySQL only)](https://github.com/kyleconroy/sqlc/releases/download/v1.7.0/sqlc-v1.7.0-windows-amd64.zip)
39+
- [Linux](https://github.com/kyleconroy/sqlc/releases/download/v1.8.0/sqlc-v1.8.0-linux-amd64.tar.gz)
40+
- [macOS](https://github.com/kyleconroy/sqlc/releases/download/v1.8.0/sqlc-v1.8.0-darwin-amd64.zip)
41+
- [Windows (MySQL only)](https://github.com/kyleconroy/sqlc/releases/download/v1.8.0/sqlc-v1.8.0-windows-amd64.zip)
4242

4343
Binaries for a specific release can be downloaded on
4444
[GitHub](https://github.com/kyleconroy/sqlc/releases).

docs/reference/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ overrides:
6565

6666
Each override document has the following keys:
6767
- `db_type`:
68-
- The PostgreSQL type to override. Find the full list of supported types in [postgresql_type.go](https://github.com/kyleconroy/sqlc/blob/master/internal/codegen/golang/postgresql_type.go#L12).
68+
- The PostgreSQL type to override. Find the full list of supported types in [postgresql_type.go](https://github.com/kyleconroy/sqlc/blob/main/internal/codegen/golang/postgresql_type.go#L12).
6969
- `go_type`:
7070
- A fully qualified name to a Go type to use in the generated code.
7171
- `nullable`:

examples/booktest/postgresql/db_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func TestBooks(t *testing.T) {
139139
t.Fatal(err)
140140
}
141141
for _, ab := range res {
142-
t.Logf("Book %d: '%s', Author: '%s', ISBN: '%s' Tags: '%v'\n", ab.BookID, ab.Title, ab.Name, ab.Isbn, ab.Tags)
142+
t.Logf("Book %d: '%s', Author: '%s', ISBN: '%s' Tags: '%v'\n", ab.BookID, ab.Title, ab.Name.String, ab.Isbn, ab.Tags)
143143
}
144144

145145
// TODO: call say_hello(varchar)

examples/booktest/postgresql/query.sql.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/kotlin/src/main/kotlin/com/example/booktest/postgresql/QueriesImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ WHERE tags && ?::varchar[]
2323
data class BooksByTagsRow (
2424
val bookId: Int,
2525
val title: String,
26-
val name: String,
26+
val name: String?,
2727
val isbn: String,
2828
val tags: List<String>
2929
)

examples/python/src/booktest/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
class BooksByTagsRow:
2828
book_id: int
2929
title: str
30-
name: str
30+
name: Optional[str]
3131
isbn: str
3232
tags: List[str]
3333

internal/cmd/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var versionCmd = &cobra.Command{
5050
if version == "" {
5151
// When no version is set, return the next bug fix version
5252
// after the most recent tag
53-
fmt.Printf("%s\n", "v1.7.1-devel")
53+
fmt.Printf("%s\n", "v1.8.1-devel")
5454
} else {
5555
fmt.Printf("%s\n", version)
5656
}

internal/codegen/golang/gen.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,21 +427,39 @@ func generate(settings config.CombinedSettings, enums []Enum, structs []Struct,
427427
fmt.Println(b.String())
428428
return fmt.Errorf("source error: %w", err)
429429
}
430+
431+
if templateName == "queryFile" && golang.OutputFilesSuffix != "" {
432+
name += golang.OutputFilesSuffix
433+
}
434+
430435
if !strings.HasSuffix(name, ".go") {
431436
name += ".go"
432437
}
433438
output[name] = string(code)
434439
return nil
435440
}
436441

437-
if err := execute("db.go", "dbFile"); err != nil {
442+
dbFileName := "db.go"
443+
if golang.OutputDBFileName != "" {
444+
dbFileName = golang.OutputDBFileName
445+
}
446+
modelsFileName := "models.go"
447+
if golang.OutputModelsFileName != "" {
448+
modelsFileName = golang.OutputModelsFileName
449+
}
450+
querierFileName := "querier.go"
451+
if golang.OutputQuerierFileName != "" {
452+
querierFileName = golang.OutputQuerierFileName
453+
}
454+
455+
if err := execute(dbFileName, "dbFile"); err != nil {
438456
return nil, err
439457
}
440-
if err := execute("models.go", "modelsFile"); err != nil {
458+
if err := execute(modelsFileName, "modelsFile"); err != nil {
441459
return nil, err
442460
}
443461
if golang.EmitInterface {
444-
if err := execute("querier.go", "interfaceFile"); err != nil {
462+
if err := execute(querierFileName, "interfaceFile"); err != nil {
445463
return nil, err
446464
}
447465
}

0 commit comments

Comments
 (0)