gf icon indicating copy to clipboard operation
gf copied to clipboard

os/gtime: issue title 使用Postgresql数据库COUNT时出现(1)语法错误

Open lyvision001 opened this issue 6 months ago • 2 comments

Go version

1.23

GoFrame version

2.9.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

goframe使用Postgresql,在进行数据count时,会出现(1)的语法错误。

What did you see happen?

goframe使用Postgresql,在进行数据count时,会出现(1)的语法错误,发现是gdb_model_builder里Build()将len(newWhere)>0时,直接返回"1"。如果增加判断将1改为true返回,则正常。是否可完善一下。

What did you expect to see?

是否需要完善,或是通过字段过滤可以解决,我测试了一下,没有找到解决方法,还是需要修改gdb_model_builder的Build()代码,请提供一个解决方法。

lyvision001 avatar Jun 23 '25 02:06 lyvision001

使用的最新postgresql 17.5,测试支持select coun(1)

内容如下 Image

如下测试代码,可以正常返回

func TestDb(t *testing.T) {
	err := gdb.AddConfigNode("test", gdb.ConfigNode{
		Link: "pgsql:postgres:123456@tcp(127.0.0.1:5432)/postgres",
	})
	if err != nil {
		panic(err)
	}
	db := g.DB("test")
	count, err := db.Model("test").Count()
	fmt.Println(count, err)
}

辛苦提供报错可测试最小代码 以及 错误截图 @lyvision001

zcool321 avatar Jun 23 '25 07:06 zcool321

没复现出来,源码也没找到=len(newWhere)>0时,直接返回"1"。这个,有具体表结构和代码吗

LanceAdd avatar Jul 29 '25 04:07 LanceAdd