pub struct SqlIdentifier<'a>(pub &'a str);Expand description
A wrapper that ensures a SQL identifier is properly escaped when formatted.
This is a zero-cost abstraction that performs escaping lazily during formatting. Identifiers are conditionally quoted:
- Simple lowercase identifiers (
users,my_table) are not quoted - Identifiers with uppercase letters are quoted to preserve case
- Identifiers with special characters are quoted
§Example
use hyperdb_api_core::protocol::escape::SqlIdentifier;
// Simple identifiers are not quoted
assert_eq!(format!("{}", SqlIdentifier("users")), "users");
assert_eq!(format!("{}", SqlIdentifier("my_table")), "my_table");
// Uppercase letters are quoted to preserve case
assert_eq!(format!("{}", SqlIdentifier("Segment")), "\"Segment\"");
// Special characters require quoting
assert_eq!(format!("{}", SqlIdentifier("my-table")), "\"my-table\"");
assert_eq!(format!("{}", SqlIdentifier("my table")), "\"my table\"");
// Internal quotes are escaped
assert_eq!(format!("{}", SqlIdentifier("my\"table")), "\"my\"\"table\"");Tuple Fields§
§0: &'a strTrait Implementations§
Source§impl<'a> Clone for SqlIdentifier<'a>
impl<'a> Clone for SqlIdentifier<'a>
Source§fn clone(&self) -> SqlIdentifier<'a>
fn clone(&self) -> SqlIdentifier<'a>
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<'a> Debug for SqlIdentifier<'a>
impl<'a> Debug for SqlIdentifier<'a>
Source§impl Display for SqlIdentifier<'_>
impl Display for SqlIdentifier<'_>
impl<'a> Copy for SqlIdentifier<'a>
Auto Trait Implementations§
impl<'a> Freeze for SqlIdentifier<'a>
impl<'a> RefUnwindSafe for SqlIdentifier<'a>
impl<'a> Send for SqlIdentifier<'a>
impl<'a> Sync for SqlIdentifier<'a>
impl<'a> Unpin for SqlIdentifier<'a>
impl<'a> UnsafeUnpin for SqlIdentifier<'a>
impl<'a> UnwindSafe for SqlIdentifier<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request