Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Problem with db.query and reactive update #21

Open
ederluca opened this issue Feb 13, 2020 · 4 comments
Open

Problem with db.query and reactive update #21

ederluca opened this issue Feb 13, 2020 · 4 comments

Comments

@ederluca
Copy link

I was observing a problem in updating the data using reactive, when you for example execute the command db.query () and for example execute an update I realized that the stream process is not updated, however if I use db.update the update occurs I do not know if it would be a bug or if this is really the behavior.

@synw
Copy link
Owner

synw commented Feb 13, 2020

Right. The thing is that query is just a string, and the function is not aware of what kind of operation it is, neither or the table and the data impacted. Therefore we can not provide the changefeed with the proper information and update the select bloc. Updating the bloc on each call to query would not be efficient. We could parse the query to check if some keywords are present like update and deduce the nature of the operation, but I am not sure that it would be reliable.

Do you have any solution or propositions about that in mind? What do you think?

@synw
Copy link
Owner

synw commented Feb 14, 2020

Thinking about it parsing the first word of the query to detect mutations (insert, update, delete) should be enough to inform the changefeed, at least for most common cases. The select bloc only needs to know that a mutation occurred in the table that it is watching to trigger a refresh and re-run the query.

We can try that to improve the behavior of query but there might be some edge cases from custom sql. If anyone wants to give it a shot prs are welcome

@ederluca
Copy link
Author

Good afternoon

I agree if treating the words insert into, update, delete you will already have a satisfactory result I believe, because there are developers who like to put the full sql command I believe that adding this functionality for future versions would be a great gain.

@synw
Copy link
Owner

synw commented Feb 15, 2020

Ok so we agree on a plan. I'm a bit busy these days, if someone wants to try an implementation it would speed up the progress on this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants