@@ -32,11 +32,13 @@ impl Bind for Identifier<'_> {
3232 }
3333}
3434
35+ /// A variant on `Identifier` which supports qualifying an identifier. For example,
36+ /// `QualifiedIdentifier("foo", "bar")` will emit the SQL `\`foo\`.\`bar\``.
3537#[ derive( Clone , Copy ) ]
36- pub struct ScopedIdentifier < ' a > ( pub & ' a str , pub & ' a str ) ;
38+ pub struct QualifiedIdentifier < ' a > ( pub & ' a str , pub & ' a str ) ;
3739
3840#[ sealed]
39- impl Bind for ScopedIdentifier < ' _ > {
41+ impl Bind for QualifiedIdentifier < ' _ > {
4042 #[ inline]
4143 fn write ( & self , dst : & mut impl fmt:: Write ) -> Result < ( ) , String > {
4244 if self . 0 . len ( ) > 0 {
@@ -49,7 +51,7 @@ impl Bind for ScopedIdentifier<'_> {
4951
5052#[ cfg( test) ]
5153mod tests {
52- use super :: { Bind , ScopedIdentifier } ;
54+ use super :: { Bind , QualifiedIdentifier } ;
5355
5456 fn bind_to_string ( b : impl Bind ) -> String {
5557 let mut s = String :: new ( ) ;
@@ -58,23 +60,26 @@ mod tests {
5860 }
5961
6062 #[ test]
61- fn test_scoped_identifier ( ) {
63+ fn test_qualified_identifier ( ) {
6264 assert_eq ! (
63- bind_to_string( ScopedIdentifier ( "foo" , "bar baz" ) ) ,
65+ bind_to_string( QualifiedIdentifier ( "foo" , "bar baz" ) ) ,
6466 "`foo`.`bar baz`"
6567 ) ;
66- assert_eq ! ( bind_to_string( ScopedIdentifier ( "" , "bar baz" ) ) , "`bar baz`" ) ;
68+ assert_eq ! (
69+ bind_to_string( QualifiedIdentifier ( "" , "bar baz" ) ) ,
70+ "`bar baz`"
71+ ) ;
6772
6873 assert_eq ! (
69- bind_to_string( ScopedIdentifier ( "`'." , ".................````" ) ) ,
74+ bind_to_string( QualifiedIdentifier ( "`'." , ".................````" ) ) ,
7075 "`\\ `\\ '.`.`.................\\ `\\ `\\ `\\ ``"
7176 ) ;
7277
7378 assert_eq ! (
74- bind_to_string( ScopedIdentifier ( "クリック" , "ハウス" ) ) ,
79+ bind_to_string( QualifiedIdentifier ( "クリック" , "ハウス" ) ) ,
7580 "`クリック`.`ハウス`"
7681 ) ;
7782
78- assert_eq ! ( bind_to_string( ScopedIdentifier ( " " , " " ) ) , "` `.` `" ) ;
83+ assert_eq ! ( bind_to_string( QualifiedIdentifier ( " " , " " ) ) , "` `.` `" ) ;
7984 }
8085}
0 commit comments