@@ -12,13 +12,14 @@ pub trait SqlDialect {
1212 const DB : DatabaseType ;
1313 const SUPPORTS_RETURNING : bool = true ;
1414 const _SUPPORTS_LIMIT_OFFSET: bool = true ;
15- const IDENT_QUOTING : IdentQuoting = IdentQuoting :: DoubleQuote ;
15+ const IDENT_QUOTING : IdentQuotingStyle = IdentQuotingStyle :: DoubleQuote ;
1616 const PLACEHOLDER_SYMBOL : PlaceholderSymbol = PlaceholderSymbol :: DollarNumbered ;
17- const PLACEHOLDER_DATA_TYPE : PlaceholderDatatype = PlaceholderDatatype :: VARCHAR ;
17+ const PLACEHOLDER_DATA_TYPE : PlaceholderDatatype = PlaceholderDatatype :: Varchar ;
1818}
1919
2020/// Safe assuming that Canyon's default is PostgreSQL,
2121/// which is the most widely used and standards-compliant database among the supported ones.
22+ #[ allow( dead_code) ]
2223pub struct StandardDialect ;
2324impl SqlDialect for StandardDialect {
2425 const DB : DatabaseType = PostgreSql ;
@@ -29,7 +30,7 @@ pub struct PgDialect;
2930#[ cfg( feature = "postgres" ) ]
3031impl SqlDialect for PgDialect {
3132 const DB : DatabaseType = PostgreSql ;
32- const IDENT_QUOTING : IdentQuoting = IdentQuoting :: DoubleQuote ;
33+ const IDENT_QUOTING : IdentQuotingStyle = IdentQuotingStyle :: DoubleQuote ;
3334 const PLACEHOLDER_SYMBOL : PlaceholderSymbol = PlaceholderSymbol :: DollarNumbered ;
3435}
3536
@@ -39,7 +40,7 @@ pub struct MsSql;
3940impl SqlDialect for MsSql {
4041 const DB : DatabaseType = SqlServer ;
4142 const SUPPORTS_RETURNING : bool = false ;
42- const IDENT_QUOTING : IdentQuoting = IdentQuoting :: Bracket ;
43+ const IDENT_QUOTING : IdentQuotingStyle = IdentQuotingStyle :: Bracket ;
4344 const PLACEHOLDER_SYMBOL : PlaceholderSymbol = PlaceholderSymbol :: AtPNumbered ;
4445}
4546
@@ -48,9 +49,9 @@ pub struct MySql;
4849#[ cfg( feature = "mysql" ) ]
4950impl SqlDialect for MySql {
5051 const DB : DatabaseType = MySQL ;
51- const IDENT_QUOTING : IdentQuoting = IdentQuoting :: Backtick ;
52+ const IDENT_QUOTING : IdentQuotingStyle = IdentQuotingStyle :: Backtick ;
5253 const PLACEHOLDER_SYMBOL : PlaceholderSymbol = PlaceholderSymbol :: QuestionMark ;
53- const PLACEHOLDER_DATA_TYPE : PlaceholderDatatype = PlaceholderDatatype :: CHAR ;
54+ const PLACEHOLDER_DATA_TYPE : PlaceholderDatatype = PlaceholderDatatype :: Char ;
5455}
5556
5657/// Identifier quoting strategy for a SQL dialect.
@@ -65,7 +66,7 @@ impl SqlDialect for MySql {
6566/// - MySQL: `` `ident` ``
6667/// - SQL Server: `[ident]`
6768#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
68- pub enum IdentQuoting {
69+ pub enum IdentQuotingStyle {
6970 /// ANSI SQL style, used by PostgreSQL and as the generic default.
7071 DoubleQuote ,
7172 /// MySQL style.
@@ -74,23 +75,43 @@ pub enum IdentQuoting {
7475 Bracket ,
7576}
7677
77- impl IdentQuoting {
78+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
79+ pub enum IdentQuoting {
80+ DoubleQuote ,
81+ Backtick ,
82+ OpeningBracket ,
83+ ClosingBracket ,
84+ }
85+
86+ impl IdentQuotingStyle {
7887 #[ inline]
79- pub const fn opening ( self ) -> & ' static str {
88+ pub const fn opening ( self ) -> IdentQuoting {
8089 match self {
81- Self :: DoubleQuote => " \" " ,
82- Self :: Backtick => "`" ,
83- Self :: Bracket => "[" ,
90+ Self :: DoubleQuote => IdentQuoting :: DoubleQuote ,
91+ Self :: Backtick => IdentQuoting :: Backtick ,
92+ Self :: Bracket => IdentQuoting :: OpeningBracket ,
8493 }
8594 }
8695
8796 #[ inline]
88- pub const fn closing ( self ) -> & ' static str {
97+ pub const fn closing ( self ) -> IdentQuoting {
8998 match self {
99+ Self :: DoubleQuote => IdentQuoting :: DoubleQuote ,
100+ Self :: Backtick => IdentQuoting :: Backtick ,
101+ Self :: Bracket => IdentQuoting :: ClosingBracket ,
102+ }
103+ }
104+ }
105+
106+ impl Display for IdentQuoting {
107+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
108+ let t = match self {
90109 Self :: DoubleQuote => "\" " ,
91110 Self :: Backtick => "`" ,
92- Self :: Bracket => "]" ,
93- }
111+ Self :: OpeningBracket => "[" ,
112+ Self :: ClosingBracket => "]" ,
113+ } ;
114+ write ! ( f, "{}" , t)
94115 }
95116}
96117
@@ -104,7 +125,7 @@ pub enum PlaceholderSymbol {
104125 /// @p1, @p2, @p3
105126 AtPNumbered ,
106127 /// :1, :2, :3
107- ColonNumbered ,
128+ _ColonNumbered ,
108129}
109130
110131impl Display for PlaceholderSymbol {
@@ -113,7 +134,7 @@ impl Display for PlaceholderSymbol {
113134 Self :: QuestionMark => "?" ,
114135 Self :: DollarNumbered => "$" ,
115136 Self :: AtPNumbered => "@P" ,
116- Self :: ColonNumbered => ":" ,
137+ Self :: _ColonNumbered => ":" ,
117138 } ;
118139 write ! ( f, "{}" , symbol)
119140 }
@@ -122,15 +143,15 @@ impl Display for PlaceholderSymbol {
122143/// Represents the syntax style for parameter placeholders in prepared statements.
123144#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
124145pub enum PlaceholderDatatype {
125- VARCHAR ,
126- CHAR ,
146+ Varchar ,
147+ Char ,
127148}
128149
129150impl Display for PlaceholderDatatype {
130151 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
131152 let datatype = match self {
132- Self :: VARCHAR => "VARCHAR" ,
133- Self :: CHAR => "CHAR" ,
153+ Self :: Varchar => "VARCHAR" ,
154+ Self :: Char => "CHAR" ,
134155 } ;
135156 write ! ( f, "{}" , datatype)
136157 }
0 commit comments