godot-sqlite icon indicating copy to clipboard operation
godot-sqlite copied to clipboard

open_db on corrupted file crases project

Open JonnyTech opened this issue 1 year ago • 0 comments

Environment:

  • OS: Debian and Windows
  • Godot version: 4.0.2
  • godot-sqlite version: 4.0

Issue description: Trying to open a corrupted / non-sqlite file crashes the project. Expecting to trap the error and handle it safely

Steps to reproduce: Create 3 buttons: create db, fill db, read db

func create_db():
	db.open_db()
	db.drop_table("table")
	db.create_table("table",{...table-data...})
	db.close_db()

func fill_db():
	db.open_db()
	db.insert_rows("table", row_array):
	db.close_db()

func read_db():
	db.open_db()
	#db.query()
	db.close_db()

Pressing the buttons in order (create, fill, read) works ok. Delete the database file test.db Press to fill the db >> an empty zero byte test.db file is created. Press to read the database, crash on db.open because test.db is not a valid db file

Additional context This is obviously a non-real-world example, but I have had an issue where the database file was unavailable and the fill/read process did happen and cause the result.

JonnyTech avatar May 05 '23 23:05 JonnyTech