gf icon indicating copy to clipboard operation
gf copied to clipboard

GF2.1.0 From子查询 SHOW FULL COLUMNS FROM “ ”

Open glennliao opened this issue 2 years ago • 4 comments

1. What version of Go and system type/arch are you using?

go 1.18 win/amd64

2. What version of GoFrame are you using?

2.1.0

3. Can this issue be re-produced with the latest release?

yes

4. What did you do?

image

just like the doc -> https://goframe.org/pages/viewpage.action?pageId=7302091

image

5. What did you expect to see?

6. What did you see instead?

image

实际上sql还是正常执行了,

glennliao avatar Jul 04 '22 11:07 glennliao

已复现,现象是否为报错但不中断流程?SQL正常执行,未返回error?

mingzaily avatar Jul 06 '22 02:07 mingzaily

@mingzaily 是的。

glennliao avatar Jul 06 '22 03:07 glennliao

@mingzaily ~刚又试了下, 现在又可以了。~(我本地改动过gf代码,把原本的报错屏蔽了) 。 然后新增了下字段,出现问题。 问题依旧是报错 + 不中断 + sql正常 + 未返回err


func TestName(t *testing.T) {

	type User struct {
		Id       string
		Username string
	}

	var users []User

	subSelect := g.DB().Model("sys_user").Fields("id", "username")

	err := g.DB().Model("? as u", subSelect).
		Where("id <", 18).
		Scan(&users)

	if err != nil {
		panic(err)
	}

	g.Dump(users)

}

image

glennliao avatar Jul 06 '22 04:07 glennliao

It's running well when I'm using With of Model struct method expression. this issue has been existing in the early GF version.

err := g.DB().Model("? as u", subSelect).With(User{})
		Where("id <", 18).
		Scan(&users)

melsendev avatar Jul 07 '22 02:07 melsendev

package demo

import (
	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
	"github.com/gogf/gf/v2/frame/g"
	"testing"
)

type User struct {
	Username string
}

func TestName(t *testing.T) {
	db := g.DB()
	var users []User
	db.Model("? as u",
		db.Model("sys_user").Fields("username"),
	).Where("username", "admin").Scan(&users)
}

=出现以下问题=

image image

glennliao avatar Oct 08 '22 03:10 glennliao

https://github.com/gogf/gf/pull/2177

gqcn avatar Oct 08 '22 11:10 gqcn