model

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package model Auto-generated using python; DO NOT EDIT py 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 19:06:28) [MSC v.1942 64 bit (AMD64)]

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColumnName

func ColumnName(pluginColumn *plugin.Column, pos int) string

func DedupClassName

func DedupClassName(name string, seen map[string]int) string

DedupClassName is DedupName with a bare digit suffix ("Name", "Name2", ...): an underscore suffix would violate the CapWords convention (N801).

func DedupName

func DedupName(name string, seen map[string]int) string

DedupName makes repeated Python identifiers unique by appending a numeric suffix ("name", "name_2", "name_3", ...). Suffixes are probed until an unused identifier is found, so a literal "name_2" that appeared earlier can never collide with a generated one. seen tracks usage counts per scope.

func EnumConstantName

func EnumConstantName(value string, index int, seen map[string]int) string

EnumConstantName converts an enum value into a valid, unique Python constant name: non-alphanumeric characters become underscores, empty results fall back to VALUE_N, digit- and underscore-leading names get a VALUE_ prefix, and duplicates get a numeric suffix. seen tracks names across one enum.

func EnumName

func EnumName(config *config.Config, enumName string, schemaName string) string

EnumName builds the class name for a SQL enum. Enum type names are never singularized - they are type names, not table names.

func Escape

func Escape(s string) string

func EscapedColumnName

func EscapedColumnName(pluginColumn *plugin.Column, pos int) string

func IsReserved

func IsReserved(s string) bool

func ModelName

func ModelName(config *config.Config, modelName string, schemaName string) string

ModelName builds the class name for a table. Singularization runs on the raw snake_case table name (before camel-casing) so that inflection_exclude_table_names entries, which users write in snake_case, match correctly. For non-default-schema tables exclusions match BOTH the bare table name ("events") and the schema-qualified form ("analytics_events") - v0.4.x singularized the qualified string, so existing configs use the qualified spelling.

func ParamName

func ParamName(p *plugin.Parameter) string

ParamName allows leading underscores: parameters are plain kwargs, never attrs/pydantic fields, so only digit-leading names need the prefix.

func Singular

func Singular(s SingularParams) string

func SnakeToCamel

func SnakeToCamel(conf *config.Config, s string) string

func UpperSnakeCase

func UpperSnakeCase(s string) string

Types

type Column

type Column struct {
	Name   string // The escaped Python attribute name
	DBName string // The raw database column name
	Type   PyType

	// Number is the 1-based sqlc parameter number when this column belongs
	// to a bundled Params class; 0 for table model columns.
	Number int32

	Embed *Embed
}

type Embed

type Embed struct {
	ModelName string
	Columns   []Column
}

type Enum

type Enum struct {
	Name      string
	Constants []EnumConstants
}

type EnumConstants

type EnumConstants struct {
	Name  string
	Value string
}

type PyType

type PyType struct {
	SQLType    string
	Type       string
	IsNullable bool
	IsList     bool
	IsEnum     bool

	// IsOverride marks a type replaced via the overrides config option.
	IsOverride bool
	// DefaultType is the Python type the column would have without the
	// override. Used to convert override values before passing them to the driver.
	DefaultType string

	// ConverterTo and ConverterFrom are fully qualified user functions that
	// replace the default constructor-call conversion in both directions.
	ConverterTo   string
	ConverterFrom string

	// SqlcSliceName is the raw sqlc.slice parameter name, needed to expand
	// the /*SLICE:name*/? placeholder at runtime. Empty for other values.
	SqlcSliceName string
}

func (PyType) DoOverride

func (t PyType) DoOverride() bool

DoOverride reports whether this type has an active override.

func (PyType) HasConverter added in v0.6.0

func (t PyType) HasConverter() bool

HasConverter reports whether user functions handle this type's conversion.

func (PyType) Print

func (t PyType) Print() string

func (PyType) PrintOptional

func (t PyType) PrintOptional() string

PrintOptional prints the type with a guaranteed "| None" suffix for values that may be absent at runtime (e.g. :one queries that match no row).

type Query

type Query struct {
	Cmd          string // The command of the query: https://docs.sqlc.dev/en/latest/reference/query-annotations.html
	SQL          string // The raw SQL of the query
	ConstantName string // The name of the constant where the raw SQL will be saved in python
	FuncName     string // The name of the python function
	QueryName    string // The original name of the query
	FileName     string // The original filename where the query is located
	ModuleName   string // The name of the python module in which the query will be implemented

	Params  []QueryValue
	Returns QueryValue

	Table *plugin.Identifier // The name of the table this query inserts into. Only used for :copyfrom
}

func (Query) EmitsTable

func (q Query) EmitsTable() bool

type QueryValue

type QueryValue struct {
	EmitTable bool
	Table     *Table
	Name      string
	Type      PyType

	// Number is the 1-based sqlc parameter number, used by drivers that
	// bind by name (psycopg's %(pN)s); 0 for return values.
	Number int32
}

func (QueryValue) IsEmpty

func (v QueryValue) IsEmpty() bool

IsEmpty reports whether this value is unset.

func (QueryValue) IsStruct

func (v QueryValue) IsStruct() bool

IsStruct reports whether this value is a structured type (table reference).

type SingularParams

type SingularParams struct {
	Name       string
	Exclusions []string
}

type Table

type Table struct {
	Name    string
	Columns []Column

	Identifier *plugin.Identifier
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL