Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string “NULL” in Query will treated as nil in STD router StructReq #3465

Closed
3 of 4 tasks
ihipop opened this issue Apr 9, 2024 · 3 comments · Fixed by #3468
Closed
3 of 4 tasks

string “NULL” in Query will treated as nil in STD router StructReq #3465

ihipop opened this issue Apr 9, 2024 · 3 comments · Fixed by #3468
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@ihipop
Copy link

ihipop commented Apr 9, 2024

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

go version go1.22.0 linux/amd64

What version of GoFrame are you using?

v2.7.0

Can this bug be re-produced with the latest release?
YES

What did you do?

define a STD router REQ

type NULLStringReq struct {
	g.Meta    `path:"/test" method:"get"  summary:"STRING NULL TESTER"`
	ES []string `json:"es"  v:"required" `
}

test with this REQs

  • GET /test?es[]=NULL result in NULLStringReq.ES = []string{"NULL"}
  • GET /test?es=1 result in NULLStringReq.ES = []string{"1"}
  • GET /test?es=NULL result in NULLStringReq.ES = nil

What did you expect to see?

  • GET /test?es=NULL result in NULLStringReq.ES = []string{"NULL"}

just like GET /test?es=1 or like the raw method,which is correct

What did you see instead?

image

@ihipop ihipop added the bug It is confirmed a bug, but don't worry, we'll handle it. label Apr 9, 2024
@wln32
Copy link
Member

wln32 commented Apr 9, 2024

@gqcn 底层调用了gconv.Strings()方法,如果参数是string的话,会调用json.Valid方法,然后传的null值字符串,会返回一个nil

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@gqcn The bottom layer calls the gconv.Strings() method. If the parameter is a string, the json.Valid method will be called, and then the null value string passed will return a nil

@ihipop
Copy link
Author

ihipop commented Apr 9, 2024

if employees=NULL is not working
employees=1 should not work too
Personally, I think this is a BUG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
3 participants