Skip to content

Protocol

SQLDialect

An abstract definition of a specific dialect of SQL.
protocol SQLDialect : Sendable

Overview

SQLKit uses the dialect provided by an instance of SQLDatabase to control various aspects of query serialization, with the intent of keeping SQLKit’s user-facing API from having to expose database-specific details as much as possible. While SQL dialects in the wild vary too widely in practice for this to ever be 100% effective, they also have enough in common to avoid having to rewrite every line of serialization logic for each database driver.

Topics

Basics

  • name
    The name of the dialect.
  • identifierQuote
    An expression (usually an SQLRaw) giving the character(s) used to quote SQL identifiers, such as table and column names.
  • literalStringQuote
    An expression (usually an SQLRaw) giving the character(s) used to quote literal string values which appear in a query, such as enumerator names.
  • bindPlaceholder(at:)
    A function which returns an expression to be used as the placeholder for the positionth bound parameter in a query.
  • literalBoolean(_:)
    A function which returns an SQL expression (usually an SQLRaw) representing the given literal boolean value.
  • literalDefault
    An expression (usually an SQLRaw) giving the syntax used to express both “use this as the default value” in a column definition and “use the default value for this column” in a value list.

Support Flags

Syntax Indicators

Modifier Methods

  • customDataType(for:)
    A function which is consulted whenever an SQLDataType will be serialized into a query. The dialect may return an expression which will replace the default serialization of the given type. Returning nil causes the default to be used.
  • normalizeSQLConstraint(identifier:)
    A function which is consulted whenever a constraint name will be serialized into a query. The dialect must return an expression for an identifer which is unique to the input identifier and is a valid constraint name for the dialect.
  • nestedSubpathExpression(in:for:)
    Given a column name and a path consisting of one or more elements, return an expression appropriate for accessing a value at the given JSON path.

Relationships

Inherits From

  • Swift.Sendable
  • Swift.SendableMetatype

See Also

Drivers

  • SQLDatabaseReportedVersion
    Provides a protocol for reporting and comparing database version numbers.
  • SQLAlterTableSyntax
    Encapsulates a dialect’s support for ALTER TABLE syntax.
  • SQLTriggerSyntax
    Encapsulates a dialect’s support for CREATE TRIGGER and DROP TRIGGER syntax.
  • SQLUnionFeatures
    A set of feature support flags for UNION queries.
  • SQLEnumSyntax
    Possible values for a dialect’s strongly-typed enumeration support.
  • SQLUpsertSyntax
    The supported syntax variants which a SQL dialect can use to to specify conflict resolution clauses.