diff --git a/docs/stripe.md b/docs/stripe.md index 17faddb8..511bbf4f 100644 --- a/docs/stripe.md +++ b/docs/stripe.md @@ -766,10 +766,6 @@ While any column is allowed in a where clause, it is most efficient to filter by - id - destination -## Limitations - -Joining local data against a Stripe FDW returns incomplete or empty results. We're tracking the [issue on GitHub](https://github.com/supabase/wrappers/issues/113) and working towards a fix. - ## Examples Some examples on how to use Stripe foreign tables. diff --git a/wrappers/src/fdw/stripe_fdw/stripe_fdw.rs b/wrappers/src/fdw/stripe_fdw/stripe_fdw.rs index 4474d8a2..dcfc091c 100644 --- a/wrappers/src/fdw/stripe_fdw/stripe_fdw.rs +++ b/wrappers/src/fdw/stripe_fdw/stripe_fdw.rs @@ -261,6 +261,7 @@ pub(crate) struct StripeFdw { scan_result: Option>, obj: String, rowid_col: String, + iter_idx: usize, } impl StripeFdw { @@ -645,6 +646,7 @@ impl ForeignDataWrapper for StripeFdw { scan_result: None, obj: String::default(), rowid_col: String::default(), + iter_idx: 0, }) } @@ -737,16 +739,20 @@ impl ForeignDataWrapper for StripeFdw { fn iter_scan(&mut self, row: &mut Row) -> StripeFdwResult> { if let Some(ref mut result) = self.scan_result { - if !result.is_empty() { - return Ok(result - .drain(0..1) - .last() - .map(|src_row| row.replace_with(src_row))); + if self.iter_idx < result.len() { + row.replace_with(result[self.iter_idx].clone()); + self.iter_idx += 1; + return Ok(Some(())); } } Ok(None) } + fn re_scan(&mut self) -> StripeFdwResult<()> { + self.iter_idx = 0; + Ok(()) + } + fn end_scan(&mut self) -> StripeFdwResult<()> { self.scan_result.take(); Ok(())