pub struct ColumnInfo {
pub name: &'static str,
pub rust_type: &'static str,
pub is_primary_key: bool,
pub is_auto_increment: bool,
pub is_index: bool,
pub is_unique: bool,
pub unique_index_name: Option<&'static str>,
}Expand description
Metadata about a single column in a model’s table schema.
Generated automatically by #[derive(DeriveModel)] and used by
[QueryBuilder::create_table] to generate DDL statements.
§Example
use grorm::{DeriveModel, ColumnInfo, Model};
#[derive(Debug, DeriveModel)]
#[table = "users"]
struct User {
id: i64,
#[index]
name: String,
#[unique]
email: String,
age: i32,
}
let schema = User::table_schema();
assert_eq!(schema.len(), 4);
assert!(schema[0].is_primary_key);
assert!(schema[1].is_index);
assert!(schema[2].is_unique);Fields§
§name: &'static strColumn name in the database
rust_type: &'static strRust type name (e.g. "i64", "String")
is_primary_key: boolWhether this column is part of the primary key
is_auto_increment: boolWhether this column is auto-increment (integer primary key)
is_index: boolWhether a regular index should be created on this column (#[index])
is_unique: boolWhether a unique constraint should be created on this column (#[unique])
unique_index_name: Option<&'static str>Name of the composite unique index group (#[unique_index = "name"]).
Columns with the same name form a composite unique index.
Trait Implementations§
Source§impl Clone for ColumnInfo
impl Clone for ColumnInfo
Source§fn clone(&self) -> ColumnInfo
fn clone(&self) -> ColumnInfo
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ColumnInfo
impl RefUnwindSafe for ColumnInfo
impl Send for ColumnInfo
impl Sync for ColumnInfo
impl Unpin for ColumnInfo
impl UnsafeUnpin for ColumnInfo
impl UnwindSafe for ColumnInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more