@@ -3,15 +3,16 @@ use crate::column::ColumnIndex;
3
3
use crate :: database:: Database ;
4
4
use crate :: error:: Error ;
5
5
use crate :: ext:: ustr:: UStr ;
6
+ use crate :: sql_str:: SqlStr ;
6
7
use crate :: statement:: Statement ;
7
8
use crate :: HashMap ;
8
9
use either:: Either ;
9
- use std:: borrow:: Cow ;
10
10
use std:: sync:: Arc ;
11
11
12
- pub struct AnyStatement < ' q > {
12
+ #[ derive( Clone ) ]
13
+ pub struct AnyStatement {
13
14
#[ doc( hidden) ]
14
- pub sql : Cow < ' q , str > ,
15
+ pub sql : SqlStr ,
15
16
#[ doc( hidden) ]
16
17
pub parameters : Option < Either < Vec < AnyTypeInfo > , usize > > ,
17
18
#[ doc( hidden) ]
@@ -20,19 +21,14 @@ pub struct AnyStatement<'q> {
20
21
pub columns : Vec < AnyColumn > ,
21
22
}
22
23
23
- impl < ' q > Statement < ' q > for AnyStatement < ' q > {
24
+ impl Statement for AnyStatement {
24
25
type Database = Any ;
25
26
26
- fn to_owned ( & self ) -> AnyStatement < ' static > {
27
- AnyStatement :: < ' static > {
28
- sql : Cow :: Owned ( self . sql . clone ( ) . into_owned ( ) ) ,
29
- column_names : self . column_names . clone ( ) ,
30
- parameters : self . parameters . clone ( ) ,
31
- columns : self . columns . clone ( ) ,
32
- }
27
+ fn into_sql ( self ) -> SqlStr {
28
+ self . sql
33
29
}
34
30
35
- fn sql ( & self ) -> & str {
31
+ fn sql ( & self ) -> & SqlStr {
36
32
& self . sql
37
33
}
38
34
@@ -51,8 +47,8 @@ impl<'q> Statement<'q> for AnyStatement<'q> {
51
47
impl_statement_query ! ( AnyArguments <' _>) ;
52
48
}
53
49
54
- impl ColumnIndex < AnyStatement < ' _ > > for & ' _ str {
55
- fn index ( & self , statement : & AnyStatement < ' _ > ) -> Result < usize , Error > {
50
+ impl ColumnIndex < AnyStatement > for & ' _ str {
51
+ fn index ( & self , statement : & AnyStatement ) -> Result < usize , Error > {
56
52
statement
57
53
. column_names
58
54
. get ( * self )
@@ -61,15 +57,14 @@ impl ColumnIndex<AnyStatement<'_>> for &'_ str {
61
57
}
62
58
}
63
59
64
- impl < ' q > AnyStatement < ' q > {
60
+ impl AnyStatement {
65
61
#[ doc( hidden) ]
66
62
pub fn try_from_statement < S > (
67
- query : & ' q str ,
68
- statement : & S ,
63
+ statement : S ,
69
64
column_names : Arc < HashMap < UStr , usize > > ,
70
65
) -> crate :: Result < Self >
71
66
where
72
- S : Statement < ' q > ,
67
+ S : Statement ,
73
68
AnyTypeInfo : for < ' a > TryFrom < & ' a <S :: Database as Database >:: TypeInfo , Error = Error > ,
74
69
AnyColumn : for < ' a > TryFrom < & ' a <S :: Database as Database >:: Column , Error = Error > ,
75
70
{
@@ -91,7 +86,7 @@ impl<'q> AnyStatement<'q> {
91
86
. collect :: < Result < Vec < _ > , _ > > ( ) ?;
92
87
93
88
Ok ( Self {
94
- sql : query . into ( ) ,
89
+ sql : statement . into_sql ( ) ,
95
90
columns,
96
91
column_names,
97
92
parameters,
0 commit comments