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
Postgres does not support named timezones #4307
Comments
Do you have a Sequelize will set the timezone for the connection to utc by default |
I have that left as default, I don't see how that could be affecting this as the query that sequelize is executing is output in the console as "SELECT * FROM foo('2015-07-01','2015-07-31');" it seems that only affects results coming back from the DB. |
The query looks the same, but if the timezone for your pgadmin connection and the sequelize connection are not the same, the dates might be interpreted differently. Its hard to say anything definitive without knowing your schema and your stored procedure. Could you check what timezone your pgadmin connection is using |
It's using "US/Eastern" and my sequelize instance is using "+00:00" (utc) |
That could definitely cause some issues - Try either running |
I tried updating sequelize to use '+04:00' which didn't change anything. I then set that back to default (utc) and tried changing the database timezone to utc which also didn't change the results returned by sequelize. |
If "Executing (default): SELECT * FROM foo('2015-07-01','2015-07-31');" is output in the console, doesn't that mean that exact command is being sent to the DB? |
Sorry for being pedantic, but "us/eastern" is behind UTC ;) Yes, the exact same query is sent to the server, but how that is interpreted might be different, since Again, without knowing your schema, your data and your procedure its hard to say something thats not total guesswork. Yes, sequelize does not alter the query in any way, what you see in the console is whats sent to the server, and we don't filter the results after the come back from the DB ;) |
By the way, i meant, set time zone to UTC in pgadmin, then run the query again, in pgadmin |
i see, now we're getting somewhere, I'm able to replicate now in pgAdmin. I set time zone to utc in pgadmin and now when i execute the query I get back 87500 rows, the same as with sequelize. Seems like now that the DB is using the same timezone as sequelize, the results are the same. |
I tried to change the timezone option for sequelize to "US/Eastern" but am getting the following error: "Unhandled rejection error: invalid input syntax for type interval: "US/Eastern"" |
The documentation states I can use that string instead of an interval, "Will also accept string versions of timezones used by moment.js (e.g. 'America/Los_Angeles'); this is useful to capture daylight savings time changes." I also tried upgrading to the latest version from 2.1 to no avail. |
Yep, seems postgres does not handle named timezones. Should be as simple as checking |
Did someone solve this? I have the same problem, I save data with timezone +00:00. But I want to set time zone -03:00 before execute a query. I have tried with PgAdmin and it is working but I can't do it with sequelize. |
I'm using a raw sequelize query in node to execute a postgresql function which returns a query. The problem I'm having is that the result set obtained from running the query in pgAdmin does not match the result set returned in node when using the .query() method, even though the query in pgAdmin and the query in node are both exactly the same.
here's the query I'm performing:
SELECT * FROM foo('2015-07-01','2015-07-31');
This query returns 91875 rows in pgAdmin, however, in node using sequelize, running the following only returns 87500 rows:
models.sequelize.query("SELECT * FROM foo('2015-07-01','2015-07-31');")
.spread(function (results, metadata) {
console.log(results.length);
});
output: 87500
The rows which are excluded correspond to the last date 2015-07-31.
I found that I can obtain all the rows in node by increasing the 2nd date parameter to go beyond the end date. For example, if my goal is to get results which include 2015-07-31, setting the end date to be 2015-08-03 works. Although, this is masking the problem and not ideal.
I thought there must be something wrong with the WHERE clause in my stored procedure function. However, if that was the case, why do I get back the desired number of rows when I run the query though pgAdmin?
The text was updated successfully, but these errors were encountered: