pub enum DatabaseType {
PostgreSQL,
MySQL,
SQLite,
}Expand description
Build a parameter placeholder for a given database type.
Variants§
Implementations§
Source§impl DatabaseType
impl DatabaseType
Sourcepub fn placeholder(&self, index: usize) -> Cow<'static, str>
pub fn placeholder(&self, index: usize) -> Cow<'static, str>
Get the parameter placeholder for this database type.
For MySQL and SQLite, this returns a borrowed static string (zero allocation). For PostgreSQL with index 1-128, this returns a borrowed static string (zero allocation). For PostgreSQL with index > 128, this returns an owned formatted string.
§Examples
use prax_query::sql::DatabaseType;
// PostgreSQL uses numbered placeholders (zero allocation for 1-128)
assert_eq!(DatabaseType::PostgreSQL.placeholder(1).as_ref(), "$1");
assert_eq!(DatabaseType::PostgreSQL.placeholder(5).as_ref(), "$5");
assert_eq!(DatabaseType::PostgreSQL.placeholder(100).as_ref(), "$100");
// MySQL and SQLite use ? (zero allocation)
assert_eq!(DatabaseType::MySQL.placeholder(1).as_ref(), "?");
assert_eq!(DatabaseType::SQLite.placeholder(1).as_ref(), "?");Sourcepub fn placeholder_string(&self, index: usize) -> String
pub fn placeholder_string(&self, index: usize) -> String
Get the parameter placeholder as a String.
This is a convenience method that always allocates. Prefer placeholder()
when you can work with Cow<str> to avoid unnecessary allocations.
Trait Implementations§
Source§impl Clone for DatabaseType
impl Clone for DatabaseType
Source§fn clone(&self) -> DatabaseType
fn clone(&self) -> DatabaseType
Returns a duplicate of the value. Read more
1.0.0 · 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 DatabaseType
impl Debug for DatabaseType
Source§impl Default for DatabaseType
impl Default for DatabaseType
Source§fn default() -> DatabaseType
fn default() -> DatabaseType
Returns the “default value” for a type. Read more
Source§impl PartialEq for DatabaseType
impl PartialEq for DatabaseType
impl Copy for DatabaseType
impl Eq for DatabaseType
impl StructuralPartialEq for DatabaseType
Auto Trait Implementations§
impl Freeze for DatabaseType
impl RefUnwindSafe for DatabaseType
impl Send for DatabaseType
impl Sync for DatabaseType
impl Unpin for DatabaseType
impl UnwindSafe for DatabaseType
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