@@ -140,52 +140,12 @@ impl Statement<'_> {
140140 pub fn column_type ( & self , idx : usize ) -> DataType {
141141 self . stmt . column_type ( idx)
142142 }
143-
144- /// Returns a slice describing the columns of the result of the query.
145- ///
146- /// If associated DB schema can be altered concurrently, you should make
147- /// sure that current statement has already been stepped once before
148- /// calling this method.
149- #[ cfg( feature = "column_decltype" ) ]
150- pub fn columns ( & self ) -> Vec < Column < ' _ > > {
151- let n = self . column_count ( ) ;
152- let mut cols = Vec :: with_capacity ( n) ;
153- for i in 0 ..n {
154- let name = self . column_name_unwrap ( i) ;
155- let slice = self . stmt . column_decltype ( i) ;
156- let decl_type =
157- slice. map ( |s| str:: from_utf8 ( s. to_bytes ( ) ) . expect ( "Invalid UTF-8 sequence in column declaration" ) ) ;
158- cols. push ( Column { name, decl_type } ) ;
159- }
160- cols
161- }
162143}
163144
164145#[ cfg( test) ]
165146mod test {
166147 use crate :: { Connection , Result } ;
167148
168- #[ test]
169- #[ cfg( feature = "column_decltype" ) ]
170- fn test_columns ( ) -> Result < ( ) > {
171- use super :: Column ;
172-
173- let db = Connection :: open_in_memory ( ) ?;
174- let query = db. prepare ( "SELECT * FROM sqlite_master" ) ?;
175- let columns = query. columns ( ) ;
176- let column_names: Vec < & str > = columns. iter ( ) . map ( Column :: name) . collect ( ) ;
177- assert_eq ! (
178- column_names. as_slice( ) ,
179- & [ "type" , "name" , "tbl_name" , "rootpage" , "sql" ]
180- ) ;
181- let column_types: Vec < Option < & str > > = columns. iter ( ) . map ( Column :: decl_type) . collect ( ) ;
182- assert_eq ! (
183- & column_types[ ..3 ] ,
184- & [ Some ( "VARCHAR" ) , Some ( "VARCHAR" ) , Some ( "VARCHAR" ) , ]
185- ) ;
186- Ok ( ( ) )
187- }
188-
189149 #[ test]
190150 fn test_column_name_in_error ( ) -> Result < ( ) > {
191151 use crate :: { types:: Type , Error } ;
0 commit comments