add test and fix bug
This commit is contained in:
parent
d25d5bdf9c
commit
a64f22fd4d
@ -23,6 +23,11 @@ type RowsQueryResult struct {
|
|||||||
func rowQueryCallback(scope *Scope) {
|
func rowQueryCallback(scope *Scope) {
|
||||||
if result, ok := scope.InstanceGet("row_query_result"); ok {
|
if result, ok := scope.InstanceGet("row_query_result"); ok {
|
||||||
scope.prepareQuerySQL()
|
scope.prepareQuerySQL()
|
||||||
|
|
||||||
|
if str, ok := scope.Get("gorm:query_hint"); ok {
|
||||||
|
scope.SQL = fmt.Sprint(str) + scope.SQL
|
||||||
|
}
|
||||||
|
|
||||||
if str, ok := scope.Get("gorm:query_option"); ok {
|
if str, ok := scope.Get("gorm:query_option"); ok {
|
||||||
scope.SQL += addExtraSpaceIfExist(fmt.Sprint(str))
|
scope.SQL += addExtraSpaceIfExist(fmt.Sprint(str))
|
||||||
}
|
}
|
||||||
|
11
main_test.go
11
main_test.go
@ -1262,6 +1262,17 @@ func TestCountWithQueryOption(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestQueryHint(t *testing.T) {
|
||||||
|
db := DB.New()
|
||||||
|
var count int
|
||||||
|
|
||||||
|
err := db.Set("gorm:query_hint", "/*master*/").Raw("select ?", "1").Count(&count).Error
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Error("Unexpected error on query_hint")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestFloatColumnPrecision(t *testing.T) {
|
func TestFloatColumnPrecision(t *testing.T) {
|
||||||
if dialect := os.Getenv("GORM_DIALECT"); dialect != "mysql" && dialect != "sqlite" {
|
if dialect := os.Getenv("GORM_DIALECT"); dialect != "mysql" && dialect != "sqlite" {
|
||||||
t.Skip()
|
t.Skip()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user