使用 xorm 和 gorm 操作 doris2.0 都不成功,看文档没有说支持 doris ,但是 doris 本身应该高度兼容 mysql 的吧,这些 orm 框架这么严格?还是代码上有问题?
xorm code:
func SelectAd() {
engine := _init_db("10.22.xx", "9030", "abc")
ad := new(FlowAdUrlStat)
if _, err := engine.Where("opt_YYYYMMDD=?", 20240626).Get(ad); err != nil {
log.Fatal(err)
}
fmt.Println(ad)
}
报错: 2024/06/27 10:55:37 Error 1105 (HY000): errCode = 2, detailMessage = Only support prepare SelectStmt point query now
gorm code:
var ad FlowAdUrlStat
stmt := db.Session(&gorm.Session{DryRun: true}).Where("opt_YYYYMMDD = ?", 20240626).Take(&ad).Statement
fmt.Println(stmt.SQL.String())
fmt.Println(stmt.Vars)
if err := db.Where("opt_YYYYMMDD = ?", 20240626).Take(&ad).Error; err != nil {
log.Fatal(err)
}
fmt.Println(ad)
报错:
output:
Type 'dlv help' for list of commands.
SELECT * FROM flow_ad_url_stat WHERE opt_YYYYMMDD = ? LIMIT ?
[20240626 1]
2024/06/26 18:07:03 Error 1105 (HY000): errCode = 2, detailMessage = Syntax error in line 1:
...RE opt_YYYYMMDD = ? LIMIT ?
^
Encountered: ?
Expected
2024/06/26 18:07:03 D:/goproject/cloudsvc/dbutils/mysqlutil.go:63 Error 1105 (HY000): errCode = 2, detailMessage = Syntax error in line 1:
...RE opt_YYYYMMDD = ? LIMIT ?
^
Encountered: ?
Expected
[58.356ms] [rows:0] SELECT * FROM flow_ad_url_stat WHERE opt_YYYYMMDD = 20240626 LIMIT 1
Process 48512 has exited with status 1
Detaching
![]() |
1
Jim2Chen 8 天前
蹲一个,我也很想知道
|
![]() |
2
MoYi123 8 天前
报错原因不是都写了吗?
OLAP 数据库不用 prepare 模式也能理解吧. |
![]() |
3
zong400 OP @MoYi123 试了 gorm 的 db.Raw 也是报错
``` if err := db.Raw("select * from flow_ad_url_stat limit 1").Scan(&ad).Error; err != nil { log.Fatal(err) } 2024/06/27 15:29:37 Error 1105 (HY000): errCode = 2, detailMessage = Only support prepare SelectStmt point query now 2024/06/27 15:29:37 D:/goproject/cloudsvc/dbutils/mysqlutil.go:59 Error 1105 (HY000): errCode = 2, detailMessage = Only support prepare SelectStmt point query now [63.082ms] [rows:-] select * from flow_ad_url_stat limit 1 ``` 倒是 xorm 的可用,但是不能装进 struct ,感觉有些别扭。 result, err := engine.QueryString("select * from flow_ad_url_stat limit 1") |