Enumeration
SQLConflictAction
INSERT query encounters a unique constraint violation.enum SQLConflictAction
Overview
Note
This is one of the only types at this layer which is not an SQLExpression. This is down to the unfortunate fact that while PostgreSQL and SQLite both support the standard’s straightforward ON CONFLICT DO NOTHING syntax which goes in the same place in the query as an update action would, MySQL can only express the SQLConflictAction.noAction case with INSERT IGNORE. This requires considering the conflict action twice in the same query when serializing, and to decide what to emit in either location based on both the specific action and the dialect’s supported sybtax. As a result, the logic for this has to live in SQLInsert, and it is not possible to serialize a conflict action to SQL in isolation (but again, only because MySQL couldn’t be bothered), and this enum can not conform to SQLExpression.
Topics
Enumeration Cases
case noActionSpecifies that conflicts this action is applied to should be ignored, allowing the query to complete successfully without inserting any new rows or changing any existing rows.case update(assignments: [any SQLExpression], predicate: (any SQLExpression)?)Specifies that conflicts this action is applied to shall cause theINSERTto be converted to anUPDATEon the same schema which performs the column updates specified by the associated column assignments and, where supported by the database, constrained by the associated predicate. The column assignments may includeSQLExcludedColumnexpressions to refer to values which would have been inserted into the row if the conflict had not taken place.
Relationships
Conforms To
Swift.SendableSwift.SendableMetatype
See Also
Clause Expressions
struct SQLAlterColumnDefinitionTypeA clause specifying a new data type to be applied to an existing column.struct SQLColumnAssignmentEncapsulates acolumn_name=valueexpression in the context of anUPDATEquery’s value assignment list. This is distinct from anSQLBinaryExpressionusing the.equaloperator in that the left side must be an unqualified column name, the operator must be=, and the right side may useSQLExcludedColumnwhen the assignment appears in theassignmentslist of aSQLConflictAction.update(assignments:predicate:)specification.enum SQLColumnConstraintAlgorithmColumn-level data constraints.struct SQLColumnDefinitionA clause expressing a column definition, for use when creating and altering tables.struct SQLCommonTableExpressionA clause describing a single Common Table Expressions, which in itws simplest form provides additional data to a primary query in the same way as joining to a subquery.struct SQLCommonTableExpressionGroupA clause representing a group of one or moreSQLCommonTableExpressions.struct SQLConflictResolutionStrategySpecifies a conflict resolution strategy and associated conditions for anINSERTquery. AnINSERTwith a conflict strategy is often refered to as anUPSERT(“insert or update”). Databases are not required to support any given subset of upsert functionality, or any at all.enum SQLDropBehaviorSpecifies a behavior when performing aDROPoperation on a database object which is referenced by other objects.struct SQLEnumDataTypeRepresents a data type which specifies an enumeration in the database.struct SQLExcludedColumnAn expression appearing on the right side of a column assignment which, when the assignment list is part of an upsert’s update acion, refers to the value which was originally to be inserted for the given column.struct SQLForeignKeyA completeFOREIGN KEYconstraint specification.struct SQLInsertModifierSimple helper for working around MySQL’s refusal to implement standard SQL. Only emits SQL when needed.struct SQLJoinEncapsulates a single SQLJOIN, specifying the join type, the right-side table, and condition.enum SQLJoinMethodThe method used by a table join clause.enum SQLLockingClauseAn SQL locking clause.