-
-
Notifications
You must be signed in to change notification settings - Fork 332
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
Cast to date fails if date is in DD-MM-YY format #3953
Comments
@Anish9901 is this a regression? |
No @kgodey, this is not a regression, we can set different datestyles on postgres at runtime but there is no way to do it via the UI at the moment. |
@Anish9901 if a text column contained one cell with the string "01/02/03", how would you expect Mathesar to cast it? Would it become January 2nd or February 1st? Or would the user (or potentially Mathesar administrator) be granted some control over this behavior? While much of the world might expect the date to be in February, US users would likely expect it to be January. |
@seancolsen Ideally, I'd like the date format to be inferred based on the browser locale. However, I can see where that could be a problem. A better solution might be to allow specifying the date format during the casting process, similar to how we allow users to choose between different date formats once the date column is already created. Nonetheless, I think we'll need a team-wide discussion to get to a best possible solution for this problem hence the label |
First, I don't think this should be in the beta milestone. We're likely to lose functionality if we're not careful about modifying this behavior, since the Postgres date casting behavior is pretty much as good as possible, subject to the issue that @seancolsen raised w.r.t. locale differences. For example, the following are all correctly handled:
I could go on, but I assume the point is made. We are simply not going to do better than that with home-rolled logic. Moreover, I don't think it makes any sense to give up that power or flexibility by making the user choose a format that has to apply to an entire column (which could be from an inconsistent source), and certainly not with a picker that's likely to lack many (or most) of the options available out-of-the-box in Postgres. With all that said, the problem is real. I suggest a dropdown that simply allows the user to choose the DateStyle parameter if desired (with some helpful hints). See the docs for what that would look like. The short version is that the parameter lets you specify how Postgres should choose between indeterminate options for, e.g., It's possible to make this setting on a per-session or per-transaction basis. I suggest per-transaction, with the setting submitted as an optional parameter when calling the cast function. We shouldn't change the response format, since that's already handled properly. |
Description
Expected behavior
Casting shouldn't fail
To Reproduce
Text
column named "Date"22/06/24
as a record in the date column.DATE
type.See also
The text was updated successfully, but these errors were encountered: