Documentation
¶
Overview ¶
Package dialect knows how each supported database spells things: column types, quoting, placeholders, queries and the DDL of migrations.
Index ¶
- Constants
- func Names() []string
- func RowInsert(d Dialect, table string, columns []string, returning []Returned) string
- func Validate(d Dialect, m *schema.Model) schema.Diagnostics
- func Visible(d Dialect, e *schema.Entity, qualified bool) []string
- type Arg
- type ArgKind
- type AuthQueries
- type DeleteRule
- type Dialect
- type Driver
- type EntityQueries
- type IdempotencyQueries
- type InsertStrategy
- type Limits
- type MySQL
- func (MySQL) ColumnType(c *schema.Column) string
- func (MySQL) Driver() Driver
- func (MySQL) FilterParam(placeholder string, _ schema.ColumnKind) string
- func (d MySQL) InsertSQL(table string, columns, values []string, _ []Returned) string
- func (MySQL) Limits() Limits
- func (d MySQL) LinkSQL(table string, columns, params [2]string) string
- func (d MySQL) Migration(changes []schema.Change, before, after *schema.Database) string
- func (MySQL) Name() string
- func (MySQL) Now() string
- func (MySQL) Paginate(param func(ArgKind) string) string
- func (MySQL) Placeholder(int) string
- func (MySQL) Positional() bool
- func (MySQL) QueryHint() string
- func (MySQL) Quote(ident string) string
- func (MySQL) RecreateDependents() bool
- func (MySQL) ScanTimeAdapter() bool
- func (MySQL) Strategy() InsertStrategy
- func (d MySQL) UpdateSQL(table string, sets []string, where string, _ []Returned) string
- type Postgres
- func (Postgres) ColumnType(c *schema.Column) string
- func (Postgres) Driver() Driver
- func (Postgres) FilterParam(placeholder string, kind schema.ColumnKind) string
- func (d Postgres) InsertSQL(table string, columns, values []string, returning []Returned) string
- func (Postgres) Limits() Limits
- func (d Postgres) LinkSQL(table string, columns, params [2]string) string
- func (d Postgres) Migration(changes []schema.Change, before, after *schema.Database) string
- func (Postgres) Name() string
- func (Postgres) Now() string
- func (Postgres) Paginate(param func(ArgKind) string) string
- func (Postgres) Placeholder(n int) string
- func (Postgres) Positional() bool
- func (Postgres) QueryHint() string
- func (Postgres) Quote(ident string) string
- func (Postgres) RecreateDependents() bool
- func (Postgres) ScanTimeAdapter() bool
- func (Postgres) Strategy() InsertStrategy
- func (d Postgres) UpdateSQL(table string, sets []string, where string, returning []Returned) string
- type Query
- type RelationQueries
- type Returned
- type SQLServer
- func (SQLServer) ColumnType(c *schema.Column) string
- func (SQLServer) Driver() Driver
- func (SQLServer) FilterParam(placeholder string, _ schema.ColumnKind) string
- func (d SQLServer) InsertSQL(table string, columns, values []string, returning []Returned) string
- func (SQLServer) Limits() Limits
- func (d SQLServer) LinkSQL(table string, columns, params [2]string) string
- func (d SQLServer) Migration(changes []schema.Change, before, after *schema.Database) string
- func (SQLServer) Name() string
- func (SQLServer) Now() string
- func (SQLServer) Paginate(param func(ArgKind) string) string
- func (SQLServer) Placeholder(n int) string
- func (SQLServer) Positional() bool
- func (SQLServer) QueryHint() string
- func (SQLServer) Quote(ident string) string
- func (SQLServer) RecreateDependents() bool
- func (SQLServer) ScanTimeAdapter() bool
- func (SQLServer) Strategy() InsertStrategy
- func (d SQLServer) UpdateSQL(table string, sets []string, where string, returning []Returned) string
- type SQLite
- func (SQLite) ColumnType(c *schema.Column) string
- func (SQLite) Driver() Driver
- func (SQLite) FilterParam(placeholder string, _ schema.ColumnKind) string
- func (d SQLite) InsertSQL(table string, columns, values []string, returning []Returned) string
- func (SQLite) Limits() Limits
- func (d SQLite) LinkSQL(table string, columns, params [2]string) string
- func (d SQLite) Migration(changes []schema.Change, before, after *schema.Database) string
- func (SQLite) Name() string
- func (SQLite) Now() string
- func (SQLite) Paginate(param func(ArgKind) string) string
- func (SQLite) Placeholder(int) string
- func (SQLite) Positional() bool
- func (SQLite) QueryHint() string
- func (SQLite) Quote(ident string) string
- func (SQLite) RecreateDependents() bool
- func (SQLite) ScanTimeAdapter() bool
- func (SQLite) Strategy() InsertStrategy
- func (d SQLite) UpdateSQL(table string, sets []string, where string, returning []Returned) string
Constants ¶
const ( CodeDialectLimit = "dialect_limit" CodeDialectCascade = "dialect_cascade" )
const Default = "postgres"
Variables ¶
This section is empty.
Functions ¶
Types ¶
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" ArgCursorTime ArgKind = "cursor.time" ArgCursorKey ArgKind = "cursor.key" ArgFetch ArgKind = "fetch" )
type AuthQueries ¶
type AuthQueries struct {
UserByIdentity string
SetPassword string
ReplacePassword string
LockAccount string
LockPassword string
SetRole string
InsertSession string
SessionPrincipal string
DeleteSession string
DeleteOtherSessions string
DeleteUserSessions string
DeleteExpiredSessions string
InsertRefresh string
RefreshToken string
UseRefresh string
RefreshSuccessor string
JWTPrincipal string
DeleteFamily string
DeleteOtherFamilies string
DeleteUserRefresh string
DeleteExpiredRefresh string
InsertAPIKey string
APIKeyPrincipal string
CountAPIKeys string
ListAPIKeys string
DeleteAPIKey string
DeleteUserAPIKeys string
ExpireRateLimit string
HitRateLimit string
RateLimitReset string
InsertRateLimit string
DeleteRateLimit string
DeleteExpiredLimits string
DeleteSingleLimits string
CountRateLimits string
}
func BuildAuthQueries ¶
func BuildAuthQueries(d Dialect, e *schema.Entity) AuthQueries
type DeleteRule ¶
func SoftDeleteRules ¶
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
}
type EntityQueries ¶
type EntityQueries struct {
Strategy InsertStrategy
Columns []string
Get Query
Exists Query
List Query
ListAfter Query
Count Query
Create *Query
Update *Query
Delete *Query
IdentityPK bool
}
func BuildEntityQueries ¶
func BuildEntityQueries(d Dialect, e *schema.Entity) EntityQueries
type IdempotencyQueries ¶ added in v0.5.0
type IdempotencyQueries struct {
Claim string
Lookup string
Retake string
Complete string
Release string
Purge string
}
func BuildIdempotencyQueries ¶ added in v0.5.0
func BuildIdempotencyQueries(d Dialect) IdempotencyQueries
BuildIdempotencyQueries writes the statements of the idempotency key store. Every placeholder has its own key, so the arguments come in the same order in every dialect, positional or not.
type InsertStrategy ¶
type InsertStrategy string
const ( ReturnRow InsertStrategy = "return_row" SelectAfter InsertStrategy = "select_after" )
type MySQL ¶
type MySQL struct{}
func (MySQL) FilterParam ¶
func (MySQL) FilterParam(placeholder string, _ schema.ColumnKind) string
func (MySQL) Placeholder ¶
func (MySQL) Positional ¶
func (MySQL) RecreateDependents ¶
func (MySQL) ScanTimeAdapter ¶
func (MySQL) Strategy ¶
func (MySQL) Strategy() InsertStrategy
type Postgres ¶
type Postgres struct{}
func (Postgres) FilterParam ¶
func (Postgres) FilterParam(placeholder string, kind schema.ColumnKind) string
func (Postgres) Placeholder ¶
func (Postgres) Positional ¶
func (Postgres) RecreateDependents ¶
func (Postgres) ScanTimeAdapter ¶
func (Postgres) Strategy ¶
func (Postgres) Strategy() InsertStrategy
type RelationQueries ¶
type RelationQueries struct {
SourceExists Query
List Query
ListAfter Query
Count Query
Link *Query
Unlink *Query
}
func BuildHasManyQueries ¶
func BuildManyToManyQueries ¶
type SQLServer ¶
type SQLServer struct{}
func (SQLServer) FilterParam ¶
func (SQLServer) FilterParam(placeholder string, _ schema.ColumnKind) string
func (SQLServer) Placeholder ¶
func (SQLServer) Positional ¶
func (SQLServer) RecreateDependents ¶
func (SQLServer) ScanTimeAdapter ¶
func (SQLServer) Strategy ¶
func (SQLServer) Strategy() InsertStrategy
type SQLite ¶
type SQLite struct{}
func (SQLite) FilterParam ¶
func (SQLite) FilterParam(placeholder string, _ schema.ColumnKind) string
func (SQLite) Placeholder ¶
func (SQLite) Positional ¶
func (SQLite) RecreateDependents ¶
func (SQLite) ScanTimeAdapter ¶
func (SQLite) Strategy ¶
func (SQLite) Strategy() InsertStrategy