Documentation
¶
Index ¶
- type Blueprint
- type Column
- type ColumnDefinition
- type Command
- type CompileLimitGrammar
- type CompileOffsetGrammar
- type CompileOrderByGrammar
- type Conditions
- type DBColumn
- type DBForeignKey
- type DBGrammar
- type DBIndex
- type Driver
- type ForeignKey
- type GormGrammar
- type Grammar
- type Having
- type Index
- type Join
- type JsonGrammar
- type PlaceholderFormat
- type Processor
- type SchemaGrammar
- type Table
- type Type
- type View
- type Where
- type WhereType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blueprint ¶
type Blueprint interface {
// GetAddedColumns Get the added columns.
GetAddedColumns() []ColumnDefinition
// GetCommands Get the commands.
GetCommands() []*Command
// GetTableName Get the table name with prefix.
GetTableName() string
// HasCommand Determine if the blueprint has a specific command.
HasCommand(command string) bool
}
type ColumnDefinition ¶
type ColumnDefinition interface {
// After sets the column "after" another column (MySQL only)
After(column string) ColumnDefinition
// Always defines the precedence of sequence values over input for an identity column (PostgreSQL only)
Always() ColumnDefinition
// AutoIncrement set the column as auto increment
AutoIncrement() ColumnDefinition
// Change the column (MySQL / PostgreSQL / SQL Server)
Change() ColumnDefinition
// Comment sets the comment value (MySQL / PostgreSQL)
Comment(comment string) ColumnDefinition
// Default set the default value
Default(def any) ColumnDefinition
// First sets the column "first" in the table (MySQL only)
First() ColumnDefinition
// GeneratedAs creates an identity column with specified sequence options (PostgreSQL only)
GeneratedAs(expression ...string) ColumnDefinition
// GetAfter returns the after value
GetAfter() string
// GetAllowed returns the allowed value
GetAllowed() []any
// GetAutoIncrement returns the autoIncrement value
GetAutoIncrement() bool
// GetComment returns the comment value
GetComment() (comment string)
// GetDefault returns the default value
GetDefault() any
// GetGeneratedAs returns the generatedAs value
GetGeneratedAs() string
// GetLength returns the length value
GetLength() int
// GetName returns the name value
GetName() string
// GetNullable returns the nullable value
GetNullable() bool
// GetOnUpdate returns the onUpdate value
GetOnUpdate() any
// GetPlaces returns the places value
GetPlaces() int
// GetPrecision returns the precision value
GetPrecision() int
// GetTotal returns the total value
GetTotal() int
// GetType returns the type value
GetType() string
// GetUnsigned returns the unsigned value
GetUnsigned() bool
// GetUseCurrent returns the useCurrent value
GetUseCurrent() bool
// GetUseCurrentOnUpdate returns the useCurrentOnUpdate value
GetUseCurrentOnUpdate() bool
// IsAlways returns the always value
IsAlways() bool
// IsChange returns true if the column has changed
IsChange() bool
// IsFirst returns true if the column is first
IsFirst() bool
// IsSetComment returns true if the comment value is set
IsSetComment() bool
// IsSetGeneratedAs returns true if the generatedAs value is set
IsSetGeneratedAs() bool
// OnUpdate sets the column to use the value on update (Mysql only)
OnUpdate(value any) ColumnDefinition
// Places set the decimal places
Places(places int) ColumnDefinition
// Total set the decimal total
Total(total int) ColumnDefinition
// Nullable allow NULL values to be inserted into the column
Nullable() ColumnDefinition
// Unsigned set the column as unsigned (Mysql only)
Unsigned() ColumnDefinition
// UseCurrent set the column to use the current timestamp
UseCurrent() ColumnDefinition
// UseCurrentOnUpdate set the column to use the current timestamp on update (Mysql only)
UseCurrentOnUpdate() ColumnDefinition
}
type CompileLimitGrammar ¶
type CompileLimitGrammar interface {
CompileLimit(builder sq.SelectBuilder, conditions *Conditions) sq.SelectBuilder
}
type CompileOffsetGrammar ¶
type CompileOffsetGrammar interface {
CompileOffset(builder sq.SelectBuilder, conditions *Conditions) sq.SelectBuilder
}
type CompileOrderByGrammar ¶
type CompileOrderByGrammar interface {
CompileOrderBy(builder sq.SelectBuilder, conditions *Conditions) sq.SelectBuilder
}
type Conditions ¶
type DBForeignKey ¶
type DBGrammar ¶
type DBGrammar interface {
// CompileLockForUpdate Compile the lock for update.
CompileLockForUpdate(builder sq.SelectBuilder, conditions *Conditions) sq.SelectBuilder
// CompileInRandomOrder Compile the random order.
CompileInRandomOrder(builder sq.SelectBuilder, conditions *Conditions) sq.SelectBuilder
// CompilePlaceholderFormat Compile the placeholder format.
CompilePlaceholderFormat() PlaceholderFormat
CompileSharedLock(builder sq.SelectBuilder, conditions *Conditions) sq.SelectBuilder
// CompileVersion Compile the version.
CompileVersion() string
}
type ForeignKey ¶
type GormGrammar ¶
type GormGrammar interface {
// CompileLockForUpdateForGorm Compile the lock for update for gorm.
CompileLockForUpdateForGorm() clause.Expression
// CompileRandomOrderForGorm Compile the random order for gorm.
CompileRandomOrderForGorm() string
CompileSharedLockForGorm() clause.Expression
}
type Grammar ¶
type Grammar interface {
SchemaGrammar
GormGrammar
DBGrammar
JsonGrammar
}
type JsonGrammar ¶
type JsonGrammar interface {
// CompileJsonColumnsUpdate Compile the JSON columns for an update statement.
CompileJsonColumnsUpdate(values map[string]any) (map[string]any, error)
// CompileJsonContains Compile a "JSON contains" statement into SQL.
CompileJsonContains(column string, value any, isNot bool) (string, []any, error)
// CompileJsonContainsKey Compile a "JSON contains key" statement into SQL.
CompileJsonContainsKey(column string, isNot bool) string
// CompileJsonLength Compile a "JSON length" statement into SQL.
CompileJsonLength(column string) string
// CompileJsonSelector Wrap the given JSON selector.
CompileJsonSelector(column string) string
// CompileJsonValues Normalizes and converts values into database-compatible types.
CompileJsonValues(args ...any) []any
}
type PlaceholderFormat ¶
type Processor ¶
type Processor interface {
ProcessColumns(dbColumns []DBColumn) []Column
ProcessForeignKeys(dbIndexes []DBForeignKey) []ForeignKey
ProcessIndexes(dbIndexes []DBIndex) []Index
ProcessTypes(types []Type) []Type
}
type SchemaGrammar ¶
type SchemaGrammar interface {
// CompileAdd Compile an add column command.
CompileAdd(blueprint Blueprint, command *Command) string
// CompileChange Compile a change column command.
CompileChange(blueprint Blueprint, command *Command) []string
// CompileColumns Compile the query to determine the columns.
CompileColumns(schema, table string) (string, error)
// CompileComment Compile a column comment command.
CompileComment(blueprint Blueprint, command *Command) string
// CompileCreate Compile a create table command.
CompileCreate(blueprint Blueprint) string
// CompileDefault Compile a default value command.
CompileDefault(blueprint Blueprint, command *Command) string
// CompileDrop Compile a drop table command.
CompileDrop(blueprint Blueprint) string
// CompileDropAllTables Compile the SQL needed to drop all tables.
CompileDropAllTables(schema string, tables []Table) []string
// CompileDropAllTypes Compile the SQL needed to drop all types.
CompileDropAllTypes(schema string, types []Type) []string
// CompileDropAllViews Compile the SQL needed to drop all views.
CompileDropAllViews(schema string, views []View) []string
// CompileDropColumn Compile a drop column command.
CompileDropColumn(blueprint Blueprint, command *Command) []string
// CompileDropForeign Compile a drop foreign key command.
CompileDropForeign(blueprint Blueprint, command *Command) string
// CompileDropFullText Compile a drop fulltext index command.
CompileDropFullText(blueprint Blueprint, command *Command) string
// CompileDropIfExists Compile a drop table (if exists) command.
CompileDropIfExists(blueprint Blueprint) string
// CompileDropIndex Compile a drop index command.
CompileDropIndex(blueprint Blueprint, command *Command) string
// CompileDropPrimary Compile a drop primary key command.
CompileDropPrimary(blueprint Blueprint, command *Command) string
// CompileDropUnique Compile a drop unique key command.
CompileDropUnique(blueprint Blueprint, command *Command) string
// CompileForeign Compile a foreign key command.
CompileForeign(blueprint Blueprint, command *Command) string
// CompileForeignKeys Compile the query to determine the foreign keys.
CompileForeignKeys(schema, table string) string
// CompileFullText Compile a fulltext index key command.
CompileFullText(blueprint Blueprint, command *Command) string
// CompileIndex Compile a plain index key command.
CompileIndex(blueprint Blueprint, command *Command) string
// CompileIndexes Compile the query to determine the indexes.
CompileIndexes(schema, table string) (string, error)
// CompilePrimary Compile a primary key command.
CompilePrimary(blueprint Blueprint, command *Command) string
// CompilePrune Compile the SQL needed to prune or shrink the database.
CompilePrune(database string) string
// CompileRename Compile a rename table command.
CompileRename(blueprint Blueprint, command *Command) string
// CompileRenameColumn Compile a rename column command.
CompileRenameColumn(blueprint Blueprint, command *Command, columns []Column) (string, error)
// CompileRenameIndex Compile a rename index command.
CompileRenameIndex(blueprint Blueprint, command *Command, indexes []Index) []string
// CompileTables Compile the query to determine the tables.
CompileTables(database string) string
// CompileTableComment Compile a table comment command.
CompileTableComment(blueprint Blueprint, command *Command) string
// CompileTypes Compile the query to determine the types.
CompileTypes() string
// CompileUnique Compile a unique key command.
CompileUnique(blueprint Blueprint, command *Command) string
// CompileViews Compile the query to determine the views.
CompileViews(database string) string
// GetAttributeCommands Get the commands for the schema build.
GetAttributeCommands() []string
// TypeBigInteger Create the column definition for a big integer type.
TypeBigInteger(column ColumnDefinition) string
// TypeBoolean Create the column definition for a boolean type.
TypeBoolean(column ColumnDefinition) string
// TypeChar Create the column definition for a char type.
TypeChar(column ColumnDefinition) string
// TypeDate Create the column definition for a date type.
TypeDate(column ColumnDefinition) string
// TypeDateTime Create the column definition for a date-time type.
TypeDateTime(column ColumnDefinition) string
// TypeDateTimeTz Create the column definition for a date-time (with time zone) type.
TypeDateTimeTz(column ColumnDefinition) string
// TypeDecimal Create the column definition for a decimal type.
TypeDecimal(column ColumnDefinition) string
// TypeDouble Create the column definition for a double type.
TypeDouble(column ColumnDefinition) string
// TypeEnum Create the column definition for an enumeration type.
TypeEnum(column ColumnDefinition) string
// TypeFloat Create the column definition for a float type.
TypeFloat(column ColumnDefinition) string
// TypeInteger Create the column definition for an integer type.
TypeInteger(column ColumnDefinition) string
// TypeJson Create the column definition for a json type.
TypeJson(column ColumnDefinition) string
// TypeJsonb Create the column definition for a jsonb type.
TypeJsonb(column ColumnDefinition) string
// TypeLongText Create the column definition for a long text type.
TypeLongText(column ColumnDefinition) string
// TypeMediumInteger Create the column definition for a medium integer type.
TypeMediumInteger(column ColumnDefinition) string
// TypeMediumText Create the column definition for a medium text type.
TypeMediumText(column ColumnDefinition) string
// TypeText Create the column definition for a text type.
TypeText(column ColumnDefinition) string
// TypeTime Create the column definition for a time type.
TypeTime(column ColumnDefinition) string
// TypeTimeTz Create the column definition for a time (with time zone) type.
TypeTimeTz(column ColumnDefinition) string
// TypeTimestamp Create the column definition for a timestamp type.
TypeTimestamp(column ColumnDefinition) string
// TypeTimestampTz Create the column definition for a timestamp (with time zone) type.
TypeTimestampTz(column ColumnDefinition) string
// TypeTinyInteger Create the column definition for a tiny integer type.
TypeTinyInteger(column ColumnDefinition) string
// TypeTinyText Create the column definition for a tiny text type.
TypeTinyText(column ColumnDefinition) string
// TypeSmallInteger Create the column definition for a small integer type.
TypeSmallInteger(column ColumnDefinition) string
// TypeString Create the column definition for a string type.
TypeString(column ColumnDefinition) string
// TypeUuid Create the column definition for a uuid type.
TypeUuid(column ColumnDefinition) string
}
Click to show internal directories.
Click to hide internal directories.