pub struct ColumnDefinition {
pub name: String,
pub data_type: String,
pub nullable: bool,
pub primary_key: bool,
pub auto_increment: bool,
pub unsigned: bool,
pub default: Option<String>,
pub comment: Option<String>,
}Expand description
单个字段定义(对齐 PHP think\db\Fetch::getFields 返回的单字段元数据)
存储数据表单个字段的完整元数据,包括字段名、类型、约束、默认值等。
§PHP 对齐
PHP getFields 返回字段数组,每个元素包含:
name:字段名type:字段类型(如int(11) unsigned)notnull:是否 NOT NULL(注意 PHP 是“是否非空“,Rust 用nullable取反)default:默认值primary:是否主键autoinc:是否自增
Rust 端额外扩展 unsigned(无符号)和 comment(字段注释)字段。
Fields§
§name: String字段名
data_type: String字段数据类型(如 int(11), varchar(255), text, decimal(10,2))
nullable: bool是否允许 NULL(对齐 PHP notnull 取反:nullable = !notnull)
primary_key: bool是否为主键(对齐 PHP primary)
auto_increment: bool是否自增(对齐 PHP autoinc)
unsigned: bool是否无符号(数值类型扩展字段,PHP 端从 type 字符串解析)
default: Option<String>默认值(None 表示无 DEFAULT 子句,Some(value) 表示有默认值)
comment: Option<String>字段注释(从 COMMENT 子句获取,PHP 端通常不缓存)
Implementations§
Source§impl ColumnDefinition
impl ColumnDefinition
Sourcepub fn primary_key(self, primary_key: bool) -> Self
pub fn primary_key(self, primary_key: bool) -> Self
设置是否为主键(Builder 模式)
Sourcepub fn auto_increment(self, auto_increment: bool) -> Self
pub fn auto_increment(self, auto_increment: bool) -> Self
设置是否自增(Builder 模式)
Sourcepub fn default_value(self, default: impl Into<String>) -> Self
pub fn default_value(self, default: impl Into<String>) -> Self
设置默认值(Builder 模式)
Trait Implementations§
Source§impl Clone for ColumnDefinition
impl Clone for ColumnDefinition
Source§fn clone(&self) -> ColumnDefinition
fn clone(&self) -> ColumnDefinition
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 moreSource§impl Debug for ColumnDefinition
impl Debug for ColumnDefinition
Source§impl<'de> Deserialize<'de> for ColumnDefinition
impl<'de> Deserialize<'de> for ColumnDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ColumnDefinition
Source§impl PartialEq for ColumnDefinition
impl PartialEq for ColumnDefinition
Source§impl Serialize for ColumnDefinition
impl Serialize for ColumnDefinition
impl StructuralPartialEq for ColumnDefinition
Auto Trait Implementations§
impl Freeze for ColumnDefinition
impl RefUnwindSafe for ColumnDefinition
impl Send for ColumnDefinition
impl Sync for ColumnDefinition
impl Unpin for ColumnDefinition
impl UnsafeUnpin for ColumnDefinition
impl UnwindSafe for ColumnDefinition
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.