-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix error with writing prices to database #87
Conversation
this should fix a bug with trying to write the same price into the table multiple times
@fhenneke Out of curiosity, i attempted to pull a "review" from ChatGPT for the Your function is mostly correct, but I see a few potential issues and areas for improvement: ✅ What’s Good?
|
I guess it is good to get such comments for double checking. The issues pointed out, though, are mostly incorrect.
|
Ok thanks for double-checking everything. It was mostly out of curiosity that i posted the above, as i wouldn't have come up with such comments myself. Things look good and since i want to get this out of the way, i am fine approving now |
This PR attempts to fix an issue with writing prices to the database. It might close #82.
Before, it could happen that the same price (i.e. the same token, time stamp, source) was inserted into the prices table. This failed due to violating the primary key constraint. This error (and potentially more?) was silenced in #84.
With this PR, the code first trys to update a value and then inserts it when the update did not succeed.
Alternatively, one could also first try to insert and update if that throws an error.
I added a test for writing a price twice. I was not able to reproduce the error by running the daemon, so that we might need to test some other way.