GORM Playground Link
https://github.com/go-gorm/playground/pull/1
Description
gorm query doris (use prepared statement)
import (
"encoding/json"
"fmt"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
type Food struct {
Id int
Name string
Price float64
TypeId int
CreateTime int64 `gorm:"column:createtime"`
}
func (v Food) TableName() string {
return "food"
}
func queryDoris() []Food {
dsn := "root:xxx@tcp(xxx:9030)/test_db?charset=utf8mb4"
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{PrepareStmt: true})
if err != nil {
panic("failed to connect database")
}
fmt.Println("connect Doris success")
var food []Food
//db.Debug().Where("id = 1").First(&food) // success
db.Debug().Where("id = ?", 1).First(&food)
//db.Raw("SELECT id, name,price,type_id,createtime FROM food WHERE id = ?", 1).Scan(&food)
jsonVal, err := json.Marshal(food)
if err == nil {
fmt.Println("Doris data:", string(jsonVal))
} else {
panic(err)
}
return food
}
springboot query doris (use prepared statement)
public Result getData(@PathVariable String id) {
LambdaQueryWrapper<FlowNewEntity> lqw = new LambdaQueryWrapper<>();
LambdaQueryWrapper<FlowNewEntity> sql = lqw.eq(FlowNewEntity::getId, id)
.orderBy(true, true, FlowNewEntity::getId);
List<FlowNewEntity> list = service.list(sql);
return Result.ok(list);
}
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: moody1117
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the
Questiontemplate, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
There is reproduced code in this issue, and there are references to this problem in other issues, but no solution. @jinzhu
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨