pub enum ColumnType {
String,
Uuid,
Integer,
BigInt,
}Expand description
The type of the tenant column.
Variants§
Implementations§
Source§impl ColumnType
impl ColumnType
Sourcepub fn placeholder(&self, index: usize) -> String
pub fn placeholder(&self, index: usize) -> String
Get the SQL placeholder for this column type.
Sourcepub fn format_value(&self, value: &str) -> String
👎Deprecated since 0.11.0: interpolates value into SQL without validation; use try_format_value, which rejects invalid UUID/integer values with a QueryError
pub fn format_value(&self, value: &str) -> String
interpolates value into SQL without validation; use try_format_value, which rejects invalid UUID/integer values with a QueryError
Format a value for this column type.
§Hazard
Uuid, Integer, and BigInt values are interpolated into the
resulting SQL fragment without any validation or escaping. A
malicious value (e.g. a raw HTTP header used as a tenant id) can
inject arbitrary SQL. Use Self::try_format_value instead; the
tenant middleware also validates tenant ids at the middleware
boundary.
Sourcepub fn try_format_value(&self, value: &str) -> QueryResult<String>
pub fn try_format_value(&self, value: &str) -> QueryResult<String>
Format a value for this column type, validating it first.
Stringvalues must match the conservative tenant id whitelist^[A-Za-z0-9_\-\:.@]+$—''-doubling alone is not sufficient on backends that honor backslash escapes (MySQL), so string ids are fail-closed instead of escaped.Uuidvalues must parse viauuid::Uuid::parse_str.Integer/BigIntvalues must parse as ani64.
Invalid input is rejected with a QueryError instead of being
interpolated into SQL.
Trait Implementations§
Source§impl Clone for ColumnType
impl Clone for ColumnType
Source§fn clone(&self) -> ColumnType
fn clone(&self) -> ColumnType
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 moreimpl Copy for ColumnType
Source§impl Debug for ColumnType
impl Debug for ColumnType
Source§impl Default for ColumnType
impl Default for ColumnType
Source§fn default() -> ColumnType
fn default() -> ColumnType
Returns the “default value” for a type. Read more
impl Eq for ColumnType
Source§impl PartialEq for ColumnType
impl PartialEq for ColumnType
impl StructuralPartialEq for ColumnType
Auto Trait Implementations§
impl Freeze for ColumnType
impl RefUnwindSafe for ColumnType
impl Send for ColumnType
impl Sync for ColumnType
impl Unpin for ColumnType
impl UnsafeUnpin for ColumnType
impl UnwindSafe for ColumnType
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