@@ -90,7 +90,7 @@ pub async fn list_rows_handler(
9090
9191 let cursor_column = table_or_view. record_pk_column ( ) ;
9292 let cursor = match ( cursor, cursor_column) {
93- ( Some ( cursor) , Some ( ( _idx , c ) ) ) => Some ( parse_cursor ( & cursor, c ) ?) ,
93+ ( Some ( cursor) , Some ( meta ) ) => Some ( parse_cursor ( & cursor, & meta . column ) ?) ,
9494 _ => None ,
9595 } ;
9696 let ( rows, columns) = fetch_rows (
@@ -99,7 +99,7 @@ pub async fn list_rows_handler(
9999 filter_where_clause,
100100 & order,
101101 Pagination {
102- cursor_column : cursor_column. map ( |( _idx , c ) | c ) ,
102+ cursor_column : cursor_column. map ( |meta| & meta . column ) ,
103103 cursor,
104104 offset,
105105 limit : limit_or_default ( limit, None ) . map_err ( |err| Error :: BadRequest ( err. into ( ) ) ) ?,
@@ -108,10 +108,10 @@ pub async fn list_rows_handler(
108108 . await ?;
109109
110110 let next_cursor = if order. is_none ( ) {
111- cursor_column. and_then ( |( col_idx , _col ) | {
111+ cursor_column. and_then ( |meta | {
112112 let row = rows. last ( ) ?;
113- assert ! ( row. len( ) > col_idx ) ;
114- match & row[ col_idx ] {
113+ assert ! ( row. len( ) > meta . index ) ;
114+ match & row[ meta . index ] {
115115 SqlValue :: Integer ( n) => Some ( n. to_string ( ) ) ,
116116 SqlValue :: Blob ( b) => {
117117 // Should be a base64 encoded [u8; 16] id.
@@ -130,7 +130,10 @@ pub async fn list_rows_handler(
130130 // NOTE: in the view case we don't have a good way of extracting the columns from the "CREATE
131131 // VIEW" query so we fall back to columns constructed from the returned data.
132132 columns : match table_or_view. columns ( ) {
133- Some ( schema_columns) if !schema_columns. is_empty ( ) => schema_columns. to_vec ( ) ,
133+ Some ( schema_columns) if !schema_columns. is_empty ( ) => schema_columns
134+ . iter ( )
135+ . map ( |meta| meta. column . clone ( ) )
136+ . collect ( ) ,
134137 _ => {
135138 // VIRTUAL TABLE or VIEW case.
136139 debug ! ( "Falling back to inferred cols for view: {table_name:?}" ) ;
0 commit comments