1010/// Default batch size for lazy row fetching (channel buffer size).
1111pub const DEFAULT_BATCH_SIZE : usize = 100 ;
1212
13- /// Generates a database-specific QueryResult implementation with lazy streaming.
13+ /// Generates a database-specific ` QueryResult` implementation with lazy streaming.
1414///
15- /// The generated QueryResult implements PHP's `Iterator` interface,
15+ /// The generated ` QueryResult` implements PHP's `Iterator` interface,
1616/// receiving rows from a background streaming task as iteration progresses.
1717///
1818/// # Arguments
1919///
2020/// - `$struct` - The Rust struct name for the query result (e.g., `PgQueryResult`)
2121/// - `$class` - The PHP class name as a string literal (e.g., `"Sqlx\\PgQueryResult"`)
22- /// - `$database` - The SQLx database type (e.g., `Postgres`)
22+ /// - `$database` - The ` SQLx` database type (e.g., `Postgres`)
2323/// - `$inner` - The inner driver type
2424#[ macro_export]
2525macro_rules! php_sqlx_impl_query_result {
2626 ( $struct: ident, $class: literal, $database: ident, $inner: ident ) => {
2727 use ext_php_rs:: prelude:: * ;
2828 use ext_php_rs:: types:: Zval ;
2929 use ext_php_rs:: zend:: ce;
30+ use saturating_cast:: SaturatingCast ;
3031
3132 /// A lazy query result iterator that streams rows on demand.
3233 ///
@@ -48,7 +49,10 @@ macro_rules! php_sqlx_impl_query_result {
4849 pub struct $struct {
4950 /// Channel receiver for streaming rows from background task
5051 receiver: tokio:: sync:: mpsc:: Receiver <
51- Result <<sqlx_oldapi:: $database as sqlx_oldapi:: Database >:: Row , $crate:: error:: Error >
52+ Result <
53+ <sqlx_oldapi:: $database as sqlx_oldapi:: Database >:: Row ,
54+ $crate:: error:: Error ,
55+ >,
5256 >,
5357 /// Current row (converted to Zval)
5458 current: Option <Zval >,
@@ -69,11 +73,14 @@ macro_rules! php_sqlx_impl_query_result {
6973 }
7074
7175 impl $struct {
72- /// Creates a new streaming QueryResult.
76+ /// Creates a new streaming ` QueryResult` .
7377 #[ allow( dead_code) ]
7478 pub fn new(
7579 receiver: tokio:: sync:: mpsc:: Receiver <
76- Result <<sqlx_oldapi:: $database as sqlx_oldapi:: Database >:: Row , $crate:: error:: Error >
80+ Result <
81+ <sqlx_oldapi:: $database as sqlx_oldapi:: Database >:: Row ,
82+ $crate:: error:: Error ,
83+ >,
7784 >,
7885 associative_arrays: bool ,
7986 buffer_size: usize ,
@@ -178,7 +185,7 @@ macro_rules! php_sqlx_impl_query_result {
178185 /// Note: This returns the count of rows fetched, not the total
179186 /// result set size (which may not be known until iteration completes).
180187 pub fn count( & self ) -> i64 {
181- self . total_fetched as i64
188+ self . total_fetched. saturating_cast :: < i64 > ( )
182189 }
183190
184191 /// Returns true if the result set has been fully consumed.
@@ -188,13 +195,14 @@ macro_rules! php_sqlx_impl_query_result {
188195
189196 /// Returns the configured buffer size for streaming.
190197 pub fn get_batch_size( & self ) -> i64 {
191- self . buffer_size as i64
198+ self . buffer_size. saturating_cast :: < i64 > ( )
192199 }
193200
194201 /// Consumes all remaining rows and returns them as an array.
195202 ///
196203 /// This will fetch all remaining rows from the stream.
197204 /// Use with caution on large result sets.
205+ #[ allow( clippy:: wrong_self_convention) ]
198206 pub fn to_array( & mut self ) -> $crate:: error:: Result <Vec <Zval >> {
199207 let mut all_rows = Vec :: new( ) ;
200208
0 commit comments