Skip to content

Lose TZ in timestamptz #264

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

Closed
YurovRuslan opened this issue Jul 18, 2018 · 2 comments
Closed

Lose TZ in timestamptz #264

YurovRuslan opened this issue Jul 18, 2018 · 2 comments

Comments

@YurovRuslan
Copy link

YurovRuslan commented Jul 18, 2018

I have a table which creates like:

create_table = [sql|
CREATE TABLE IF NOT EXISTS sometable
    ( ...
    , time TIMESTAMP WITH TIME ZONE NOT NULL
    ...
    );
|]

Then I create someschema from sometable. Field time goes via psql functions: tstzrange, MAX and time_bucket(tsdb)

Then I have a query to this table:

data <- query conn Sql.selectFromSomeSchema (timeZoneName $ zonedTimeZone from, ...)

Sql query looks like:

selectFromSomeSchema = [sql|
SELECT          
    timezone(?, LOWER(range))
    , timezone(?, UPPER(range))
    , CAST(EXTRACT(EPOCH FROM (UPPER(range) - LOWER(range))) AS INTEGER) FROM someschema
WHERE
    ...
|]

And I have an error:

"Incompatible {errSQLType = \"timestamp\", errSQLTableOid = Nothing, errSQLField = \"timezone\", errHaskellType = \"ZonedTime\", errMessage = \"\"}"
@lpsmith
Copy link
Owner

lpsmith commented Aug 13, 2018

Timestamptz does not store the timezone on a per-value or per-column basis. You should read the documentation I wrote in the Time module.

@lpsmith lpsmith closed this as completed Aug 13, 2018
@lpsmith
Copy link
Owner

lpsmith commented Aug 13, 2018

Also, you might be interested in reading the discussion of issue #69.

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

No branches or pull requests

2 participants