-
Notifications
You must be signed in to change notification settings - Fork 11
Add support for bulk update in ll_bitemporal_update_select functions.
#8
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
base: master
Are you sure you want to change the base?
Conversation
3ecf349 to
808683f
Compare
Use the FROM clause in the UPDATE statement to support bulk data update.
808683f to
7e9089f
Compare
|
Hi @raghavio - actually, you can do pretty much the same without modifying the function. It's my fault that I never formalized and documented this feature, but the reason why I added the alias t to the update has exactly that! See here: That's how I used it: As you can see, "t" always denotes the table we are updating, and then you can reference its attributes in the select statement. I think that this covers at least part of the functionality you are looking for. |
|
Hi @hettie-d, thanks for the quick look. Hope you had fun at the PG Conf! I'm actually aware of this but this isn't what I need. My change allows updation of multiple records with data that's outside of the table that's being updated. Right now, if the query in
It doesn't allow updating of multiple records with different data coming from the SELECT query. That's what I need. Pasting my function call from #7: If you see, my SELECT query here returns two records. This currently gives me an error saying the subquery returns more the one record. |
|
Got it! Thank you for the clarification! |
|
Hi @raghavio - my sincere apologies it took so long to get to you. Everything looks great except for one issue. When you construct the update statement, it is assumed that the names of the columns in the "update select" statement are the same as those we are updating. In your example, you explicitly use "AS" to name them the right way, which is perfectly fine when you know that you need to do this. However, if somebody is already using this function in production (like one of my former companies) and is unaware of this new requirement, their code will break. I think that your contribution is very valuable for pg_bitemporal, but it's critical to ensure backward compatibility when I am advocating for broader adoption of this framework.
Do you think this is doable? Please let me know! Thanks:) |
|
Hi @hettie-d. Sorry for the late reply. I'll get to this. |
|
Yes, you are right, and I have been thinking about this problem for a long time. I am not sure how to handle that yet, partially because time is in some sense "invisible" for the application (we do all the hard work :)), and if we allow effective/asserted time to vary within one operation, we need to allow injecting some dependencies of effective time on the values which we pass. So I do not have a solution yet, but I am happy to work on it, I know it is needed. For a start, can you give me an example of how the kind of update you are looking for? And BTW - feel free to send me a message on LinkedIn, this may result in a long conversation :) |
Use the FROM clause in the UPDATE statement to support bulk data update.
Fixes #7