SqliteConnectOptions::filename() memory fix (#3136) (#3137)

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

* Expose in_memory sqlite option

* Docs SqliteConnectOptions::filename include mention of from_str alternative

* Docs SqliteConnectOptions::filename typo fix
This commit is contained in:
Liam Gray 2024-05-31 20:45:27 +01:00 committed by GitHub
parent c57b46ceb6
commit 2df770a10b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
@ -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.