codeforkjeff / dbt-sqlite

A SQLite adapter plugin for dbt (data build tool)
Apache License 2.0
76 stars 12 forks source link

check if schema exists before calling DETACH DATABASE #15

Closed codeforkjeff closed 2 years ago

codeforkjeff commented 2 years ago

sqlite doesn't support IF EXISTS for DETACH DATABASE so we check manually. Note that we have to commit before detaching, otherwise sqlite will raise a 'database is locked' error.

This issue was exposed when changing the test suite to use the new framework for dbt-core 1.1.0. The old test suite for 1.0.x isn't raising any errors, but fixing this anyway. It's not clear to me that this ever comes up in real world use cases.