- Added Options.MinIdleConns.
- Options.MaxAge renamed to Options.MaxConnAge.
- PoolStats.FreeConns is renamed to PoolStats.IdleConns.
- New hook BeforeSelectQuery.
,override
is renamed to,inherit
.- Dialer.KeepAlive is set to 5 minutes by default.
- Added support "scram-sha-256" authentication.
- Fields ignored with
sql:"-"
tag are no longer considered by ORM relation detector.
Insert
,Update
, andDelete
can returnpg.ErrNoRows
andpg.ErrMultiRows
whenReturning
is used and model expects single row.
db.Model(&strct).Update()
anddb.Model(&strct).Delete()
no longer adds WHERE condition based on primary key when there are no conditions. Instead you should usedb.Update(&strct)
ordb.Model(&strct).WherePK().Update()
.
?Columns
is renamed to?TableColumns
.?Columns
is changed to produce column names without table alias.
pg:"fk"
tag now accepts SQL names instead of Go names, e.g.pg:"fk:ParentId"
becomespg:"fk:parent_id"
. Old code should continue working in most cases, but it is strongly advised to start using new convention.- uint and uint64 SQL type is changed from decimal to bigint according to the the lesser of two evils principle. Use
sql:"type:decimal"
to get old behavior.
CreateTable
no longer adds ON DELETE hook by default. To get old behavior users should addsql:"on_delete:CASCADE"
tag on foreign key field.
types.Result
is renamed toorm.Result
.- Added
OnQueryProcessed
event that can be used to log / report queries timing. Query logger is removed. orm.URLValues
is renamed toorm.URLFilters
. It no longer adds ORDER clause.orm.Pager
is renamed toorm.Pagination
.- Support for net.IP and net.IPNet.
- Support for context.Context.
- Bulk/multi updates.
- Query.WhereGroup for enclosing conditions in paretheses.
- All fields are nullable by default.
,null
tag is replaced with,notnull
. Result.Affected
renamed toResult.RowsAffected
.- Added
Result.RowsReturned
. Create
renamed toInsert
,BeforeCreate
toBeforeInsert
,AfterCreate
toAfterInsert
.- Indexed placeholders support, e.g.
db.Exec("SELECT ?0 + ?0", 1)
. - Named placeholders are evaluated when query is executed.
- Added Update and Delete hooks.
- Order reworked to quote column names. OrderExpr added to bypass Order quoting restrictions.
- Group reworked to quote column names. GroupExpr added to bypass Group quoting restrictions.
Options.Host
andOptions.Port
merged intoOptions.Addr
.- Added
Options.MaxRetries
. Now queries are not retried by default. LoadInto
renamed toScan
,ColumnLoader
renamed toColumnScanner
, LoadColumn renamed to ScanColumn,NewRecord() interface{}
changed toNewModel() ColumnScanner
,AppendQuery(dst []byte) []byte
changed toAppendValue(dst []byte, quote bool) ([]byte, error)
.- Structs, maps and slices are marshalled to JSON by default.
- Added support for scanning slices, .e.g. scanning
[]int
. - Added object relational mapping.