@@ -78,7 +78,7 @@ impl Transaction {
78
78
Ok ( & * * self . slot . borrow ( ) . unwrap ( ) )
79
79
}
80
80
81
- fn tx < ' a > ( & ' a self ) -> CargoResult < & ' a pg :: PostgresTransaction < ' a > > {
81
+ fn tx < ' a > ( & ' a self ) -> CargoResult < & ' a Connection + ' a > {
82
82
// Similar to above, the transaction for this request is actually tied
83
83
// to the connection in the request itself, not 'static. We transmute it
84
84
// to static as its paired with the inner connection to achieve the
@@ -93,7 +93,7 @@ impl Transaction {
93
93
}
94
94
let tx = self . tx . borrow ( ) ;
95
95
let tx: & ' a pg:: PostgresTransaction < ' static > = tx. unwrap ( ) ;
96
- Ok ( tx)
96
+ Ok ( tx as & Connection )
97
97
}
98
98
}
99
99
@@ -134,7 +134,7 @@ pub trait RequestTransaction<'a> {
134
134
///
135
135
/// The transaction will live for the duration of the request, and it will
136
136
/// only be set to commit() if a successful response code of 200 is seen.
137
- fn tx ( self ) -> CargoResult < & ' a pg :: PostgresTransaction < ' a > > ;
137
+ fn tx ( self ) -> CargoResult < & ' a Connection + ' a > ;
138
138
}
139
139
140
140
impl < ' a > RequestTransaction < ' a > for & ' a Request + ' a {
@@ -144,7 +144,7 @@ impl<'a> RequestTransaction<'a> for &'a Request + 'a {
144
144
. conn ( )
145
145
}
146
146
147
- fn tx ( self ) -> CargoResult < & ' a pg :: PostgresTransaction < ' a > > {
147
+ fn tx ( self ) -> CargoResult < & ' a Connection + ' a > {
148
148
self . extensions ( ) . find :: < Transaction > ( )
149
149
. expect ( "Transaction not present in request" )
150
150
. tx ( )
@@ -164,21 +164,14 @@ impl Connection for pg::PostgresConnection {
164
164
self . execute ( query, params)
165
165
}
166
166
}
167
- //
168
- // impl Connection for pg::pool::PooledPostgresConnection {
169
- // fn prepare<'a>(&'a self, query: &str) -> PostgresResult<PostgresStatement<'a>> {
170
- // self.prepare(query)
171
- // }
172
- // fn execute(&self, query: &str, params: &[&ToSql]) -> PostgresResult<uint> {
173
- // self.execute(query, params)
174
- // }
175
- // }
176
167
177
168
impl < ' a > Connection for pg:: PostgresTransaction < ' a > {
178
169
fn prepare < ' a > ( & ' a self , query : & str ) -> PostgresResult < PostgresStatement < ' a > > {
170
+ log ! ( 5 , "prepare: {}" , query) ;
179
171
self . prepare ( query)
180
172
}
181
173
fn execute ( & self , query : & str , params : & [ & ToSql ] ) -> PostgresResult < uint > {
174
+ log ! ( 5 , "execute: {}" , query) ;
182
175
self . execute ( query, params)
183
176
}
184
177
}
0 commit comments