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

How can EXTRACT be used with this library? #236

Open
guaraqe opened this issue May 12, 2023 · 1 comment
Open

How can EXTRACT be used with this library? #236

guaraqe opened this issue May 12, 2023 · 1 comment

Comments

@guaraqe
Copy link

guaraqe commented May 12, 2023

The EXTRACT function has a weird syntax, for example:

EXTRACT(EPOCH FROM now())

I tried using function to write it, but it ends up with CASTs in places that create syntax errors, namely around EPOCH FROM:

CAST(EXTRACT(CAST(EPOCH FROM(CAST(now() AS timestamptz))))))

Is there any way to use a DBType that has no casts around it, or some other technique to make it work? The syntax is similar to CAST, but I see no definition of it in the library. I cannot see neither how to use unsafeLiteral to write it.

@guaraqe guaraqe closed this as completed May 12, 2023
@guaraqe guaraqe reopened this May 12, 2023
@guaraqe
Copy link
Author

guaraqe commented May 12, 2023

The problem is the casting around each one of the parameters. If there was a way to avoid it, it would be possible to apply the strategy here: tomjaguarpaw/haskell-opaleye#291

If there is interest, I can add a function that does it, maybe just for EXTRACT.

guaraqe added a commit to guaraqe/rel8 that referenced this issue May 12, 2023
This adds unsafe EXTRACT function to Rel8.Expr.Time, using the low-level
Opaleye functions. Should solve circuithub#236.
guaraqe added a commit to guaraqe/rel8 that referenced this issue Dec 10, 2024
This adds unsafe EXTRACT function to Rel8.Expr.Time, using the low-level
Opaleye functions. Should solve circuithub#236.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant