GeneratedColumn<T extends Object> class Null safety

Implementation for a Column declared on a table.

Available Extensions


GeneratedColumn(String $name, String tableName, bool $nullable, {T? clientDefault()?, required DriftSqlType<T> type, void defaultConstraints(GenerationContext)?, String? $customConstraints, Expression<T>? defaultValue, VerificationResult additionalChecks(T?, VerificationMeta)?, bool requiredDuringInsert = false, GeneratedAs? generatedAs, Expression<bool> check()?, bool hasAutoIncrement = false})
Used by generated code.


$customConstraints String?
Custom constraints that have been specified for this column.
$name String
The sql name of this column.
$nullable bool
Whether null values are allowed for this column.
additionalChecks → (VerificationResult Function(T?, VerificationMeta)?)
Additional checks performed on values before inserts or updates.
check → (Expression<bool> Function()?)
A CHECK column constraint present on this column.
clientDefault → (T? Function()?)
A function that yields a default column for inserts if no value has been set. This is different to defaultValue since the function is written in Dart, not SQL. It's a compile-time error to declare columns where both defaultValue and clientDefault are non-null.
defaultValue Expression<T>?
The default expression to be used during inserts when no value has been specified. Can be null if no default value is set.
driftSqlType DriftSqlType<T>
The supported DriftSqlType backing this expression.
escapedName String
name, but wrapped in double quotes to escape it as a a same identifier.
generatedAs GeneratedAs?
If this column is generated (that is, it is a SQL expression of other) columns, contains information about how to generate this column.
hasAutoIncrement bool
Whether this column has an AUTOINCREMENT primary key constraint that was created by drift.
hashCode int
The hash code for this object.
isLiteral bool
Whether this expression is a literal. Some use-sites need to put parentheses around non-literals.
name String
The (unescaped) name of this column.
precedence Precedence
The precedence of this expression. This can be used to automatically put parentheses around expressions as needed.
requiredDuringInsert bool
Whether a value is required for this column when inserting a new row.
runtimeType Type
A representation of the runtime type of the object.
tableName String
The name of the table that contains this column
type DriftSqlType<T>
The sql type to use for this column.


caseMatch<T extends Object>({required Map<Expression<T>, Expression<T>> when, Expression<T>? orElse}) Expression<T>
A CASE WHEN construct using the current expression as a base.
cast<D2 extends Object>() Expression<D2>
Generates a CAST(expression AS TYPE) expression.
dartCast<D2 extends Object>() Expression<D2>
Casts this expression to an expression of D.
equals(T compare) Expression<bool>
Whether this column is equal to the given value, which must have a fitting type. The compare value will be written as a variable using prepared statements, so there is no risk of an SQL-injection.
equalsExp(Expression<T> compare) Expression<bool>
Whether this expression is equal to the given expression.
equalsNullable(T? compare) Expression<bool>
Compares the value of this column to compare or null.
isAcceptableOrUnknown(Expression<Object> value, VerificationMeta meta) VerificationResult
A more general version of isAcceptableValue that supports any sql expression.
isAcceptableValue(T? value, VerificationMeta meta) VerificationResult
Checks whether the given value fits into this column. The default implementation only checks for nullability, but subclasses might enforce additional checks. For instance, a text column might verify that a text has a certain length.
isIn(Iterable<T> values) Expression<bool>
An expression that is true if this resolves to any of the values in values.
isInQuery(BaseSelectStatement select) Expression<bool>
An expression checking whether this is included in any row of the provided select statement.
isNotIn(Iterable<T> values) Expression<bool>
An expression that is true if this does not resolve to any of the values in values.
isNotInQuery(BaseSelectStatement select) Expression<bool>
An expression checking whether this is not included in any row of the provided select statement.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
toString() String
A string representation of this object.
withConverter<D>(TypeConverter<D, T?> converter) GeneratedColumnWithTypeConverter<D, T>
Applies a type converter to this column.
writeAroundPrecedence(GenerationContext context, Precedence precedence) → void
Writes this expression into the GenerationContext, assuming that there's an outer expression with precedence. If the Expression.precedence of this expression is lower, it will be wrap}ped in
writeColumnDefinition(GenerationContext into) → void
Writes the definition of this column, as defined here, into the given buffer.
writeInner(GenerationContext ctx, Expression<Object> inner) → void
If this Expression wraps an inner expression, this utility method can be used inside writeInto to write that inner expression while wrapping it in parentheses if necessary.
writeInto(GenerationContext context, {bool ignoreEscape = false}) → void
Writes this component into the context by writing to its GenerationContext.buffer or by introducing bound variables. When writing into the buffer, no whitespace around the this component should be introduced. When a component consists of multiple composed component, it's responsible for introducing whitespace between its child components.


operator ==(Object other) bool
The equality operator.

Static Methods

checkTextLength({int? minTextLength, int? maxTextLength}) VerificationResult Function(String?, VerificationMeta)
A value for additionalChecks validating allowed text lengths.
constraintIsAlways(String constraint) → dynamic Function(GenerationContext)
A helper method to make creating defaultConstraints simpler. Used when the constraint does not depend on the dialect.
constraintsDependsOnDialect(Map<SqlDialect, String> constraints) → dynamic Function(GenerationContext)
A helper method to make creating defaultConstraints simpler. Used when the constraint depends on the dialect.