-
Notifications
You must be signed in to change notification settings - Fork 286
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
Multiple updates in one query -> not working "operator does not exist: integer = text" #539
Comments
Edit casting to ::int works, maybe you should update your example ? |
Running into this as well. |
same issue here. @alexisvisco where should i make the ::int cast? |
In my case update_data.id::int |
Yeah casting has been working fine, but it has been a real pain. I think this really is a library issue though. Anytime you do In other contexts the appropriate types are sent over for integers, floats, dates, etc, why does that not occur when using the helper in a values list context? [1] https://www.postgresql.org/docs/14/typeconv-union-case.html |
There's actually a PR to remove that from regular parameters as well #392 . This library aims to be as close to PostgreSQL as possible (this is not an ORM)™️. Now there are plenty of ways to solve the issues faced here, but I'm not at my computer these days, so unless someone else pitches in before I'm back, I'll be sure to get back then 😊 |
Okay I will take the convo over there. The crux of this problem then becomes: we just need an interface to cast INSIDE of the values list, next to each literal. Right now it is agonizing to cast in sub-query select lists, join conditions, return lists, etc. I've had to perform a lot of gymnastics to get bulk inserts with joins to work. |
Yeah, if you have any opinions related to that PR, sure, but try to keep in mind we're trying to stay as close to the DB as possible to let it do the inference it does directly because it's better at casting according to its types than any js layer, and also to avoid another abstraction. If you don't mind, I'd like to see actual code of what you're trying to do to get a better understanding. |
Upon more thought I think I see what you mean: once you remove any implicit casting the library does, postgres' type inference should be just fine. It's just problematic right now because the library is casting to But here's a bulk insert example that should have been simple but got really verbose. I'm inserting from a select statement that is mostly comprised of a values list, but does also have one join. I had to wrap the values list in its own sub-query so I could have the chance to cast every column. Without that, postgres complained that a bunch of the types were
|
I think this could possibly also be causing a problem when issuing an update that contains jsonb columns with array values. For example, an update |
Lead to :
I don't really understand, I just grab the example from the readme, I am doing something wrong ?
The query works well in postgres even with parameterized parameter.
Edit:
Doing
Seems to unlock the situation so the problem must be on your side sinde postgres can handle the query with the
update_data.id
Edit:
I don't see any tests for this feature
Multiple updates in one query
The text was updated successfully, but these errors were encountered: