1use common::fmt::EscapeKwFreeIdent;
2use surrealdb_strand::Strand;
3use surrealdb_types::{SqlFormat, ToSql, write_sql};
4
5#[derive(Clone, Debug, Default, PartialEq, Eq)]
6#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
7pub struct Param(Strand);
8
9impl Param {
10 pub fn new(str: impl Into<Strand>) -> Self {
15 Self(str.into())
16 }
17
18 pub fn as_str(&self) -> &str {
20 self.0.as_str()
21 }
22
23 pub fn into_string(self) -> String {
25 self.0.into_string()
26 }
27
28 pub fn into_strand(self) -> Strand {
30 self.0
31 }
32}
33
34impl ToSql for Param {
35 fn fmt_sql(&self, f: &mut String, fmt: SqlFormat) {
36 write_sql!(f, fmt, "${}", EscapeKwFreeIdent(self.as_str()))
37 }
38}