Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support for overriding types #82

Open
@oliverlambson

Description

@oliverlambson

It would be really helpful to have theoverride functionality available in the go version of sqlc. In combination with the existing pydantic functionality, this would be very useful.

e.g., currentlyJSONB columns are returned withAny type. I would like to be able to override this behaviour on a per-column basis. This would be useful not only for "Any" types, but also for types where a different primitive is desired (e.g. a 3rd party UUID instead of the builtin, like thego example)

Given this schema

-- schema.sqlCREATETABLEsome_table (    idSERIALNOT NULL,    payload JSONBNOT NULL);

Current output ofsqlc generate (uses Any for payload column)

# db/models.py# Code generated by sqlc. DO NOT EDIT.# versions:#   sqlc v1.28.0importpydanticfromtypingimportAnyclassSomeTable(pydantic.BaseModel):id:intpayload:Any

Desired output (uses custom type for payload column)

# db/models.py# Code generated by sqlc. DO NOT EDIT.# versions:#   sqlc v1.28.0importpydanticimportmy_lib.modelsclassSomeTable(pydantic.BaseModel):id:intpayload:my_lib.models.Payload

How it could work

I would imagine something in the config like:

version:"2"plugins:  -name:pywasm:url:https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.3.0.wasmsha256:fbedae96b5ecae2380a70fb5b925fd4bff58a6cfb1f3140375d098fbab7b3a3csql:  -schema:"./schemq.sql"queries:"./query"engine:postgresqlcodegen:      -out:./packages/core/src/core/dbplugin:pyoptions:package:core.dbemit_pydantic_models:trueoverrides:# similar to the go overrides            -column:"some_table.payload"py_import:"my_lib.models"py_type:"Payload"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp