-
Notifications
You must be signed in to change notification settings - Fork 280
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
R::keepInShape(true) deletes relations #4
Comments
fixed in commit ba6f898 can you confirm this works? here is the test case that demonstrates the problem and tests the fix: testpack("Optimizer and Garbage collector"); //Test description: test whether relation tables are spared during keepinshape (github issue #3) $db->exec("CREATE TABLE `deletethis` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,`col1` VARCHAR( 255 ) NOT NULL ,`col2` TEXT NOT NULL ,`col3` INT( 11 ) UNSIGNED NOT NULL ,PRIMARY KEY ( `id` ) ) ENGINE = MYISAM"); $db->exec("CREATE TABLE `deletethis2` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,`col1` VARCHAR( 255 ) NOT NULL ,`col2` TEXT NOT NULL ,`col3` INT( 11 ) UNSIGNED NOT NULL ,PRIMARY KEY ( `id` ) ) ENGINE = MYISAM"); $db->exec("INSERT INTO `redbeantables` (`id` ,`tablename`) VALUES (NULL , 'deletethis');"); $db->exec("INSERT INTO `redbeantables` (`id` ,`tablename`) VALUES (NULL , 'deletethis2');"); $db->exec("CREATE TABLE `deletethis_deletethis2` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,`col1` VARCHAR( 255 ) NOT NULL ,`col2` TEXT NOT NULL ,`col3` INT( 11 ) UNSIGNED NOT NULL ,PRIMARY KEY ( `id` ) ) ENGINE = MYISAM"); $db->exec("INSERT INTO `redbeantables` (`id` ,`tablename`) VALUES (NULL , 'deletethis_deletethis2');"); $db->exec("CREATE TABLE `deletethis_dontdeletethis` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,`col1` VARCHAR( 255 ) NOT NULL ,`col2` TEXT NOT NULL ,`col3` INT( 11 ) UNSIGNED NOT NULL ,PRIMARY KEY ( `id` ) ) ENGINE = MYISAM"); $db->exec("INSERT INTO `redbeantables` (`id` ,`tablename`) VALUES (NULL , 'deletethis_dontdeletethis');"); R::gen('dontdelete,dontdelete2'); $dontdelete = new dontdelete; $dontdelete->save(); asrt(intval($db->getCell("SELECT COUNT(*) FROM redbeantables WHERE tablename='dontdelete'")),1); asrt(intval($db->getCell("SELECT COUNT(*) FROM redbeantables WHERE tablename='deletethis'")),1); $dontdelete->add( new dontdelete2 ); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'deletethis'")),1); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'dontdelete'")),1); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'dontdelete2'")),1); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'dontdelete_dontdelete2'")),1); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'deletethis_dontdeletethis'")),1); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'deletethis_deletethis2'")),1); R::keepInShape( true ); asrt(intval($db->getCell("SELECT COUNT(*) FROM redbeantables WHERE tablename='dontdelete'")),1); asrt(intval($db->getCell("SELECT COUNT(*) FROM redbeantables WHERE tablename='deletethis'")),0); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'deletethis'")),0); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'dontdelete'")),1); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'dontdelete2'")),1); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'dontdelete_dontdelete2'")),1); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'deletethis_dontdeletethis'")),0); asrt(intval($db->getCell("SELECT count(*) FROM information_schema.tables WHERE table_schema = 'oodb' AND table_name = 'deletethis_deletethis2'")),0); |
fixed |
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems that in redbean 0.6 (downloaded on 23.09.2009 from github) keepInShape(true) deletes all relations between beans. The relation-tables are created as expected, but get deleted afterwards, although there are existing relations in them. Whilst in keepInShape(false) keeps them.
The text was updated successfully, but these errors were encountered: