Class MySqlDialect
MySQL's SQL flavour: snake_case naming, identifiers, backtickLIMIT/OFFSET, row-wise tuple
comparisons, and AUTO_INCREMENT keys — which MySQL cannot read back from an insert (no
RETURNING), so generated-key backfill is rejected with guidance: declare a client-generated key.
Collection columns do not exist; collection clauses degrade to the gated client-side residual.
public class MySqlDialect : SqlDialect
- Inheritance
-
MySqlDialect
- Derived
- Inherited Members
Properties
GeneratedKeyDdl
The DDL column suffix declaring a database-generated key (e.g. GENERATED BY DEFAULT AS IDENTITY).
public override string GeneratedKeyDdl { get; }
Property Value
IntrospectColumnsSql
A query listing every column of the schema in use, as four values in order: the table's name, the
column's name, its type spelled the way this dialect spells it in DDL, and whether it accepts
null. null when the dialect cannot read its own catalogue, which makes drift unanswerable
rather than answered wrongly.
Each dialect writes its own, and composes the type in SQL rather than leaving it to be reassembled from parts afterwards. Catalogues disagree about where a type's facets live — one keeps the whole spelling in a column, another splits length from precision from fractional seconds — and the disagreement is far better settled by the store that knows the answer.
public override string? IntrospectColumnsSql { get; }
Property Value
Remarks
column_type rather than data_type: it carries the display width and the fractional-second
precision that this dialect writes into its DDL — tinyint(1), datetime(6) — which
data_type drops, and dropping them would make every boolean and every timestamp read as drift.
SupportsBulkInsert
Whether the engine has a native bulk-load path for this dialect (PostgreSQL COPY,
SQL Server SqlBulkCopy, MySQL's bulk loader). BulkInsertAsync refuses on dialects that
answer false rather than quietly running an ordinary batch — asking for a bulk load and
getting row-by-row inserts is exactly the kind of silent cost this engine does not ship.
public override bool SupportsBulkInsert { get; }
Property Value
System
The OpenTelemetry db.system value (e.g. postgresql, mysql, mssql).
public override string System { get; }
Property Value
Methods
AlterColumnType(string, string, string)
The DDL altering a column's type (a dialect may need a cast clause).
public override string AlterColumnType(string quotedTable, string quotedColumn, string sqlType)
Parameters
Returns
BindValue(object?)
Converts a value before binding (a dialect may need CLR-side coercion, e.g. arrays); identity by default.
public override object? BindValue(object? value)
Parameters
valueobject
Returns
BulkInsertAsync(DbConnection, DbTransaction?, string, IReadOnlyList<RelationalColumn>, IReadOnlyList<object?[]>, CancellationToken)
Bulk-loads rows through the store's native mechanism. Implemented by the dialects that declare
SupportsBulkInsert; each row carries the column values in columns
order, already converted to their stored form by the engine.
public override Task<long> BulkInsertAsync(DbConnection connection, DbTransaction? transaction, string quotedTable, IReadOnlyList<RelationalColumn> columns, IReadOnlyList<object?[]> rows, CancellationToken cancellationToken)
Parameters
connectionDbConnectionThe open connection (inside the caller's transaction, when there is one).
transactionDbTransactionThe ambient transaction, or
null.quotedTablestringThe quoted target table.
columnsIReadOnlyList<RelationalColumn>The target columns, in the order each row's values arrive.
rowsIReadOnlyList<object[]>The rows to load.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Remarks
MySqlConnector's MySqlBulkCopy — the client-side bulk loader, which streams rows without a
statement per row. Column mappings are explicit (ordinal to name), so the engine's row order is
authoritative regardless of the table's physical column order.
CreateIndexSql(string, string, string, bool, IndexMethod, string?)
The DDL creating an index with a structure and an optional filtered predicate (already rendered as a SQL fragment with inlined literals). The base dialect builds default-structure indexes, filtered or not; a method it has no structure for is rejected with guidance.
public override string CreateIndexSql(string quotedName, string quotedTable, string columns, bool unique, IndexMethod method, string? filter)
Parameters
quotedNamestringThe quoted index name.
quotedTablestringThe quoted table.
columnsstringThe rendered key column list.
uniqueboolWhether the index enforces uniqueness.
methodIndexMethodThe index structure.
filterstringThe rendered partial-index predicate, or
null.
Returns
Quote(string)
Quotes an identifier (table or column name).
public override string Quote(string identifier)
Parameters
identifierstring
Returns
SqlType(Type)
The DDL type for a CLR type (used by CREATE TABLE migrations).
public override string SqlType(Type type)
Parameters
typeType
Returns
TupleComparison(IReadOnlyList<string>, ComparisonOperator, IReadOnlyList<string>)
Renders a row-wise tuple comparison; the base dialect cannot express it.
public override string TupleComparison(IReadOnlyList<string> columns, ComparisonOperator op, IReadOnlyList<string> parameters)
Parameters
columnsIReadOnlyList<string>The quoted columns.
opComparisonOperatorThe comparison operator.
parametersIReadOnlyList<string>The bound values' parameter markers.