Skip to content

Commit 7d6e01d

Browse files
gaultierory-bot
authored andcommitted
chore: split SCIM from multi-region & make it work with SQLite
GitOrigin-RevId: b84b6a42442c818b805a2409746e03fd542c59ae
1 parent 7e33125 commit 7d6e01d

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

oryx/dbal/dsn.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,35 @@ func NewSharedUniqueInMemorySQLiteDatabase() (string, error) {
4747
return fmt.Sprintf("sqlite://file:%s/db.sqlite?_fk=true&mode=memory&cache=shared", dir), nil
4848
}
4949

50-
// NewSQLiteTestDatabase creates a new unique SQLite database
50+
// NewSQLiteTestDatabase creates a new in-memory, unique SQLite database
5151
// which is shared amongst all callers and identified by an individual file name.
5252
func NewSQLiteTestDatabase(t interface {
5353
TempDir() string
5454
}) string {
5555
return NewSQLiteInMemoryDatabase(t.TempDir())
5656
}
5757

58-
// NewSQLiteInMemoryDatabase creates a new unique SQLite database
58+
// NewSQLiteInMemoryDatabase creates a new in-memory, unique SQLite database
5959
// which is shared amongst all callers and identified by an individual file name.
6060
func NewSQLiteInMemoryDatabase(name string) string {
6161
return fmt.Sprintf("sqlite://file:%s?_fk=true&mode=memory&cache=shared", name)
6262
}
63+
64+
// NewSQLiteDatabase creates a new on-disk, unique SQLite database
65+
// which is shared amongst all callers and identified by an individual file name.
66+
// This is sometimes necessary over a in-memory database, for example when multiple tests/goroutines run in parallel
67+
// and access the same table.
68+
// This would result in a locking error from SQLite when running in-memory.
69+
// Additionally, shared cache mode is deprecated and discouraged, and the problem is better solved with the WAL,
70+
// according to official docs.
71+
func NewSQLiteDatabase(name string) string {
72+
return fmt.Sprintf("sqlite://file:%s/test.db?_fk=true&_journal=WAL", name)
73+
}
74+
75+
// NewSQLiteTestDatabaseOnDisk creates a new on-disk, unique SQLite database
76+
// which is shared amongst all callers and identified by an individual file name.
77+
func NewSQLiteTestDatabaseOnDisk(t interface {
78+
TempDir() string
79+
}) string {
80+
return NewSQLiteDatabase(t.TempDir())
81+
}

0 commit comments

Comments
 (0)