-
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
The operation delete not working ($inp['__dbid'] order mismatch) #4
Comments
Thanks a lot for reporting this issue and providing such detailed information! I'll see if I can reproduce this, as soon as possible. - I think I'll be able to look into it by mid next week. |
Hi, sorry for the late reply. I ran a little test script and was able to reproduce your issue: $cdb->table('names')->create());
$cdb->table('names')->count());
$cdb->table('names')->insert(array("name" => "Name A"));
$cdb->table('names')->insert(array("name" => "Name B"));
$cdb->table('names')->insert(array("name" => "Name C"));
$cdb->table('names')->select(["name", "==", "Name A"])->delete();
$cdb->table('names')->select(["name", "==", "Name B"])->delete();
$cdb->table('names')->select(["name", "==", "Name C"])->delete();
// Database should be empty but contains "C"
$cdb->table('names')->select('*')->fetch();
$cdb->table('names')->count());
$cdb->table('names')->drop(); Thank you for providing a fitting solution. Although I don't think re-aligning the table twice is necessary. The bug is only caused by shifts from previous deletes, so using // working delete();
foreach($this->data as $d) {
unset($this->base->tbdata['data'][$d['__dbid']]);
}
$this->base->tbdata['data'] = array_values($this->base->tbdata['data']);
$this->base->_saveData();
return true; In Conclusion, if you want, you can file a PR to have these changes merged into the library under your name. Otherwise, I'll just commit them manually and reference this issue :) For reference: $aligned_table = array("data" => array_values($this->tbdata["data"]));
file_put_contents($this->tbpath, json_encode($aligned_table)); |
Hi Sven, thanks for getting into this and also for keeping this nice project (still a unique project in this category json database system) Although I've been using github for years yet to do a PR next time i'll do |
I experienced an issue after deleting a few records, inserting a few and again tried to delete
nothing happened...
inspected through the code
The delete operation is based on ['__dbid'] which is based on $counter created in tweak function
So I temporarily reordered using array_values in delete function (like below)
kindly look through this when you go through crunchdb
The text was updated successfully, but these errors were encountered: