May I ask how the TOSQL method can wrap the variable of string type with 'xxx' single quotes instead of "xxx" double quotes

question

May I ask how the TOSQL method can wrap the variable of string type with 'xxx' single quotes instead of "xxx" double quotes

The document you expected this should be explained

package main

import (
    "fmt"
    "gorm.io/driver/sqlite"
    "gorm.io/gorm"
)

type Product struct {
    gorm.Model
    Code  string
    Price uint
}

func main() {
    db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
    if err != nil {
        panic("failed to connect database")
    }
    var product Product
    sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
        return tx.Model(&product).Updates(map[string]interface{}{"Price": 200, "Code": "F42"})
    })
    fmt.Println(sql)
}
 I want to get the sql : UPDATE `products` SET `code`='F42',`price`=200,`updated_at`='2022-11-14 20:11:31.14' WHERE `products`.`deleted_at` IS NULL 

cauz there may be some " in my variable

but now , i get :

UPDATE `products` SET `code`="F42",`price`=200,`updated_at`="2022-11-14 20:11:31.14" WHERE `products`.`deleted_at` IS NULL

Expected answer

how can i get the sql style ( single quotes for varchar/string) from tosql method?

Comment From: a631807682

This is determined by different drivers, which means that the sql you generate from sqlite cannot be guaranteed to be executed in other databases. https://github.com/go-gorm/mysql/blob/master/mysql.go#L333