diff --git a/GRDB/Core/DatabaseQueue.swift b/GRDB/Core/DatabaseQueue.swift index 79252cb25..13ecfb6e9 100644 --- a/GRDB/Core/DatabaseQueue.swift +++ b/GRDB/Core/DatabaseQueue.swift @@ -16,9 +16,6 @@ public final class DatabaseQueue { writer.configuration } - /// The path to the database file. - /// - /// The path is `:memory:` for in-memory databases. public var path: String { writer.path } diff --git a/GRDB/Core/DatabaseReader.swift b/GRDB/Core/DatabaseReader.swift index 2ac917d1f..ae947cae4 100644 --- a/GRDB/Core/DatabaseReader.swift +++ b/GRDB/Core/DatabaseReader.swift @@ -17,6 +17,7 @@ import Dispatch /// ### Database Information /// /// - ``configuration`` +/// - ``path`` /// /// ### Reading from the Database /// @@ -46,6 +47,12 @@ public protocol DatabaseReader: AnyObject, Sendable { /// The database configuration. var configuration: Configuration { get } + /// The path to the database file. + /// + /// In-memory databases also have a path: + /// see [In-Memory Databases](https://www.sqlite.org/inmemorydb.html). + var path: String { get } + /// Closes the database connection. /// /// - note: You do not have to call this method, and you should not call @@ -644,6 +651,10 @@ extension AnyDatabaseReader: DatabaseReader { base.configuration } + public var path: String { + base.path + } + public func close() throws { try base.close() } diff --git a/GRDB/Core/DatabaseWriter.swift b/GRDB/Core/DatabaseWriter.swift index 7d9480e11..939092e37 100644 --- a/GRDB/Core/DatabaseWriter.swift +++ b/GRDB/Core/DatabaseWriter.swift @@ -964,6 +964,10 @@ extension AnyDatabaseWriter: DatabaseReader { base.configuration } + public var path: String { + base.path + } + public func close() throws { try base.close() }