dialect

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	CodeDialectLimit   = "dialect_limit"
	CodeDialectCascade = "dialect_cascade"
)
View Source
const Default = "postgres"

Variables

This section is empty.

Functions

func Names

func Names() []string

func RowInsert

func RowInsert(d Dialect, table string, columns []string, returning []Returned) string

func Validate

func Validate(d Dialect, m *schema.Model) schema.Diagnostics

func Visible

func Visible(d Dialect, e *schema.Entity, qualified bool) []string

Types

type Arg

type Arg struct {
	Kind  ArgKind
	Field *schema.Field
}

type ArgKind

type ArgKind string
const (
	ArgID       ArgKind = "id"
	ArgInput    ArgKind = "input"
	ArgFilter   ArgKind = "filter"
	ArgLimit    ArgKind = "limit"
	ArgOffset   ArgKind = "offset"
	ArgSourceID ArgKind = "source"
	ArgOwner    ArgKind = "owner"
	ArgPassword ArgKind = "password"
)

type AuthQueries

type AuthQueries struct {
	UserByIdentity        string
	SetPassword           string
	SetRole               string
	InsertSession         string
	SessionPrincipal      string
	DeleteSession         string
	DeleteOtherSessions   string
	DeleteUserSessions    string
	DeleteExpiredSessions string
	InsertRefresh         string
	RefreshToken          string
	UseRefresh            string
	DeleteFamily          string
	DeleteOtherFamilies   string
	DeleteUserRefresh     string
	DeleteExpiredRefresh  string
	InsertAPIKey          string
	APIKeyPrincipal       string
	CountAPIKeys          string
	ListAPIKeys           string
	DeleteAPIKey          string
	DeleteUserAPIKeys     string
}

func BuildAuthQueries

func BuildAuthQueries(d Dialect, e *schema.Entity) AuthQueries

type DeleteRule

type DeleteRule struct {
	Restrict bool
	Child    *schema.Entity
	Field    *schema.Field
	Query    Query
}

func SoftDeleteRules

func SoftDeleteRules(d Dialect, m *schema.Model, e *schema.Entity) []DeleteRule

type Dialect

type Dialect interface {
	Name() string
	Driver() Driver
	Quote(ident string) string
	Placeholder(n int) string
	Positional() bool
	FilterParam(placeholder string, kind schema.ColumnKind) string
	ColumnType(c *schema.Column) string
	Now() string
	Strategy() InsertStrategy
	InsertSQL(table string, columns, values []string, returning []Returned) string
	UpdateSQL(table string, sets []string, where string, returning []Returned) string
	Paginate(param func(ArgKind) string) string
	QueryHint() string
	LinkSQL(table string, columns, params [2]string) string
	ScanTimeAdapter() bool
	RecreateDependents() bool
	Limits() Limits
	Migration(changes []schema.Change, before, after *schema.Database) string
}

func Get

func Get(name string) (Dialect, error)

type Driver

type Driver struct {
	Module     string
	Version    string
	Import     string
	Name       string
	ExampleDSN string
}

type EntityQueries

type EntityQueries struct {
	Strategy   InsertStrategy
	Columns    []string
	Get        Query
	Exists     Query
	List       Query
	Count      Query
	Create     *Query
	Update     *Query
	Delete     *Query
	IdentityPK bool
}

func BuildEntityQueries

func BuildEntityQueries(d Dialect, e *schema.Entity) EntityQueries

type InsertStrategy

type InsertStrategy string
const (
	ReturnRow   InsertStrategy = "return_row"
	SelectAfter InsertStrategy = "select_after"
)

type Limits

type Limits struct {
	IndexedString    int
	PrimaryKeyString int
	PartialIndexes   bool
	SingleCascade    bool
}

type MySQL

type MySQL struct{}

func (MySQL) ColumnType

func (MySQL) ColumnType(c *schema.Column) string

func (MySQL) Driver

func (MySQL) Driver() Driver

func (MySQL) FilterParam

func (MySQL) FilterParam(placeholder string, _ schema.ColumnKind) string

func (MySQL) InsertSQL

func (d MySQL) InsertSQL(table string, columns, values []string, _ []Returned) string

func (MySQL) Limits

func (MySQL) Limits() Limits

func (MySQL) LinkSQL

func (d MySQL) LinkSQL(table string, columns, params [2]string) string

func (MySQL) Migration

func (d MySQL) Migration(changes []schema.Change, before, after *schema.Database) string

func (MySQL) Name

func (MySQL) Name() string

func (MySQL) Now

func (MySQL) Now() string

func (MySQL) Paginate

func (MySQL) Paginate(param func(ArgKind) string) string

func (MySQL) Placeholder

func (MySQL) Placeholder(int) string

func (MySQL) Positional

func (MySQL) Positional() bool

func (MySQL) QueryHint

func (MySQL) QueryHint() string

func (MySQL) Quote

func (MySQL) Quote(ident string) string

func (MySQL) RecreateDependents

func (MySQL) RecreateDependents() bool

func (MySQL) ScanTimeAdapter

func (MySQL) ScanTimeAdapter() bool

func (MySQL) Strategy

func (MySQL) Strategy() InsertStrategy

func (MySQL) UpdateSQL

func (d MySQL) UpdateSQL(table string, sets []string, where string, _ []Returned) string

type Postgres

type Postgres struct{}

func (Postgres) ColumnType

func (Postgres) ColumnType(c *schema.Column) string

func (Postgres) Driver

func (Postgres) Driver() Driver

func (Postgres) FilterParam

func (Postgres) FilterParam(placeholder string, kind schema.ColumnKind) string

func (Postgres) InsertSQL

func (d Postgres) InsertSQL(table string, columns, values []string, returning []Returned) string

func (Postgres) Limits

func (Postgres) Limits() Limits

func (Postgres) LinkSQL

func (d Postgres) LinkSQL(table string, columns, params [2]string) string

func (Postgres) Migration

func (d Postgres) Migration(changes []schema.Change, before, after *schema.Database) string

func (Postgres) Name

func (Postgres) Name() string

func (Postgres) Now

func (Postgres) Now() string

func (Postgres) Paginate

func (Postgres) Paginate(param func(ArgKind) string) string

func (Postgres) Placeholder

func (Postgres) Placeholder(n int) string

func (Postgres) Positional

func (Postgres) Positional() bool

func (Postgres) QueryHint

func (Postgres) QueryHint() string

func (Postgres) Quote

func (Postgres) Quote(ident string) string

func (Postgres) RecreateDependents

func (Postgres) RecreateDependents() bool

func (Postgres) ScanTimeAdapter

func (Postgres) ScanTimeAdapter() bool

func (Postgres) Strategy

func (Postgres) Strategy() InsertStrategy

func (Postgres) UpdateSQL

func (d Postgres) UpdateSQL(table string, sets []string, where string, returning []Returned) string

type Query

type Query struct {
	SQL  string
	Args []Arg
}

func LiveReferenceQuery

func LiveReferenceQuery(d Dialect, target *schema.Entity) Query

func OwnedReferenceQuery

func OwnedReferenceQuery(d Dialect, target *schema.Entity) Query

type RelationQueries

type RelationQueries struct {
	SourceExists Query
	List         Query
	Count        Query
	Link         *Query
	Unlink       *Query
}

func BuildHasManyQueries

func BuildHasManyQueries(d Dialect, parent, child *schema.Entity, fk *schema.Field) RelationQueries

func BuildManyToManyQueries

func BuildManyToManyQueries(d Dialect, source, target *schema.Entity, via string, writable bool) RelationQueries

type Returned

type Returned struct {
	Column string
	Type   string
}

type SQLServer

type SQLServer struct{}

func (SQLServer) ColumnType

func (SQLServer) ColumnType(c *schema.Column) string

func (SQLServer) Driver

func (SQLServer) Driver() Driver

func (SQLServer) FilterParam

func (SQLServer) FilterParam(placeholder string, _ schema.ColumnKind) string

func (SQLServer) InsertSQL

func (d SQLServer) InsertSQL(table string, columns, values []string, returning []Returned) string

func (SQLServer) Limits

func (SQLServer) Limits() Limits

func (SQLServer) LinkSQL

func (d SQLServer) LinkSQL(table string, columns, params [2]string) string

func (SQLServer) Migration

func (d SQLServer) Migration(changes []schema.Change, before, after *schema.Database) string

func (SQLServer) Name

func (SQLServer) Name() string

func (SQLServer) Now

func (SQLServer) Now() string

func (SQLServer) Paginate

func (SQLServer) Paginate(param func(ArgKind) string) string

func (SQLServer) Placeholder

func (SQLServer) Placeholder(n int) string

func (SQLServer) Positional

func (SQLServer) Positional() bool

func (SQLServer) QueryHint

func (SQLServer) QueryHint() string

func (SQLServer) Quote

func (SQLServer) Quote(ident string) string

func (SQLServer) RecreateDependents

func (SQLServer) RecreateDependents() bool

func (SQLServer) ScanTimeAdapter

func (SQLServer) ScanTimeAdapter() bool

func (SQLServer) Strategy

func (SQLServer) Strategy() InsertStrategy

func (SQLServer) UpdateSQL

func (d SQLServer) UpdateSQL(table string, sets []string, where string, returning []Returned) string

type SQLite

type SQLite struct{}

func (SQLite) ColumnType

func (SQLite) ColumnType(c *schema.Column) string

func (SQLite) Driver

func (SQLite) Driver() Driver

func (SQLite) FilterParam

func (SQLite) FilterParam(placeholder string, _ schema.ColumnKind) string

func (SQLite) InsertSQL

func (d SQLite) InsertSQL(table string, columns, values []string, returning []Returned) string

func (SQLite) Limits

func (SQLite) Limits() Limits

func (SQLite) LinkSQL

func (d SQLite) LinkSQL(table string, columns, params [2]string) string

func (SQLite) Migration

func (d SQLite) Migration(changes []schema.Change, before, after *schema.Database) string

func (SQLite) Name

func (SQLite) Name() string

func (SQLite) Now

func (SQLite) Now() string

func (SQLite) Paginate

func (SQLite) Paginate(param func(ArgKind) string) string

func (SQLite) Placeholder

func (SQLite) Placeholder(int) string

func (SQLite) Positional

func (SQLite) Positional() bool

func (SQLite) QueryHint

func (SQLite) QueryHint() string

func (SQLite) Quote

func (SQLite) Quote(ident string) string

func (SQLite) RecreateDependents

func (SQLite) RecreateDependents() bool

func (SQLite) ScanTimeAdapter

func (SQLite) ScanTimeAdapter() bool

func (SQLite) Strategy

func (SQLite) Strategy() InsertStrategy

func (SQLite) UpdateSQL

func (d SQLite) UpdateSQL(table string, sets []string, where string, returning []Returned) string

Jump to

Keyboard shortcuts

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