pub struct QuotedIdentifier<'a>(pub &'a str);Expand description
A SQL identifier that is always quoted, whatever it contains.
SqlIdentifier omits the quotes when a name is already a legal bare
identifier, which is fine for display but unsafe for generated DDL:
is_valid_unquoted_identifier deliberately does not know the reserved
word list, so an all-lowercase keyword such as select or order passes
the check and is emitted bare, producing a syntax error. Quoting
unconditionally sidesteps the whole question — "users" and users name
the same relation, so the extra quotes never change meaning.
Use this for any identifier written into SQL that the engine must parse.
§Example
use hyperdb_api_core::protocol::escape::QuotedIdentifier;
// Reserved words survive, where SqlIdentifier would emit them bare
assert_eq!(format!("{}", QuotedIdentifier("select")), "\"select\"");
assert_eq!(format!("{}", QuotedIdentifier("users")), "\"users\"");
// Internal quotes are doubled
assert_eq!(format!("{}", QuotedIdentifier("a\"b")), "\"a\"\"b\"");Tuple Fields§
§0: &'a strTrait Implementations§
Source§impl<'a> Clone for QuotedIdentifier<'a>
impl<'a> Clone for QuotedIdentifier<'a>
Source§fn clone(&self) -> QuotedIdentifier<'a>
fn clone(&self) -> QuotedIdentifier<'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 moreimpl<'a> Copy for QuotedIdentifier<'a>
Source§impl<'a> Debug for QuotedIdentifier<'a>
impl<'a> Debug for QuotedIdentifier<'a>
Auto Trait Implementations§
impl<'a> Freeze for QuotedIdentifier<'a>
impl<'a> RefUnwindSafe for QuotedIdentifier<'a>
impl<'a> Send for QuotedIdentifier<'a>
impl<'a> Sync for QuotedIdentifier<'a>
impl<'a> Unpin for QuotedIdentifier<'a>
impl<'a> UnsafeUnpin for QuotedIdentifier<'a>
impl<'a> UnwindSafe for QuotedIdentifier<'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