I'm currently making a NodeJS application and I'm using SQLite as the backend database. I've run into a problem when trying to soft-delete entries in a table. When I use the application to change the 'deleted' attribute, the changes appear in the SQLite CLI, but the application still displays each record as not deleted. These are the steps I use to test the application and database:
- In SQLite CLI, call the createDB.sql script to delete all tables and
set them up again.
- Call the populateDB.sql script to input test data into each of the tables
- Check in SQLite CLI that the records are correct (SELECT id, deleted FROM table1;)
- Check in application console that records are correct
- In the application, change deleted attribute for a single entry
- Output entry to console Console shows entry not deleted
- In the application, change deleted attribute for all entries
- Output entry to console Console shows entries not deleted
- Check in SQLite CLI that the records are correct Output shows deleted attribute has changed for all records
- Output to application console the deleted attribute Still shows all entries are not deleted
These are the steps I have take to try and resolve the issue:
- The data type for the deleted field is BOOLEAN. SQLite doesn't have a specific boolean type, but converts it to 1 or 0. I have tried using 1 and 0, 'true' and 'false' and even 'yes' or 'no' with no change in the behaviour.
- I have tried this using both relative and absolute file paths for the database.
- I added time delays to the application in case there is a delay updating the database.
- I looked into file locking and learned that SQLite prevents two processes accessing a file concurrently. Makes sense. I killed my CLI process and tried to update the deleted attribute from the application only, making sure it was the only thing connected to the database, but got the same result.
After all this testing I believe the application is writing to the actual database file, but is reading from a cache. Is this an accurate conclusion? If so, how do I tell the application to refresh it's cache after executing an update query?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…