Documentation
¶
Index ¶
- Constants
- func BeforeQuery(db *gorm.DB)
- func Create(db *gorm.DB)
- func Delete(db *gorm.DB)
- func DeleteClauseBuilder(c clause.Clause, builder clause.Builder)
- func InsertClauseBuilder(c clause.Clause, builder clause.Builder)
- func LimitClauseBuilder(c clause.Clause, builder clause.Builder)
- func MismatchedCaseHandler(gormDB *gorm.DB)
- func New(config Config) gorm.Dialector
- func OnConflictClauseBuilder(c clause.Clause, builder clause.Builder)
- func Open(dsn string) gorm.Dialector
- func OracleClauseBuilders() map[string]clause.ClauseBuilder
- func QuoteIdentifier(identifier string) string
- func ReturningClauseBuilder(c clause.Clause, builder clause.Builder)
- func ShouldUseRealConflict(values clause.Values, onConflict clause.OnConflict, ...) bool
- func Update(db *gorm.DB)
- func UpdateClauseBuilder(c clause.Clause, builder clause.Builder)
- func ValuesClauseBuilder(c clause.Clause, builder clause.Builder)
- type Config
- type Dialector
- func (d Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})
- func (d Dialector) DataTypeOf(field *schema.Field) string
- func (d Dialector) DefaultValueOf(field *schema.Field) clause.Expression
- func (d Dialector) Explain(sqlStr 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) 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) error
- func (m Migrator) AlterColumn(value interface{}, field string) 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{}) error
- func (m Migrator) CurrentDatabase() 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) FkTriggerName(refTable string, refField string, table string, field string) string
- func (m Migrator) FullDataTypeOf(field *schema.Field) (expr clause.Expr)
- func (m Migrator) GetTables() (tableList []string, err error)
- 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) RenameIndex(value interface{}, oldName, newName string) error
- func (m Migrator) RenameTable(oldName, newName interface{}) error
- func (m Migrator) RunWithValue(value interface{}, fc func(*gorm.Statement) error) error
Constants ¶
const ( ClauseInsert = "INSERT" ClauseUpdate = "UPDATE" ClauseDelete = "DELETE" ClauseLimit = "LIMIT" ClauseOnConflict = "ON CONFLICT" ClauseValues = "VALUES" ClauseReturning = "RETURNING" )
const DefaultDriverName string = "godror"
Variables ¶
This section is empty.
Functions ¶
func BeforeQuery ¶ added in v0.2.0
func Create ¶
Create overrides GORM's create callback for Oracle.
Behavior:
- If the schema has fields with default DB values and only one row is being inserted, it builds an INSERT ... RETURNING statement.
- If no RETURNING is needed, it emits a standard INSERT.
- If multiple rows require RETURNING, it builds a PL/SQL block using FORALL and BULK COLLECT; if an ON CONFLICT clause is present and resolvable, it emits a MERGE.
- For that last case, it validates Dest (non-nil, non-empty slice with no nil elements), normalizes bind variables for Oracle, and populates destinations from OUT parameters.
Register with:
db.Callback().Create().Replace("gorm:create", oracle.Create)
func Delete ¶
Delete overrides GORM's delete callback for Oracle.
Delete builds a safe, Oracle-compatible DELETE that supports soft deletes, hard deletes, and optional RETURNING of deleted rows.
Behavior:
- DELETE safety: checks for missing WHERE conditions and refuses to run unless AllowGlobalUpdate is set or the WHERE clause has meaningful conditions.
- Soft delete: if the model has a soft-delete field and Unscoped is false, it lets GORM emit the UPDATE that marks rows as deleted. If a RETURNING clause is present with soft delete, it executes via QueryContext so the returned columns can be scanned.
- Hard delete + RETURNING: it emits a PL/SQL block that performs DELETE … RETURNING BULK COLLECT INTO, wiring per-row sql.Out destinations so the deleted rows (or selected columns) can be populated back into the destination slice.
- Hard delete (no RETURNING): it emits a standard DELETE and executes it via ExecContext.
- Expressions: it expands WHERE expressions, including IN with slices, and normalizes bind variables for Oracle.
Register with:
db.Callback().Delete().Replace("gorm:delete", oracle.Delete)
func DeleteClauseBuilder ¶
DeleteClauseBuilder builds the DELETE clause
func InsertClauseBuilder ¶
InsertClauseBuilder builds the INSERT INTO cluase
func LimitClauseBuilder ¶
LimitClauseBuilder builds the Oracle FETCH clause instead of using the default LIMIT syntax The FETCH syntax is supported in Oracle 12c and later
func MismatchedCaseHandler ¶ added in v0.2.0
MismatchedCaseHandler handles Oracle Case Insensitivity. When identifiers are not quoted, columns are returned by Oracle in uppercase. Fields in the models may be lower case for compatibility with other databases. Match them up with the fields using the column mapping.
func OnConflictClauseBuilder ¶
OnConflictClauseBuilder builds MERGE statement directly
func OracleClauseBuilders ¶
func OracleClauseBuilders() map[string]clause.ClauseBuilder
Returns the clause builders that are used to generate clauses for Oracle DB
func QuoteIdentifier ¶ added in v0.2.0
func ReturningClauseBuilder ¶
Enhanced ReturningClauseBuilder that handles both RETURNING and INTO
func ShouldUseRealConflict ¶
func ShouldUseRealConflict(values clause.Values, onConflict clause.OnConflict, conflictColumns []clause.Column) bool
Helper method to determine if we need MERGE
func Update ¶
Update overrides GORM's update callback for Oracle.
It builds Oracle-compatible UPDATE statements and supports:
- Standard updates without RETURNING using GORM’s default SQL build, with bind variable conversion for Oracle types.
- Updates with RETURNING, emitting a PL/SQL block that performs UPDATE … RETURNING BULK COLLECT INTO for multi-row updates, wiring sql.Out binds for each returned column and row.
- UPDATE safety: checks for missing WHERE conditions and refuses to run unless AllowGlobalUpdate is set or the WHERE clause has meaningful conditions (beyond soft-delete filters).
- Primary key WHERE injection when the destination object or slice has identifiable PK values, to avoid unintended mass updates.
- Soft-delete compatibility: conditions on deleted_at are ignored for the safety check, but preserved in the WHERE for the actual SQL.
For updates with RETURNING, OUT bind results are mapped back into the destination struct or slice using getUpdateReturningValues.
Register with:
db.Callback().Update().Replace("gorm:update", oracle.Update)
func UpdateClauseBuilder ¶
UpdateClauseBuilder builds the UPDATE clause
Types ¶
type Dialector ¶
type Dialector struct {
*Config
}
func (Dialector) DataTypeOf ¶
Determines the data type for a schema field
func (Dialector) DefaultValueOf ¶
func (d Dialector) DefaultValueOf(field *schema.Field) clause.Expression
func (Dialector) Explain ¶
Explain Formats SQL statements with variables, string literals will be encoded with in ”
func (Dialector) Initialize ¶
Initializes the database connection
func (Dialector) Migrator ¶
Migrator returns the migrator instance associated with the given gorm.DB
func (Dialector) RollbackTo ¶
RollbackTo Rolls back to the given save point
type Migrator ¶
func (Migrator) AlterColumn ¶
AlterColumn alters value's `field` column's type based on schema definition
func (Migrator) ColumnTypes ¶
func (m Migrator) ColumnTypes(value interface{}) ([]gorm.ColumnType, error)
ColumnTypes returns the column types for the given value’s table and any error encountered during execution
func (Migrator) CreateConstraint ¶ added in v0.2.0
CreateConstraint creates constraint based on the given 'value' and 'name'
func (Migrator) CreateTable ¶
CreateTable creates table in database for the given `values`
func (Migrator) CurrentDatabase ¶
CurrentDatabase returns the the name of the current Oracle database
func (Migrator) DropColumn ¶
DropColumn drops value's `name` column
func (Migrator) DropConstraint ¶ added in v0.2.0
DropConstraint drops constraint based on the given 'value' and 'name'
func (Migrator) DropIndex ¶
DropIndex drops the index with the specified `name` from the table associated with `value`
func (Migrator) DropTable ¶
DropTable drops the table starting from the bottom of the dependency chain. The function returns an error when Oracle databases report a missing table. If multiple errors occur, it returns a combined (joint) error.
func (Migrator) FkTriggerName ¶ added in v0.2.0
func (Migrator) FullDataTypeOf ¶
func (Migrator) HasColumn ¶
HasColumn checks whether the table for the given value contains the specified column `field`
func (Migrator) HasConstraint ¶
HasConstraint checks whether the table for the given `value` contains the specified constraint `name`
func (Migrator) HasIndex ¶
HasIndex checks whether the table for the given `value` contains an index with the specified `name`
func (Migrator) HasTable ¶
HasTable returns table exists or not for value, value could be a struct or string
func (Migrator) RenameIndex ¶
RenameIndex renames index from oldName to newName on the table for the given `value`
func (Migrator) RenameTable ¶
RenameTable renames table from oldName to newName