CockroachDbStatementBuilder
A class used to build the SQL statements for CockroachDB.
This class is the BaseStatementBuilder-derived implementation for CockroachDB. It is automatically registered by CockroachDbBootstrap — you do not need to instantiate it directly under normal use.
Constructors
public CockroachDbStatementBuilder()
public CockroachDbStatementBuilder(IDbSetting dbSetting,
IResolver<Field, IDbSetting, string> convertFieldResolver = null,
IResolver<Type, Type> averageableClientTypeResolver = null)
The parameterless constructor defaults convertFieldResolver to CockroachDbConvertFieldResolver.
CockroachDB-specific generation notes
- Paging uses
LIMIT/LIMIT ... OFFSETfor Query/top-N queries and BatchQuery/skip-take queries. - Insert appends a trailing
RETURNING ... AS "Result"clause so the generated/primary key is returned in the same round trip, casting it to its SQL type first when one can be resolved. - InsertAll builds a single multi-row
INSERT ... VALUES (...), (...), ...with one trailingRETURNINGclause for the whole batch — this assumes the returned rows come back in the same order the rows were listed, which has not been independently verified against CockroachDB. - Merge/MergeAll compile to
INSERT ... ON CONFLICT (qualifiers) DO UPDATE SET ..., each with a trailingRETURNINGclause (MergeAll also returns a per-row__RepoDb_OrderColumnparameter alongside the key, to align results back to the source rows). An identity column is inserted withOVERRIDING SYSTEM VALUEso an explicit value on the entity is respected instead of silently ignored. - Truncate is a plain
TRUNCATE TABLE ...— noRESTART IDENTITY. - Passing a non-null
hintsargument to anyCreate*method throwsNotSupportedException, sinceCockroachDbDbSetting.AreTableHintsSupportedisfalse.
Usability
Use StatementBuilderMapper to override it with a custom implementation.
StatementBuilderMapper.Add(typeof(CockroachDbConnection), new MyCustomCockroachDbStatementBuilder(dbSetting), true);