Skip to content

Commit 1ac5932

Browse files
committed
Add table_prefix conf option
1 parent 9653405 commit 1ac5932

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ test: bin/sqlc-gen-python.wasm
99
all: bin/sqlc-gen-python bin/sqlc-gen-python.wasm
1010

1111
bin/sqlc-gen-python: bin go.mod go.sum $(wildcard **/*.go)
12-
cd plugin && go build -o ../bin/sqlc-gen-python ./main.go
12+
cd plugin/sqlc-gen-python && go build -o ../../bin/sqlc-gen-python ./main.go
1313

1414
bin/sqlc-gen-python.wasm: bin/sqlc-gen-python
15-
cd plugin && GOOS=wasip1 GOARCH=wasm go build -o ../bin/sqlc-gen-python.wasm main.go
15+
cd plugin/sqlc-gen-python && GOOS=wasip1 GOARCH=wasm go build -o ../../bin/sqlc-gen-python.wasm main.go
1616

1717
bin:
1818
mkdir -p bin

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Build
2+
3+
make bin/sqlc-gen-python
4+
15
## Usage
26

37
```yaml

internal/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ type Config struct {
99
EmitPydanticModels bool `json:"emit_pydantic_models"`
1010
QueryParameterLimit *int32 `json:"query_parameter_limit"`
1111
InflectionExcludeTableNames []string `json:"inflection_exclude_table_names"`
12+
TablePrefix string `json:"table_prefix"`
1213
}

internal/gen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ func buildModels(conf Config, req *plugin.GenerateRequest) []Struct {
279279
Exclusions: conf.InflectionExcludeTableNames,
280280
})
281281
}
282+
if conf.TablePrefix != "" {
283+
structName = conf.TablePrefix + strings.ToUpper(structName[:1]) + structName[1:]
284+
}
282285
s := Struct{
283286
Table: plugin.Identifier{Schema: schema.Name, Name: table.Rel.Name},
284287
Name: modelName(structName, req.Settings),

0 commit comments

Comments
 (0)