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

The parsed default timezone of timestamp fields must be "UTC" not "" #3464

Open
1AbdulKareem opened this issue Jun 25, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@1AbdulKareem
Copy link

Version

1.26.0

What happened?

I will try to show the bug (I can't say it's a bug , as it can fixed by just adjusting the label of the location object used) as brief as possible .

this test code

arg.SnapDate = util.RandomDate().Round(time.Second).UTC()
require.Equal(t, arg.SnapDate, snapshot.SnapDate) 

arg.SnapDate is generated randomly , it's referred to be the actual value
snapshot.SnapDate is marshaled by SQLC compiler .

will result the following error

Error: ```
Not equal:
expected: time.Date(2028, time.February, 25, 0, 0, 0, 0, time.Location(""))
actual : time.Date(2028, time.February, 25, 0, 0, 0, 0, time.Location(""))

    	            	Diff:
    	            	--- Expected
    	            	+++ Actual
    	            	@@ -1,2 +1,2 @@
    	            	-(time.Time) 2028-02-25 00:00:00 +0000 UTC
    	            	+(time.Time) 2028-02-25 00:00:00 +0000 +0000

I inspected the go time.Location object of both fields and found the following: 

SQLC parsed the timestamp with `time.FixedZone("", 0)` i guess without a name which golang interprets it's name as "" and actually it's "UTC" .

Now I have to do something like : 
loc := time.FixedZone("", 0)
res := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, loc).Round(time.Second)

each time I deal with timestamps . 

Kindly tell me where exactly in SQLC source code . I can replace that FixedZone location with UTC location instead . so it makes my code more cleaner . 






### Relevant log output

_No response_

### Database schema

_No response_

### SQL queries

_No response_

### Configuration

_No response_

### Playground URL

_No response_

### What operating system are you using?

_No response_

### What database engines are you using?

_No response_

### What type of code are you generating?

_No response_
@1AbdulKareem 1AbdulKareem added bug Something isn't working triage New issues that hasn't been reviewed labels Jun 25, 2024
@kyleconroy kyleconroy removed the triage New issues that hasn't been reviewed label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants