pub struct Column<S> { /* private fields */ }Expand description
A column of a table blueprint for the dialect S.
Built by the table’s factories (Table::string,
Table::integer, …), which return it to
chain modifiers: table.string("email", 255).unique().nullable().
PHP: Utopia\Query\Schema\Column and its dialect classes
(Column\MySQL, Column\PostgreSQL, Column\SQLite,
Column\ClickHouse, Column\MongoDB).
Implementations§
Source§impl<S> Column<S>
impl<S> Column<S>
Sourcepub fn new(name: impl Into<String>, kind: ColumnType) -> Self
pub fn new(name: impl Into<String>, kind: ColumnType) -> Self
A column name of type kind, with no size and no modifier (PHP’s
table factories make columns; this one belongs to no table).
PHP: new Column($table, $name, $type).
Sourcepub fn with_length(self, length: Option<i64>) -> Self
pub fn with_length(self, length: Option<i64>) -> Self
The column with a length (strings).
PHP: the $length constructor parameter.
Sourcepub fn with_precision(self, precision: Option<i64>) -> Self
pub fn with_precision(self, precision: Option<i64>) -> Self
The column with a precision.
PHP: the $precision constructor parameter.
Sourcepub fn with_scale(self, scale: Option<i64>) -> Self
pub fn with_scale(self, scale: Option<i64>) -> Self
The column with a scale.
PHP: the $scale constructor parameter.
Sourcepub fn with_srid(self, srid: Option<i64>) -> Self
pub fn with_srid(self, srid: Option<i64>) -> Self
The column with a spatial reference system.
PHP: the $srid constructor parameter.
Sourcepub fn with_dimensions(self, dimensions: Option<i64>) -> Self
pub fn with_dimensions(self, dimensions: Option<i64>) -> Self
The column with a vector width.
PHP: the $dimensions constructor parameter.
Sourcepub fn with_auto_increment(self, auto_increment: bool) -> Self
pub fn with_auto_increment(self, auto_increment: bool) -> Self
The column, server-incremented or not.
PHP: the $autoIncrement constructor parameter.
Sourcepub fn definition(&self) -> &ColumnDefinition
pub fn definition(&self) -> &ColumnDefinition
What the column is.
PHP: the column’s public properties.
Sourcepub fn definition_mut(&mut self) -> &mut ColumnDefinition
pub fn definition_mut(&mut self) -> &mut ColumnDefinition
What the column is, to set directly: nothing here is validated, as nothing is when PHP sets a column’s properties.
Sourcepub fn default(&mut self, value: impl IntoValue) -> &mut Self
pub fn default(&mut self, value: impl IntoValue) -> &mut Self
Sets the default value, rendered as a literal (None for
DEFAULT NULL).
PHP: default().
Sourcepub fn default_raw(&mut self, expression: &str) -> Result<&mut Self>
pub fn default_raw(&mut self, expression: &str) -> Result<&mut Self>
Sets a raw default expression (now(), gen_random_uuid()),
trimmed; it must not be empty nor contain ;.
PHP: defaultRaw().
Sourcepub fn primary(&mut self) -> &mut Self
pub fn primary(&mut self) -> &mut Self
Marks the column as the primary key (a composite key is
Table::primary).
PHP: primary() without arguments.
Sourcepub fn enum_values<V: Into<String>>(
&mut self,
values: impl IntoIterator<Item = V>,
) -> Result<&mut Self>
pub fn enum_values<V: Into<String>>( &mut self, values: impl IntoIterator<Item = V>, ) -> Result<&mut Self>
Sets the allowed values of an enum column; there must be one at least.
PHP: enum() with one array argument.
Source§impl<S: AutoIncrement> Column<S>
impl<S: AutoIncrement> Column<S>
Sourcepub fn auto_increment(&mut self) -> &mut Self
pub fn auto_increment(&mut self) -> &mut Self
Marks the column server-incremented.
PHP: autoIncrement().
Source§impl<S: Dimensions> Column<S>
impl<S: Dimensions> Column<S>
Sourcepub fn dimensions(&mut self, dimensions: i64) -> &mut Self
pub fn dimensions(&mut self, dimensions: i64) -> &mut Self
Sets the width of a vector column.
PHP: dimensions().
Source§impl<S: VirtualGenerated> Column<S>
impl<S: VirtualGenerated> Column<S>
Source§impl<S: Positioning> Column<S>
impl<S: Positioning> Column<S>
Source§impl<S: Checks> Column<S>
impl<S: Checks> Column<S>
Sourcepub fn check(&mut self, expression: impl Into<String>) -> &mut Self
pub fn check(&mut self, expression: impl Into<String>) -> &mut Self
Sets a column-level CHECK expression (a named table-level check is
Table::check).
PHP: check() with one argument.
Source§impl Column<PostgreSql>
impl Column<PostgreSql>
Source§impl Column<ClickHouse>
impl Column<ClickHouse>
Sourcepub fn as_fixed_string(&mut self, length: i64) -> Result<&mut Self>
pub fn as_fixed_string(&mut self, length: i64) -> Result<&mut Self>
Makes the column FixedString(length); the length is at least 1.
PHP: Column\ClickHouse::asFixedString().
Sourcepub fn is_fixed_string(&self) -> bool
pub fn is_fixed_string(&self) -> bool
Whether the column is FixedString(N).
PHP: isFixedString().
Sourcepub fn as_array(&mut self, element: ColumnType) -> &mut Self
pub fn as_array(&mut self, element: ColumnType) -> &mut Self
Makes the column Array(element).
PHP: asArray().
Sourcepub fn as_tuple(&mut self, elements: Vec<ColumnType>) -> Result<&mut Self>
pub fn as_tuple(&mut self, elements: Vec<ColumnType>) -> Result<&mut Self>
Makes the column Tuple(elements...); there must be one at least.
PHP: asTuple().
Sourcepub fn low_cardinality(&mut self) -> &mut Self
pub fn low_cardinality(&mut self) -> &mut Self
Wraps the type in LowCardinality(...).
PHP: lowCardinality().