Documentation ¶
Index ¶
- Variables
- func AddSessionParams(db *sql.DB, params map[string]string, originals ...bool) (keys []string, err error)
- func BuildUrl(server string, port int, service, user, password string, ...) string
- func ConvertNameToFormat(x string) stringdeprecated
- func ConvertToAssignments(stmt *gorm.Statement) (set clause.Set)
- func Create(db *gorm.DB)
- func DelSessionParams(db *sql.DB, keys []string)
- func GetStringExpr(value string, quotes ...bool) clause.Expr
- func IsReservedWord(v string) bool
- func MergeCreate(db *gorm.DB, onConflict clause.OnConflict, values clause.Values)
- func New(config Config) gorm.Dialector
- func Open(dsn string) gorm.Dialector
- func Update(config *callbacks.Config) func(db *gorm.DB)
- type Config
- type DataSet
- type Dialector
- func (d Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, _ interface{})
- func (d Dialector) ClauseBuilders() (clauseBuilders map[string]clause.ClauseBuilder)
- func (d Dialector) DataTypeOf(field *schema.Field) string
- func (d Dialector) DefaultValueOf(*schema.Field) clause.Expression
- func (d Dialector) DummyTableName() string
- func (d Dialector) Explain(sql string, vars ...interface{}) string
- func (d Dialector) Initialize(db *gorm.DB) (err error)
- func (d Dialector) Migrator(db *gorm.DB) gorm.Migrator
- func (d Dialector) Name() string
- func (d Dialector) QuoteTo(writer clause.Writer, str string)
- func (d Dialector) RewriteLimit(c clause.Clause, builder clause.Builder)
- func (d Dialector) RewriteLimit11(c clause.Clause, builder clause.Builder)
- func (d Dialector) RollbackTo(tx *gorm.DB, name string) error
- func (d Dialector) SavePoint(tx *gorm.DB, name string) error
- type Migrator
- func (m Migrator) AddColumn(value interface{}, name string) (err error)
- func (m Migrator) AlterColumn(value interface{}, field string) error
- func (m Migrator) AlterDataTypeOf(stmt *gorm.Statement, field *schema.Field) (expr clause.Expr)
- func (m Migrator) AutoMigrate(dst ...interface{}) error
- func (m Migrator) ColumnTypes(value interface{}) ([]gorm.ColumnType, error)
- func (m Migrator) CreateConstraint(value interface{}, name string) error
- func (m Migrator) CreateTable(values ...interface{}) (err error)
- func (m Migrator) CurrentDatabase() (name string)
- func (m Migrator) DropColumn(value interface{}, name string) error
- func (m Migrator) DropConstraint(value interface{}, name string) error
- func (m Migrator) DropIndex(value interface{}, name string) error
- func (m Migrator) DropTable(values ...interface{}) error
- func (m Migrator) FullDataTypeOf(field *schema.Field) (expr clause.Expr)
- func (m Migrator) GetTables() (tableList []string, err error)
- func (m Migrator) GetTypeAliases(databaseTypeName string) (types []string)
- func (m Migrator) HasColumn(value interface{}, field string) bool
- func (m Migrator) HasConstraint(value interface{}, name string) bool
- func (m Migrator) HasIndex(value interface{}, name string) bool
- func (m Migrator) HasTable(value interface{}) bool
- func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnType gorm.ColumnType) (err error)
- func (m Migrator) RenameIndex(value interface{}, oldName, newName string) error
- func (m Migrator) RenameTable(oldName, newName interface{}) (err error)
- func (m Migrator) TryQuotifyReservedWords(values ...interface{}) error
- func (m Migrator) TryRemoveOnUpdate(values ...interface{}) error
- type Namer
- func (n Namer) CheckerName(table, column string) (name string)
- func (n Namer) ColumnName(table, column string) (name string)
- func (n Namer) ConvertNameToFormat(x string) string
- func (n Namer) IndexName(table, column string) (name string)
- func (n Namer) JoinTableName(table string) (name string)
- func (n Namer) RelationshipFKName(relationship schema.Relationship) (name string)
- func (n Namer) SchemaName(table string) string
- func (n Namer) TableName(table string) (name string)
- func (n Namer) UniqueName(table, column string) string
- type Out
- type RefCursor
Constants ¶
This section is empty.
Variables ¶
var ReservedWords = hashset.New(func() []interface{} { reservedWords := make([]interface{}, len(ReservedWordsList)) for i, word := range ReservedWordsList { reservedWords[i] = word } return reservedWords }()...)
var ReservedWordsList = []string{}/* 143 elements not displayed */
Functions ¶
func AddSessionParams ¶ added in v1.5.11
func AddSessionParams(db *sql.DB, params map[string]string, originals ...bool) (keys []string, err error)
AddSessionParams setting database connection session parameters, the value is wrapped in single quotes.
If the value doesn't need to be wrapped in single quotes, please use the go_ora.AddSessionParam function directly, or pass the originals parameter as true.
func BuildUrl ¶ added in v1.3.0
func BuildUrl(server string, port int, service, user, password string, options map[string]string) string
BuildUrl create databaseURL from server, port, service, user, password, urlOptions this function help build a will formed databaseURL and accept any character as it convert special charters to corresponding values in URL
func ConvertNameToFormat
deprecated
func ConvertToAssignments ¶ added in v1.4.2
ConvertToAssignments convert to update assignments
func DelSessionParams ¶ added in v1.5.11
DelSessionParams remove session parameters
func GetStringExpr ¶ added in v1.5.9
GetStringExpr replace single quotes in the string with two single quotes and return the expression for the string value
quotes : if the SQL placeholder is ? then pass true, if it is '?' then do not pass or pass false.
func IsReservedWord ¶
func MergeCreate ¶ added in v1.5.12
Types ¶
type Config ¶
type Config struct { DriverName string DSN string Conn gorm.ConnPool //*sql.DB DefaultStringSize uint DBVer string IgnoreCase bool // warning: may cause performance issues NamingCaseSensitive bool // whether naming is case-sensitive // whether VARCHAR type size is character length, defaulting to byte length VarcharSizeIsCharLength bool // RowNumberAliasForOracle11 is the alias for ROW_NUMBER() in Oracle 11g, defaulting to ROW_NUM RowNumberAliasForOracle11 string }
type Dialector ¶
type Dialector struct {
*Config
}
Dialector implement GORM database dialector
func (Dialector) ClauseBuilders ¶
func (d Dialector) ClauseBuilders() (clauseBuilders map[string]clause.ClauseBuilder)
func (Dialector) DefaultValueOf ¶
func (d Dialector) DefaultValueOf(*schema.Field) clause.Expression
func (Dialector) DummyTableName ¶
func (Dialector) RewriteLimit ¶
func (Dialector) RewriteLimit11 ¶ added in v1.3.39
RewriteLimit11 rewrite the LIMIT clause in the query to accommodate pagination requirements for Oracle 11g and lower database versions
Limit and Offset ¶
SELECT * FROM (SELECT T.*, ROW_NUMBER() OVER (ORDER BY column) AS ROW_NUM FROM table_name T) WHERE ROW_NUM BETWEEN offset+1 AND offset+limit
Only Limit ¶
SELECT * FROM table_name WHERE ROWNUM <= limit ORDER BY column
Only Offset ¶
SELECT * FROM table_name WHERE ROWNUM > offset ORDER BY column
type Migrator ¶
Migrator implement gorm migrator interface
func (Migrator) AlterColumn ¶
AlterColumn alter value's "field" column's type based on schema definition
func (Migrator) AlterDataTypeOf ¶ added in v1.3.26
func (Migrator) AutoMigrate ¶ added in v1.3.64
AutoMigrate 自动迁移模型为表结构
// 迁移并设置单个表注释 db.Set("gorm:table_comments", "用户信息表").AutoMigrate(&User{}) // 迁移并设置多个表注释 db.Set("gorm:table_comments", []string{"用户信息表", "公司信息表"}).AutoMigrate(&User{}, &Company{})
func (Migrator) ColumnTypes ¶ added in v1.3.26
func (m Migrator) ColumnTypes(value interface{}) ([]gorm.ColumnType, error)
ColumnTypes return columnTypes []gorm.ColumnType and execErr error
func (Migrator) CreateConstraint ¶
CreateConstraint create constraint
func (Migrator) CreateTable ¶
CreateTable create table in database for values
func (Migrator) CurrentDatabase ¶
CurrentDatabase returns current database name
func (Migrator) DropColumn ¶
DropColumn drop value's "name" column
func (Migrator) DropConstraint ¶
DropConstraint drop constraint
func (Migrator) FullDataTypeOf ¶ added in v1.5.3
FullDataTypeOf returns field's db full data type
func (Migrator) GetTables ¶ added in v1.5.19
GetTables returns tables under the current user database
func (Migrator) GetTypeAliases ¶ added in v1.4.0
GetTypeAliases return database type aliases
func (Migrator) HasConstraint ¶
HasConstraint check has constraint or not
func (Migrator) HasTable ¶
HasTable returns table exists or not for value, value could be a struct or string
func (Migrator) MigrateColumn ¶ added in v1.5.7
func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnType gorm.ColumnType) (err error)
MigrateColumn migrate column
func (Migrator) RenameIndex ¶
RenameIndex rename index from oldName to newName
see also: https://docs.oracle.com/database/121/SPATL/alter-index-rename.htm
func (Migrator) RenameTable ¶
RenameTable rename table from oldName to newName
func (Migrator) TryQuotifyReservedWords ¶
func (Migrator) TryRemoveOnUpdate ¶
type Namer ¶
type Namer struct { // NamingStrategy use custom naming strategy in gorm.Config on initialize NamingStrategy schema.Namer // CaseSensitive determines whether naming is case-sensitive CaseSensitive bool }
Namer implement gorm schema namer interface
func (Namer) CheckerName ¶
CheckerName generate checker name
func (Namer) ColumnName ¶
ColumnName convert string to column name
func (Namer) ConvertNameToFormat ¶ added in v1.5.0
ConvertNameToFormat return appropriate capitalization name based on CaseSensitive
func (Namer) JoinTableName ¶
JoinTableName convert string to join table name
func (Namer) RelationshipFKName ¶
func (n Namer) RelationshipFKName(relationship schema.Relationship) (name string)
RelationshipFKName generate fk name for relation
func (Namer) SchemaName ¶ added in v1.6.5
SchemaName generate schema name from table name, don't guarantee it is the reverse value of TableName
func (Namer) UniqueName ¶ added in v1.6.5
UniqueName generate unique constraint name