Documentation
¶
Index ¶
- Constants
- func BeforeUpdate(db *gorm.DB)
- func New(config Config) gorm.Dialector
- func Open(dsn string) gorm.Dialector
- func RunTransaction(ctx context.Context, db *gorm.DB, fc func(tx *gorm.DB) error, ...) error
- type BoolArray
- type BytesArray
- type Column
- type CommitTimestamp
- type Config
- type DateArray
- type Dialector
- func (dialector Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})
- func (dialector Dialector) DataTypeOf(field *schema.Field) string
- func (dialector Dialector) DefaultValueOf(field *schema.Field) clause.Expression
- func (dialector Dialector) Explain(sql string, vars ...interface{}) string
- func (dialector Dialector) Initialize(db *gorm.DB) (err error)
- func (dialector Dialector) Migrator(db *gorm.DB) gorm.Migrator
- func (dialector Dialector) Name() string
- func (dialector Dialector) QuoteTo(writer clause.Writer, str string)
- type Exprs
- type Float32Array
- type Float64Array
- type Index
- type IndexHint
- type Int64Array
- type NullBoolArray
- type NullBytesArray
- type NullDateArray
- type NullFloat32Array
- type NullFloat64Array
- type NullInt64Array
- type NullJSONArray
- type NullStringArray
- type NullTimeArray
- type SpannerMigrator
- type StringArray
- type TimeArray
Constants ¶
const ( DefaultSequenceKind = "BIT_REVERSED_POSITIVE" AutoIncrementIdentityColumns = "AUTO_INCREMENT" DisableIdentityColumns = "DISABLED" )
Variables ¶
This section is empty.
Functions ¶
func BeforeUpdate ¶
Types ¶
type BoolArray ¶ added in v1.6.0
type BoolArray []bool
BoolArray is a named type for storing bool arrays in Spanner. This type cannot contain any NULL elements. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`.
func (BoolArray) GormDBDataType ¶ added in v1.6.0
func (BoolArray) GormDataType ¶ added in v1.6.0
type BytesArray ¶ added in v1.6.0
type BytesArray [][]byte
BytesArray is a named type for storing bytes arrays in Spanner. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`.
func (BytesArray) GormDBDataType ¶ added in v1.6.0
func (BytesArray) GormDataType ¶ added in v1.6.0
func (a BytesArray) GormDataType() string
func (*BytesArray) Scan ¶ added in v1.6.0
func (a *BytesArray) Scan(v any) error
type Column ¶
type Column struct {
// contains filtered or unexported fields
}
func (Column) DatabaseTypeName ¶
func (Column) DecimalSize ¶
DecimalSize return precision int64, scale int64, ok bool
type CommitTimestamp ¶
CommitTimestamp can be used for columns that should write the PENDING_COMMIT_TIMESTAMP(). Use it as the type for a field in a model. The corresponding database column must be of type TIMESTAMP, and the option `allow_commit_timestamp=true` must have been set. The Spanner gorm migrator will automatically create a TIMESTAMP column with the `allow_commit_timestamp=true` option enabled for any field that has type CommitTimestamp.
Note that the commit timestamp is not returned directly after inserting/updating a row. Instead, the value can only be read after the transaction has been committed.
Example:
type Singer struct {
ID int64
Name string
LastUpdated CommitTimestamp
}
func (CommitTimestamp) GormDataType ¶
func (ct CommitTimestamp) GormDataType() string
GormDataType implements gorm.GormDataTypeInterface.
func (*CommitTimestamp) Scan ¶
func (ct *CommitTimestamp) Scan(v interface{}) error
Scan implements the sql.Scanner interface
type Config ¶
type Config struct {
DriverName string
// DSN is the Data Source Name that should be used to open a database connection.
// Only set one of DSN, Connector, and Conn.
DSN string
// Connector is the driver.Connector that should be used to open a database connection.
// Create a driver.Connector for Spanner by calling spannerdriver.CreateConnector.
// A connector should be created only once and used to create all database connections.
// Only set one of DSN, Connector, and Conn.
Connector driver.Connector
// Conn is a pre-created gorm connection pool.
// Only set one of DSN, Connector, and Conn.
Conn gorm.ConnPool
// DisableAutoMigrateBatching turns off DDL batching for AutoMigrate calls.
// Cloud Spanner by default uses DDL batching when AutoMigrate is called, as
// executing multiple DDL statements in a single batch is a lot more efficient
// than executing each statement separately. You should only use this option
// if you are experiencing problems with the automatic batching of DDL
// statements when calling AutoMigrate.
DisableAutoMigrateBatching bool
// DefaultSequenceKind is the value that will be used for auto-generated
// primary keys. This configuration option defaults to 'bit_reversed_positive'
// if no value has been set.
//
// Set this configuration option to AUTO_INCREMENT to use the AUTO_INCREMENT
// keyword. The auto-generated value will then use the default_sequence_kind
// that is configured in the database. This returns an error if the database
// does not have a default_sequence_kind.
//
// Set this configuration option to DISABLED to fall back to using sequences
// for auto-increment primary keys.
DefaultSequenceKind string
}
type DateArray ¶ added in v1.6.0
DateArray is a named type for storing date arrays in Spanner. This type cannot contain any NULL elements. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`.
func (DateArray) GormDBDataType ¶ added in v1.6.0
func (DateArray) GormDataType ¶ added in v1.6.0
type Dialector ¶
type Dialector struct {
*Config
}
func (Dialector) DefaultValueOf ¶
func (dialector Dialector) DefaultValueOf(field *schema.Field) clause.Expression
type Exprs ¶
type Exprs []clause.Expression
type Float32Array ¶ added in v1.6.0
type Float32Array []float32
Float32Array is a named type for storing float32 arrays in Spanner. This type cannot contain any NULL elements. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`.
func (Float32Array) GormDBDataType ¶ added in v1.6.0
func (Float32Array) GormDataType ¶ added in v1.6.0
func (a Float32Array) GormDataType() string
func (*Float32Array) Scan ¶ added in v1.6.0
func (a *Float32Array) Scan(v any) error
type Float64Array ¶ added in v1.6.0
type Float64Array []float64
Float64Array is a named type for storing float64 arrays in Spanner. This type cannot contain any NULL elements. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`.
func (Float64Array) GormDBDataType ¶ added in v1.6.0
func (Float64Array) GormDataType ¶ added in v1.6.0
func (a Float64Array) GormDataType() string
func (*Float64Array) Scan ¶ added in v1.6.0
func (a *Float64Array) Scan(v any) error
type Int64Array ¶ added in v1.6.0
type Int64Array []int64
Int64Array is a named type for storing int64 arrays in Spanner. This type cannot contain any NULL elements. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`.
func (Int64Array) GormDBDataType ¶ added in v1.6.0
func (Int64Array) GormDataType ¶ added in v1.6.0
func (a Int64Array) GormDataType() string
func (*Int64Array) Scan ¶ added in v1.6.0
func (a *Int64Array) Scan(v any) error
type NullBoolArray ¶ added in v1.6.0
NullBoolArray is a named type for storing bool arrays in Spanner. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`. ARRAY<BOOL> is by default mapped to []spanner.NullBool in the Spanner database/sql driver. This is because Spanner always allows arrays to contain null elements, even if the column itself is defined as NOT NULL.
func (NullBoolArray) GormDBDataType ¶ added in v1.6.0
func (NullBoolArray) GormDataType ¶ added in v1.6.0
func (a NullBoolArray) GormDataType() string
type NullBytesArray ¶ added in v1.6.0
type NullBytesArray BytesArray
NullBytesArray is a synonym for BytesArray. It is only defined for consistency with the other array data types.
func (NullBytesArray) GormDBDataType ¶ added in v1.6.0
func (NullBytesArray) GormDataType ¶ added in v1.6.0
func (a NullBytesArray) GormDataType() string
func (*NullBytesArray) Scan ¶ added in v1.6.0
func (a *NullBytesArray) Scan(v any) error
type NullDateArray ¶ added in v1.6.0
NullDateArray is a named type for storing date arrays in Spanner. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`. ARRAY<DATE> is by default mapped to []spanner.NullDate in the Spanner database/sql driver. This is because Spanner always allows arrays to contain null elements, even if the column itself is defined as NOT NULL.
func (NullDateArray) GormDBDataType ¶ added in v1.6.0
func (NullDateArray) GormDataType ¶ added in v1.6.0
func (a NullDateArray) GormDataType() string
type NullFloat32Array ¶ added in v1.6.0
type NullFloat32Array []spanner.NullFloat32
NullFloat32Array is a named type for storing float32 arrays in Spanner. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`. ARRAY<FLOAT32> is by default mapped to []spanner.NullFloat32 in the Spanner database/sql driver. This is because Spanner always allows arrays to contain null elements, even if the column itself is defined as NOT NULL.
func (NullFloat32Array) GormDBDataType ¶ added in v1.6.0
func (NullFloat32Array) GormDataType ¶ added in v1.6.0
func (a NullFloat32Array) GormDataType() string
type NullFloat64Array ¶ added in v1.6.0
type NullFloat64Array []spanner.NullFloat64
NullFloat64Array is a named type for storing float64 arrays in Spanner. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`. ARRAY<FLOAT64> is by default mapped to []spanner.NullFloat64 in the Spanner database/sql driver. This is because Spanner always allows arrays to contain null elements, even if the column itself is defined as NOT NULL.
func (NullFloat64Array) GormDBDataType ¶ added in v1.6.0
func (NullFloat64Array) GormDataType ¶ added in v1.6.0
func (a NullFloat64Array) GormDataType() string
type NullInt64Array ¶ added in v1.6.0
NullInt64Array is a named type for storing int64 arrays in Spanner. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`. ARRAY<INT64> is by default mapped to []spanner.NullInt64 in the Spanner database/sql driver. This is because Spanner always allows arrays to contain null elements, even if the column itself is defined as NOT NULL.
func (NullInt64Array) GormDBDataType ¶ added in v1.6.0
func (NullInt64Array) GormDataType ¶ added in v1.6.0
func (a NullInt64Array) GormDataType() string
type NullJSONArray ¶ added in v1.6.0
NullJSONArray is a named type for storing JSON arrays in Spanner. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`. ARRAY<JSON> is by default mapped to []spanner.NullJSON in the Spanner database/sql driver. This is because Spanner always allows arrays to contain null elements, even if the column itself is defined as NOT NULL.
func (NullJSONArray) GormDBDataType ¶ added in v1.6.0
func (NullJSONArray) GormDataType ¶ added in v1.6.0
func (a NullJSONArray) GormDataType() string
type NullStringArray ¶ added in v1.6.0
type NullStringArray []spanner.NullString
NullStringArray is a named type for storing string arrays in Spanner. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`. ARRAY<STRING> is by default mapped to []spanner.NullString in the Spanner database/sql driver. This is because Spanner always allows arrays to contain null elements, even if the column itself is defined as NOT NULL.
func (NullStringArray) GormDBDataType ¶ added in v1.6.0
func (NullStringArray) GormDataType ¶ added in v1.6.0
func (a NullStringArray) GormDataType() string
type NullTimeArray ¶ added in v1.6.0
NullTimeArray is a named type for storing timestamp arrays in Spanner. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`. ARRAY<TIMESTAMP> is by default mapped to []spanner.NullTime in the Spanner database/sql driver. This is because Spanner always allows arrays to contain null elements, even if the column itself is defined as NOT NULL.
func (NullTimeArray) GormDBDataType ¶ added in v1.6.0
func (NullTimeArray) GormDataType ¶ added in v1.6.0
func (a NullTimeArray) GormDataType() string
type SpannerMigrator ¶
type StringArray ¶ added in v1.6.0
type StringArray []string
StringArray is a named type for storing string arrays in Spanner. This type cannot contain any NULL elements. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`.
func (StringArray) GormDBDataType ¶ added in v1.6.0
func (StringArray) GormDataType ¶ added in v1.6.0
func (a StringArray) GormDataType() string
func (*StringArray) Scan ¶ added in v1.6.0
func (a *StringArray) Scan(v any) error
type TimeArray ¶ added in v1.6.0
TimeArray is a named type for storing date arrays in Spanner. This type cannot contain any NULL elements. We must use a named type for this to implement the driver.Valuer interface. This is required, because gorm otherwise translates arrays/slices to literals in the form `(item1, item2, ..., itemN)`.