-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Question: how to properly set datestyle on pooled connections #1393
Comments
You can create a client type for use with the pool providing custom startup configuration: const pool = new pg.Pool({
Client: class extends pg.Client {
getStartupConf() {
return Object.assign(super.getStartupConf(), {
DateStyle: 'ISO,MDY',
});
}
},
⋮
}); It might be nice to have an option along these lines, though: class pool = new pg.Pool({
connectionOptions: {
DateStyle: 'ISO,MDY',
},
⋮
}); |
hm, i've solved it by doing pool.on "connect", (client) ->
client.query "SET DATESTYLE = iso, mdy" but your solution looks better :) |
I added this to the documentation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using the
pool.connect
&client.release
approach, I'm setting theset datestyle = iso mdy
as a first query to have my date-types parsed properly.However, how to do it with the
pool.query
call? Since the connection returned is random - and might be an existing one recently returned to the pool as well as a newly established one..Im not sure, if setting pg.types.setTypeParser for all the date/datetime/timestamp with/without timezone is a way I want to go..
Suggestions? :)
The text was updated successfully, but these errors were encountered: