Closed toffee-makes-things closed 2 years ago
Ok uhh i just found a really big issue. Outside of the Image type if you delete a Restaurant its not completely dropped in SQL (items included) @spotlightishere @SketchMaster2001
There are no exceptions or anything. It just does not drop the records in the DB
Ok uhh i just found a really big issue. Outside of the Image type if you delete a Restaurant its not completely dropped in SQL (items included) @spotlightishere @SketchMaster2001
Ok i was slightly wrong about this, its off of the database but its still counting upwards from ID 1 even though ID 1 was removed
Wait is this actually intended behavior 🤔 Im slightly confused
Auto-increment for primary columns is expected behavior - this lets the database manage identification without making us need to attempt for uniqueness, and allow indexing to occur :) It won't revert back to a primary value upon deletion of previous rows without manually modifying its value.
You can verify that this is present by looking at the default value for item_code
, for example via \d item_list
in psql
:
This corresponds to the default behavior of SQLAlchemy, creating an auto-incrementing/sequenced key for the primary integer column: https://github.com/WiiLink24/food-server/blob/39350da181d7f54120ac3c76ec9ab8f28a0a3b59/models.py#L78-L79
If items or menus related to the deleted restaurant persist, that is an issue. (However, this should not occur, as we specify a foreign key of shop_code
for menus, and menu_code
for items. If it does permit deletion, that's also a big issue!)
Ah ok I get it now! Thanks for explaining! @spotlightishere
So basically if you have a Item/Restaurant that has Issue you get a item that cant be fully deleted from the admin panel.
For example if you upload a .JPG as a Restaurant image it kinda creates but if you delete it the ID continues to be referenced. (depending on the condition after you delete Restaurant ID 1 it stops showing on the admin panel, but ID 1 is still in the database. so the next Restaurant has a ID of 2 even though ID 1 should be gone)
kinda related to #8