File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1521,7 +1521,7 @@ pub trait RowIndex {
15211521impl RowIndex for uint {
15221522 #[ inline]
15231523 fn idx ( & self , stmt : & Statement ) -> Option < uint > {
1524- if * self > stmt. result_desc . len ( ) {
1524+ if * self >= stmt. result_desc . len ( ) {
15251525 None
15261526 } else {
15271527 Some ( * self )
Original file line number Diff line number Diff line change @@ -540,6 +540,18 @@ fn test_get_was_null() {
540540 } ;
541541}
542542
543+ #[ test]
544+ fn test_get_off_by_one ( ) {
545+ let conn = or_panic ! ( Connection :: connect( "postgres://postgres@localhost" , & SslMode :: None ) ) ;
546+ let stmt = or_panic ! ( conn. prepare( "SELECT 10::INT as id" ) ) ;
547+ let mut result = or_panic ! ( stmt. query( & [ ] ) ) ;
548+
549+ match result. next ( ) . unwrap ( ) . get_opt :: < uint , i32 > ( 1 ) {
550+ Err ( Error :: InvalidColumn ) => { }
551+ res => panic ! ( "unexpected result {}" , res) ,
552+ } ;
553+ }
554+
543555#[ test]
544556fn test_custom_notice_handler ( ) {
545557 static mut count: uint = 0 ;
You can’t perform that action at this time.
0 commit comments