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

Allow DateStyle to be "ISO, MDY", "ISO, DMY", or "ISO, YMD". #30

Closed
AMBIENTE1 opened this issue Oct 31, 2020 · 6 comments
Closed

Allow DateStyle to be "ISO, MDY", "ISO, DMY", or "ISO, YMD". #30

AMBIENTE1 opened this issue Oct 31, 2020 · 6 comments

Comments

@AMBIENTE1
Copy link

Hallo, I would like to change parameter datestyle from ISO, MDY to ISO, DMY in Parameter.swift
When I try:
let text = "SET DateStyle TO 'ISO, DMY';"
let cursor = try Database.connection().prepareStatement(text: text).execute()

error: Invalid value for Postgres parameter (response.name): ISO, DMY (must be ISO, MDY); closing connection

Please what is the best way to do this?

@pitfield
Copy link
Member

pitfield commented Nov 2, 2020

PostgresClientKit sets the Postgres DATESTYLE parameter to ISO, MDY and doesn't allow this value to be changed. This prevents misinterpretation of dates sent over the wire due to configuration mismatches.

If you want to control the format of dates in your user interface, you should use the PostgresDate type (or PostgresTimestampWithTimeZone for date/time values) and a DateFormatter (from the Foundation framework).

@AMBIENTE1
Copy link
Author

In my Postgres database are many funcs, where the date is set as string in format DD.MM.YYYY. ISO DMY is required. Would it be possible to set ISO DMY or MDY as a parameter please?

@pitfield
Copy link
Member

Could please try this commit (tip of the develop branch)? 40fe0ff

This should allow you to set the DATESTYLE paraameter to ISO, MDY, ISO, DMY, or ISO, YMD.

@AMBIENTE1
Copy link
Author

If i used playground, i couldn't use import PostgresClientKit :No such module 'PostgresClientKit'

But i modified the test and it worked properly.
Can you please add this modification to the release?

@pitfield pitfield changed the title change parameter Allow DateStyle to be "ISO, MDY", "ISO, DMY", or "ISO, YMD". Nov 13, 2020
@pitfield
Copy link
Member

Released in v1.3.1.

@AMBIENTE1
Copy link
Author

thank you so much

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

No branches or pull requests

2 participants