zonkyio / embedded-database-spring-test

A library for creating isolated embedded databases for Spring-powered integration tests.
Apache License 2.0
399 stars 37 forks source link

Setting timezone for embbeded postgresql #233

Open swapy opened 1 year ago

swapy commented 1 year ago

Hello,

Can we set default timezone for this embedded database? If yes, can you let me know how?

tomix26 commented 1 year ago

Hi @swapy, thanks for the question. You can set it using the following configuration property:

zonky.test.database.postgres.server.properties.timezone=GMT

The server properties correspond to the options in the postgresql.conf file. So you can change other settings as well.

swapy commented 1 year ago

Thank you very much @tomix26

I tried setting GMT as well as american time but it did not work

image

tomix26 commented 1 year ago

Yes, you're right, it doesn't work. Maybe it's because the server parameters are now passed as command-line parameters instead of editing the postgresql.conf file. But according to the documentation here, even the command-line parameters should work.

The TimeZone configuration parameter can be set in the file postgresql.conf, or in any of the other standard ways described in Chapter 19.

I'll have to investigate the problem more and I assume it will require some changes in the library. Note that even the ALTER SYSTEM SET timezone = 'America/Los_Angeles' sql command doesn't work for me, which is really weird.