Skip to main content

Column

Struct Column 

Source
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>

Source

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).

Source

pub fn with_length(self, length: Option<i64>) -> Self

The column with a length (strings).

PHP: the $length constructor parameter.

Source

pub fn with_precision(self, precision: Option<i64>) -> Self

The column with a precision.

PHP: the $precision constructor parameter.

Source

pub fn with_scale(self, scale: Option<i64>) -> Self

The column with a scale.

PHP: the $scale constructor parameter.

Source

pub fn with_srid(self, srid: Option<i64>) -> Self

The column with a spatial reference system.

PHP: the $srid constructor parameter.

Source

pub fn with_dimensions(self, dimensions: Option<i64>) -> Self

The column with a vector width.

PHP: the $dimensions constructor parameter.

Source

pub fn with_auto_increment(self, auto_increment: bool) -> Self

The column, server-incremented or not.

PHP: the $autoIncrement constructor parameter.

Source

pub fn definition(&self) -> &ColumnDefinition

What the column is.

PHP: the column’s public properties.

Source

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.

Source

pub fn name(&self) -> &str

The name.

PHP: $column->name.

Source

pub fn nullable(&mut self) -> &mut Self

Accepts NULL.

PHP: nullable().

Source

pub fn default(&mut self, value: impl IntoValue) -> &mut Self

Sets the default value, rendered as a literal (None for DEFAULT NULL).

PHP: default().

Source

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().

Source

pub fn unsigned(&mut self) -> &mut Self

Marks the column unsigned.

PHP: unsigned().

Source

pub fn primary(&mut self) -> &mut Self

Marks the column as the primary key (a composite key is Table::primary).

PHP: primary() without arguments.

Source

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

pub fn modify(&mut self) -> &mut Self

Makes an ALTER modify the column instead of adding it.

PHP: modify().

Source§

impl<S: AutoIncrement> Column<S>

Source

pub fn auto_increment(&mut self) -> &mut Self

Marks the column server-incremented.

PHP: autoIncrement().

Source§

impl<S: Collation> Column<S>

Source

pub fn collation(&mut self, collation: impl Into<String>) -> &mut Self

Sets the collation.

PHP: collation().

Source§

impl<S: Comment> Column<S>

Source

pub fn comment(&mut self, comment: impl Into<String>) -> &mut Self

Sets the comment.

PHP: comment().

Source§

impl<S: Dimensions> Column<S>

Source

pub fn dimensions(&mut self, dimensions: i64) -> &mut Self

Sets the width of a vector column.

PHP: dimensions().

Source§

impl<S: Generated> Column<S>

Source

pub fn generated_as(&mut self, expression: impl Into<String>) -> &mut Self

Makes the column generated from expression.

PHP: generatedAs().

Source

pub fn stored(&mut self) -> &mut Self

Stores the generated column.

PHP: stored().

Source§

impl<S: VirtualGenerated> Column<S>

Source

pub fn virtual_(&mut self) -> &mut Self

Computes the generated column on read.

PHP: virtual().

Source§

impl<S: Positioning> Column<S>

Source

pub fn after(&mut self, column: impl Into<String>) -> &mut Self

Places the column after column (in an ALTER).

PHP: after().

Source§

impl<S: Srid> Column<S>

Source

pub fn srid(&mut self, srid: i64) -> &mut Self

Sets the spatial reference system.

PHP: srid().

Source§

impl<S: Unique> Column<S>

Source

pub fn unique(&mut self) -> &mut Self

Marks the column unique.

PHP: unique().

Source§

impl<S: Checks> Column<S>

Source

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>

Source

pub fn user_type(&mut self, name: &str) -> Result<&mut Self>

Uses the user-defined type name (a CREATE TYPE enum), which must be an identifier.

PHP: Column\PostgreSQL::userType().

Source§

impl Column<ClickHouse>

Source

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().

Source

pub fn is_fixed_string(&self) -> bool

Whether the column is FixedString(N).

PHP: isFixedString().

Source

pub fn as_array(&mut self, element: ColumnType) -> &mut Self

Makes the column Array(element).

PHP: asArray().

Source

pub fn is_array(&self) -> bool

Whether the column is Array(T).

PHP: isArray().

Source

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().

Source

pub fn is_tuple(&self) -> bool

Whether the column is Tuple(...).

PHP: isTuple().

Source

pub fn low_cardinality(&mut self) -> &mut Self

Wraps the type in LowCardinality(...).

PHP: lowCardinality().

Source

pub fn codec(&mut self, codec: &str) -> Result<&mut Self>

Adds a CODEC(...) clause (LZ4, Delta(4)), trimmed; it must not be empty nor contain ;.

PHP: codec().

Source

pub fn ttl(&mut self, expression: &str) -> Result<&mut Self>

Sets a column-level TTL expression, trimmed; it must not be empty nor contain ;.

PHP: Column\ClickHouse::ttl().

Trait Implementations§

Source§

impl<S> Clone for Column<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S> Debug for Column<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S> PartialEq for Column<S>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<S> !Freeze for Column<S>

§

impl<S> Forget for Column<S>

§

impl<S> Move for Column<S>

§

impl<S> RefUnwindSafe for Column<S>

§

impl<S> Send for Column<S>
where RawVecInner: Send, &'static [u8]: Send, Bytes: Send, Arc<Repr<Object>>: Send, BoxRaw<Query>: Send,

§

impl<S> Sync for Column<S>
where RawVecInner: Sync, Bytes: Sync, Arc<Repr<Object>>: Sync, BoxRaw<Query>: Sync,

§

impl<S> Unpin for Column<S>
where *const u8 is !null: Unpin, &'static [u8]: Unpin, *const u8: Unpin, Align8<*mut ()>: Unpin, &'static Vtable: Unpin, Arc<Repr<Object>>: Unpin, Box<Query>: Unpin,

§

impl<S> UnsafeUnpin for Column<S>

§

impl<S> UnwindSafe for Column<S>
where RawVecInner: UnwindSafe, &'static [u8]: UnwindSafe, *const u8: UnwindSafe, Align8<*mut ()>: UnwindSafe, &'static Vtable: UnwindSafe, Arc<Repr<Object>>: UnwindSafe, BoxRaw<Query>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.