@@ -35,7 +35,7 @@ use postgres::error::{PgConnectDbError,
3535 InvalidCatalogName ,
3636 PgWrongTransaction ,
3737 CardinalityViolation } ;
38- use postgres:: types:: { PgInt4 , PgVarchar , ToSql } ;
38+ use postgres:: types:: { PgInt4 , PgVarchar } ;
3939
4040macro_rules! or_fail(
4141 ( $e: expr) => (
@@ -108,7 +108,7 @@ fn test_transaction_commit() {
108108 or_fail ! ( conn. execute( "CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)" , [ ] ) ) ;
109109
110110 let trans = or_fail ! ( conn. transaction( ) ) ;
111- or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , [ & 1i32 as & ToSql ] ) ) ;
111+ or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , & [ & 1i32 ] ) ) ;
112112 trans. set_commit ( ) ;
113113 drop ( trans) ;
114114
@@ -124,7 +124,7 @@ fn test_transaction_commit_finish() {
124124 or_fail ! ( conn. execute( "CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)" , [ ] ) ) ;
125125
126126 let trans = or_fail ! ( conn. transaction( ) ) ;
127- or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , [ & 1i32 as & ToSql ] ) ) ;
127+ or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , & [ & 1i32 ] ) ) ;
128128 trans. set_commit ( ) ;
129129 assert ! ( trans. finish( ) . is_ok( ) ) ;
130130
@@ -140,7 +140,7 @@ fn test_transaction_commit_method() {
140140 or_fail ! ( conn. execute( "CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)" , [ ] ) ) ;
141141
142142 let trans = or_fail ! ( conn. transaction( ) ) ;
143- or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , [ & 1i32 as & ToSql ] ) ) ;
143+ or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , & [ & 1i32 ] ) ) ;
144144 assert ! ( trans. commit( ) . is_ok( ) ) ;
145145
146146 let stmt = or_fail ! ( conn. prepare( "SELECT * FROM foo" ) ) ;
@@ -154,10 +154,10 @@ fn test_transaction_rollback() {
154154 let conn = or_fail ! ( PostgresConnection :: connect( "postgres://postgres@localhost" , & NoSsl ) ) ;
155155 or_fail ! ( conn. execute( "CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)" , [ ] ) ) ;
156156
157- or_fail ! ( conn. execute( "INSERT INTO foo (id) VALUES ($1)" , [ & 1i32 as & ToSql ] ) ) ;
157+ or_fail ! ( conn. execute( "INSERT INTO foo (id) VALUES ($1)" , & [ & 1i32 ] ) ) ;
158158
159159 let trans = or_fail ! ( conn. transaction( ) ) ;
160- or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , [ & 2i32 as & ToSql ] ) ) ;
160+ or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , & [ & 2i32 ] ) ) ;
161161 drop ( trans) ;
162162
163163 let stmt = or_fail ! ( conn. prepare( "SELECT * FROM foo" ) ) ;
@@ -171,10 +171,10 @@ fn test_transaction_rollback_finish() {
171171 let conn = or_fail ! ( PostgresConnection :: connect( "postgres://postgres@localhost" , & NoSsl ) ) ;
172172 or_fail ! ( conn. execute( "CREATE TEMPORARY TABLE foo (id INT PRIMARY KEY)" , [ ] ) ) ;
173173
174- or_fail ! ( conn. execute( "INSERT INTO foo (id) VALUES ($1)" , [ & 1i32 as & ToSql ] ) ) ;
174+ or_fail ! ( conn. execute( "INSERT INTO foo (id) VALUES ($1)" , & [ & 1i32 ] ) ) ;
175175
176176 let trans = or_fail ! ( conn. transaction( ) ) ;
177- or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , [ & 2i32 as & ToSql ] ) ) ;
177+ or_fail ! ( trans. execute( "INSERT INTO foo (id) VALUES ($1)" , & [ & 2i32 ] ) ) ;
178178 assert ! ( trans. finish( ) . is_ok( ) ) ;
179179
180180 let stmt = or_fail ! ( conn. prepare( "SELECT * FROM foo" ) ) ;
@@ -373,7 +373,7 @@ fn test_query() {
373373 let conn = or_fail ! ( PostgresConnection :: connect( "postgres://postgres@localhost" , & NoSsl ) ) ;
374374 or_fail ! ( conn. execute( "CREATE TEMPORARY TABLE foo (id BIGINT PRIMARY KEY)" , [ ] ) ) ;
375375 or_fail ! ( conn. execute( "INSERT INTO foo (id) VALUES ($1), ($2)" ,
376- [ & 1i64 as & ToSql , & 2i64 as & ToSql ] ) ) ;
376+ & [ & 1i64 , & 2i64 ] ) ) ;
377377 let stmt = or_fail ! ( conn. prepare( "SELECT * from foo ORDER BY id" ) ) ;
378378 let result = or_fail ! ( stmt. query( [ ] ) ) ;
379379
@@ -415,7 +415,7 @@ fn test_lazy_query() {
415415 let stmt = or_fail ! ( trans. prepare( "INSERT INTO foo (id) VALUES ($1)" ) ) ;
416416 let values = vec ! ( 0i32 , 1 , 2 , 3 , 4 , 5 ) ;
417417 for value in values. iter ( ) {
418- or_fail ! ( stmt. execute( [ value as & ToSql ] ) ) ;
418+ or_fail ! ( stmt. execute( & [ value] ) ) ;
419419 }
420420 let stmt = or_fail ! ( trans. prepare( "SELECT id FROM foo ORDER BY id" ) ) ;
421421 let result = or_fail ! ( trans. lazy_query( & stmt, [ ] , 2 ) ) ;
@@ -460,15 +460,15 @@ fn test_execute_counts() {
460460 b INT
461461 )" , [ ] ) ) ) ;
462462 assert_eq ! ( 3 , or_fail!( conn. execute( "INSERT INTO foo (b) VALUES ($1), ($2), ($2)" ,
463- [ & 1i32 as & ToSql , & 2i32 as & ToSql ] ) ) ) ;
463+ & [ & 1i32 , & 2i32 ] ) ) ) ;
464464 assert_eq ! ( 2 , or_fail!( conn. execute( "UPDATE foo SET b = 0 WHERE b = 2" , [ ] ) ) ) ;
465465 assert_eq ! ( 3 , or_fail!( conn. execute( "SELECT * FROM foo" , [ ] ) ) ) ;
466466}
467467
468468#[ test]
469469fn test_wrong_param_type ( ) {
470470 let conn = or_fail ! ( PostgresConnection :: connect( "postgres://postgres@localhost" , & NoSsl ) ) ;
471- match conn. execute ( "SELECT $1::VARCHAR" , [ & 1i32 as & ToSql ] ) {
471+ match conn. execute ( "SELECT $1::VARCHAR" , & [ & 1i32 ] ) {
472472 Err ( PgWrongType ( _) ) => { }
473473 res => fail ! ( "unexpected result {}" , res)
474474 }
@@ -477,7 +477,7 @@ fn test_wrong_param_type() {
477477#[ test]
478478fn test_too_few_params ( ) {
479479 let conn = or_fail ! ( PostgresConnection :: connect( "postgres://postgres@localhost" , & NoSsl ) ) ;
480- match conn. execute ( "SELECT $1::INT, $2::INT" , [ & 1i32 as & ToSql ] ) {
480+ match conn. execute ( "SELECT $1::INT, $2::INT" , & [ & 1i32 ] ) {
481481 Err ( PgWrongParamCount { expected : 2 , actual : 1 } ) => { } ,
482482 res => fail ! ( "unexpected result {}" , res)
483483 }
@@ -486,7 +486,7 @@ fn test_too_few_params() {
486486#[ test]
487487fn test_too_many_params ( ) {
488488 let conn = or_fail ! ( PostgresConnection :: connect( "postgres://postgres@localhost" , & NoSsl ) ) ;
489- match conn. execute ( "SELECT $1::INT, $2::INT" , [ & 1i32 as & ToSql , & 2i32 as & ToSql , & 3i32 as & ToSql ] ) {
489+ match conn. execute ( "SELECT $1::INT, $2::INT" , & [ & 1i32 , & 2i32 , & 3i32 ] ) {
490490 Err ( PgWrongParamCount { expected : 2 , actual : 3 } ) => { } ,
491491 res => fail ! ( "unexpected result {}" , res)
492492 }
0 commit comments