Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods that take iterators of parameters #458

Merged
merged 1 commit into from
Jul 10, 2019
Merged

Conversation

sfackler
Copy link
Owner

The existing methods which take slices of parameters work well when
directly passing a temporary slice (e.g. c.query(s, &[&15, &"hi"]),
but becomes limiting in other contexts like when programmatically
building up a query. We now offer methods which take iterators, which
are significantly more flexible for these kinds of use cases.

Because of the weird object safety of ToSql, we can't be generic over
Iterator<Item = impl ToSql>, but instead have to specifically work
with Iterator<Item = &dyn ToSql>. This may require a .map() or two
but should still work fine.

Closes #265

The existing methods which take slices of parameters work well when
directly passing a temporary slice (e.g. `c.query(s, &[&15, &"hi"])`,
but becomes limiting in other contexts like when programmatically
building up a query. We now offer methods which take iterators, which
are significantly more flexible for these kinds of use cases.

Because of the weird object safety of `ToSql`, we can't be generic over
`Iterator<Item = impl ToSql>`, but instead have to specifically work
with `Iterator<Item = &dyn ToSql>`. This may require a `.map()` or two
but should still work fine.

Closes #265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Take IntoIterator rather than &[&ToSql].
1 participant