Skip to content

Instance Method

serialize(to:)

Invoked when a request is made to serialize the expression to raw SQL.
func serialize(to serializer: inout SQLSerializer)

Parameters

serializer

The SQLSerializer to use.

Discussion

Implementations of this requirement should invoke various SQLSerializer methods as appropriate to convert its contents to raw SQL form, including inspecting dialect as needed.

Important

Because this method is not throwing, an expression which encounters a serialization failure has limited options to report it. Implementations are STRONGLY discouraged from triggering a runtime error (such as via fatalError()) or from using print() to inform the user; instead, the recommended behavior for such failures is:

  1. (Optional) Use the logger of the database to log an appropriate message at an appropriate severity level.

  2. Either output no content at all, or output deliberately syntactically invalid SQL to ensure an attempt to execute a query containing the failing expression will fail in turn.