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

ExplainSQL does not show the correct time zone for time parameters #5248

Closed
jsgoupil opened this issue Apr 11, 2022 · 3 comments
Closed

ExplainSQL does not show the correct time zone for time parameters #5248

jsgoupil opened this issue Apr 11, 2022 · 3 comments
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@jsgoupil
Copy link

GORM Playground Link

go-gorm/playground#465
jsgoupil@95f5807

Description

The ExplainSQL does not display the time zone when displaying a time. The following times,

now := time.Now()
nowInPST := now.In(pst)
nowInEST := now.In(est)

are all equivalent. However, when you display the SQL, they will appear to be different.
What is saved in the database is correct; it's only what is in the ExplainSQL that doesn't work.

I added 2 time zones because one can pass if your computer is in that time zone.
I am in PST, so it works, but it will fail with the EST.

sql_test.go:118: Explain SQL #8 expects
create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu?", 1, 999.990000, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\"com", "admin", "pass"),
but got
create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu?", 1, 999.990000, true, "12345", "2020-02-23 14:10:10", "2020-02-23 11:10:10", NULL, "w@g.\"com", "admin", "pass")
@github-actions github-actions bot added the type:with reproduction steps with reproduction steps label Apr 11, 2022
@holicc
Copy link

holicc commented Jun 8, 2022

you mean like this ?

create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass) values ("jinzhu?", 1, 999.990000, true, "12345", "2020-02-22 19:10:10 PST", "2020-02-23 11:10:10 CST", NULL, "w@g."com", "admin", "pass")

@jsgoupil
Copy link
Author

jsgoupil commented Jun 8, 2022

I would prefer the offset rather than time zone abbreviation, since it can be different based on the real "time zone" and the DST.

@a631807682
Copy link
Member

Maybe we need to add config to ExplainSQL/Explain to support hidden sql vars or define time output format, but this is a breaking change.

related to #5287

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:with reproduction steps with reproduction steps
Projects
None yet
Development

No branches or pull requests

4 participants