r/coolgithubprojects • • 1d ago

The note I'd keep after fixing SQLite's `no such table` error

Post image

In a small SQLite reproduction, the setup connection creates an empty jobs table. The worker opens a second connection to count rows. The expected result is 0; instead, it gets no such table: jobs.

The setup connection can still query the table. Both connections use :memory:, which makes the mismatch easy to overlook. Each plain :memory: connection gets its own database.

Opening the same fresh temporary DB file on both connections, with setup committed before the worker queries, makes SELECT COUNT(*) FROM jobs return 0 on both. The file belongs to that test run so another run can start with an empty database.

The fixture comment needs to say why this test uses a file. The same detail is worth keeping in MemoraX Code's Coding Memory.

Setup and worker open separate connections. Give them the same fresh temporary DB file and commit setup before the worker queries. With no rows inserted, SELECT COUNT(*) FROM jobs must return 0 from either connection. Use a separate file for each test.

The connection detail matters more to me than the phrase "use a temp file." Before changing this fixture, I'd check whether setup and worker still open separate connections.

1 Upvotes

2 comments sorted by

1

u/Super-Insurance-2211 21h ago

Would you include the test path or command in that note so the next session can rerun it?

1

u/PhroznGaming 1d ago

What the fuck are you saying