mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SQLStore: Fix wrong usage of xorm's insert functions in tests (#63850)
* SQLStore: Fix InsertId * Prefs: Fix Insert return value * Fix tests * Add guidelines
This commit is contained in:
committed by
GitHub
parent
afd5f41780
commit
89569be3a6
@@ -190,6 +190,12 @@ for context.
|
||||
|
||||
If a column, or column combination, should be unique, add a corresponding uniqueness constraint through a migration.
|
||||
|
||||
### Usage of XORM Session.Insert() and Session.InsertOne()
|
||||
|
||||
The [Session.Insert()](https://pkg.go.dev/github.com/go-xorm/xorm#Session.Insert) and [Session.InsertOne()](https://pkg.go.dev/github.com/go-xorm/xorm#Session.InsertOne) are poorly documented and return the number of affected rows contrary to a common mistake that they return the newly introduced primary key. Therefore, contributors should be extra cautious when using them.
|
||||
|
||||
The same applies for the respective [Engine.Insert()](https://pkg.go.dev/github.com/go-xorm/xorm#Engine.Insert) and [Engine.InsertOne()](https://pkg.go.dev/github.com/go-xorm/xorm#Engine.InsertOne)
|
||||
|
||||
## JSON
|
||||
|
||||
The simplejson package is used a lot throughout the backend codebase,
|
||||
|
||||
Reference in New Issue
Block a user