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

Couldn't cast "time stamp with time zone" to "Date" #4196

Open
Anish9901 opened this issue Jan 28, 2025 · 1 comment
Open

Couldn't cast "time stamp with time zone" to "Date" #4196

Anish9901 opened this issue Jan 28, 2025 · 1 comment
Labels
ready Ready for implementation restricted: maintainers Only maintainers can resolve this issue type: bug work: backend Related to Python, Django, and simple SQL
Milestone

Comments

@Anish9901
Copy link
Member

To Reproduce

  • Create a table "t1"
  • Add a Date & Time column "dt"
  • Try casting "dt" to "Date"
  • Notice the following error

Image

Expected behavior

Casting to date from timestamp with time zone should be possible.

@Anish9901 Anish9901 added restricted: maintainers Only maintainers can resolve this issue work: backend Related to Python, Django, and simple SQL labels Jan 28, 2025
@seancolsen seancolsen added the ready Ready for implementation label Jan 28, 2025
@mathemancer
Copy link
Contributor

It's possible, but only if there would be no data loss. Our cast_to_... functions typically don't let users perform casts that would lose precision. If you cast 2025-01-01 00:00:00 +00 to a date, it will work.

We should not solve this problem ad-hoc (i.e., for this specific type or case), but rather as a broader reworking of our casting behavior. These functions are among the first we designed, and we had somewhat different goals for them. They're becoming less and less appropriate as our product goals evolve. We need to:

  • Determine precisely what casting behavior we want in Mathesar overall
    • Should we allow loss of precision?
    • Should we use the same behavior in PostgreSQL in all cases?
    • If not, when and why?
    • etc.
  • Come up with a plan to implement that behavior in a coherent way so that things feel consistent in the product, rather than piecemeal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Ready for implementation restricted: maintainers Only maintainers can resolve this issue type: bug work: backend Related to Python, Django, and simple SQL
Projects
None yet
Development

No branches or pull requests

5 participants