@@ -19,7 +19,7 @@ pub enum Strategy {
1919}
2020
2121/// Iterator over the `meta_key`s of a chain of nested
22- /// [`Strategy::PreferDistinct`]. outermost first. Stops at the first
22+ /// [`Strategy::PreferDistinct`], outermost first. Stops at the first
2323/// non-`PreferDistinct` strategy, which can afterwards be retrieved with
2424/// [`MetaKeysIter::take`].
2525pub struct MetaKeysIter < ' a > {
@@ -178,13 +178,25 @@ impl Strategy {
178178 }
179179 }
180180
181- /// Append a query snippet to select from the `random_order` column on the
182- /// given table using the "cutting the deck" technique.
183- fn push_random_order_query < ' a > (
181+ /// Append a query snippet to a `QueryBuilder` to select `columns` using the
182+ /// `random_order` column as a filter (the "cutting the deck" technique),
183+ /// from table `table`.
184+ ///
185+ /// ```
186+ /// use opsqueue::consumer::strategy::Strategy;
187+ /// use sqlx::{QueryBuilder, Sqlite};
188+ /// let mut qb: QueryBuilder<Sqlite> = QueryBuilder::new("");
189+ /// Strategy::push_random_order_query(&mut qb, "id, name", "users", Some("status = 'active'"));
190+ /// let expected_sql = "SELECT id, name FROM users WHERE random_order >= ? AND status = 'active' \
191+ /// UNION ALL \
192+ /// SELECT id, name FROM users WHERE random_order < ? AND status = 'active'";
193+ /// assert_eq!(qb.sql(), expected_sql);
194+ /// ```
195+ pub fn push_random_order_query < ' a > (
184196 qb : & ' a mut QueryBuilder < Sqlite > ,
185- columns : & str ,
186- table_name : & str ,
187- condition : Option < & str > ,
197+ columns : & ' static str ,
198+ table_name : & ' static str ,
199+ condition : Option < & ' static str > ,
188200 ) -> & ' a mut QueryBuilder < Sqlite > {
189201 let random_offset: u16 = rand:: random ( ) ;
190202 let push_select = |qb : & mut QueryBuilder < Sqlite > , operator : & str | {
0 commit comments