Skip to content

Instance Property

version

The version number the database reports for itself.
var version: (any SQLDatabaseReportedVersion)? { get }

Discussion

The version must be provided via a type conforming to the SQLDatabaseReportedVersion protocol. If the version number is not applicable (such as for a connection pool dispatch wrapper) or not yet known, nil may be returned. Version numbers may also change at runtime (for example, if a connection is auto-reconnected after a remote update), or even become unknown again after being known.

Note

This version number has nothing to do with SQLKit or the driver implementation for the database, nor does it represent any data stored within the database; it is the version of the database to which the SQLDatabase object represents a connection (such as a MySQL server, or a linked libsqlite3 library). The primary motivation for finally adding this property stemmed from the desire to enable customizing SQLDialect configurations based on the actual feature set available at runtime, rather than the old solution of hardcoding a “safe” (but limited) baseline.

Default Implementations

SQLDatabase Implementations

  • version
    The version property was added to SQLDatabase multiple years after the protocol’s original definition; it was in fact the first change of any kind to the protocol since Fluent 4’s original release. Therefore it is necessary to provide a default value for the benefit of drivers which haven’t been updated, to avoid a source compatibility break. Conveniently, a nil version represents an obviously desirable default: “database version is unknown”.

See Also

Properties

  • logger
    The Logger used for logging all operations relating to a given database.
  • eventLoop
    The EventLoop used for asynchronous operations on a given database.
  • dialect
    The descriptor for the dialect of SQL supported by the given database.
  • queryLogLevel
    The logging level used for reporting queries run on the given database to the database’s logger. Defaults to .debug.