File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -573,6 +573,9 @@ impl<'self> NormalPostgresStatement<'self> {
573
573
-> Option < PostgresDbError > {
574
574
let mut formats = ~[ ] ;
575
575
let mut values = ~[ ] ;
576
+ assert ! ( self . param_types. len( ) == params. len( ) ,
577
+ "Expected %u parameters but found %u" ,
578
+ self . param_types. len( ) , params. len( ) ) ;
576
579
for ( & param, & ty) in params. iter ( ) . zip ( self . param_types . iter ( ) ) {
577
580
let ( format, value) = param. to_sql ( ty) ;
578
581
formats. push ( format as i16 ) ;
Original file line number Diff line number Diff line change @@ -311,6 +311,22 @@ fn test_wrong_param_type() {
311
311
conn. try_update( "SELECT $1::VARCHAR" , [ & 1i32 as & ToSql ] ) ;
312
312
}
313
313
314
+ #[ test]
315
+ #[ should_fail]
316
+ fn test_too_few_params( ) {
317
+ let conn = PostgresConnection :: connect( "postgres://postgres@localhost" ) ;
318
+ conn. try_update( "SELECT $1::INT, $2::INT" , [ & 1i32 as & ToSql ] ) ;
319
+ }
320
+
321
+ #[ test]
322
+ #[ should_fail]
323
+ fn test_too_many_params( ) {
324
+ let conn = PostgresConnection :: connect( "postgres://postgres@localhost" ) ;
325
+ conn. try_update( "SELECT $1::INT, $2::INT" , [ & 1i32 as & ToSql ,
326
+ & 2i32 as & ToSql ,
327
+ & 3i32 as & ToSql ] ) ;
328
+ }
329
+
314
330
#[ test]
315
331
fn test_find_col_named( ) {
316
332
let conn = PostgresConnection :: connect( "postgres://postgres@localhost" ) ;
You can’t perform that action at this time.
0 commit comments