-
Notifications
You must be signed in to change notification settings - Fork 16
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
function_clause error when querying if tstzrange contains timestamptz #36
Comments
Oh, I missed that you opened this. I don't think there is a fix here besides casting. Well, that isn't fair, the "fix" is that pgo needs to return a real error message. But I don't think it can infer the type. Let me figure out fixing error messages and we can see what it is actually getting wrong and if there might be a fix for this besides casting. |
Doesn't it work automatically in epgsql? |
Possibly but it might rely on the text protocol for that. With the binary protocol, which pgo uses, it needs to know the type upfront and it may not be able to figure it out without the cast. But I need to fix the error message to be sure. |
Yea, so I'm about to push an update to pgo that gives better errors and optional formated error messages. And for your original query I get:
So it expects a |
Hm, or is |
Looking at this again and based on my last comment I'm guessing I realized you were right and it should just be accepting what you pass :). It would mean updating https://github.com/tsloughter/pg_types/blob/master/src/pg_range.erl to accept a single term. |
Nevermind, I found the bug. The issue is I'm not sure the best way to get around this issue yet, but I found it knows it is needing to encode the value with It may have to be an ugly hack of matching I suppose the other option would be to not support turning Best solution would be to have a timestamp record or map, but that'd be as much of a pain. |
Requiring {{From, To}, {true, true}} instead of {From, To} might be fine. |
I'm still trying to figure out what it is Postgres expects for the encoding of this. Since there is no damn spec I'm trying to read the epgsql and postgrex code but it isn't yet clear what they do for a case like this -- trying to even find a test case in postgrex. |
This gives an error:
Casting to timestamptz works:
The text was updated successfully, but these errors were encountered: