Skip to content

Commit

Permalink
SqliteConnectOptions::filename() memory fix (launchbadge#3136) (launc…
Browse files Browse the repository at this point in the history
…hbadge#3137)

* SqliteConnectOptions::filename() memory fix (launchbadge#3136)

* Expose in_memory sqlite option

* Docs SqliteConnectOptions::filename include mention of from_str alternative

* Docs SqliteConnectOptions::filename typo fix
  • Loading branch information
hoxxep authored and jayy-lmao committed Jun 6, 2024
1 parent 98b9948 commit b20a657
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sqlx-sqlite/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ impl SqliteConnectOptions {
}

/// Sets the name of the database file.
///
/// This is a low-level API, and SQLx will apply no special treatment for `":memory:"` as an
/// in-memory database using this method. Using [SqliteConnectOptions::from_str] may be
/// preferred for simple use cases.
pub fn filename(mut self, filename: impl AsRef<Path>) -> Self {
self.filename = Cow::Owned(filename.as_ref().to_owned());
self
Expand All @@ -228,6 +232,14 @@ impl SqliteConnectOptions {
self.pragma("foreign_keys", if on { "ON" } else { "OFF" })
}

/// Set the [`SQLITE_OPEN_MEMORY` flag](https://sqlite.org/c3ref/open.html).
///
/// By default, this is disabled.
pub fn in_memory(mut self, in_memory: bool) -> Self {
self.in_memory = in_memory;
self
}

/// Set the [`SQLITE_OPEN_SHAREDCACHE` flag](https://sqlite.org/sharedcache.html).
///
/// By default, this is disabled.
Expand Down

0 comments on commit b20a657

Please sign in to comment.