Closed NeedleInAJayStack closed 2 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
3c8c6aa
) to head (e2b955b
). Report is 1 commits behind head on main.
welcome a bit of bikeshedding on the matter
I think multiValues(_:)
is a fine name. Along the same vein, allValues
seems like a reasonable option. However, I think I prefer rows(_:)
or rowValues(_:)
, since I feel like they imply that all sequences should have equal length and correspond to the column ordering.
@gwynne Sorry it took so long to get back to this one. I've adjusted it to use your implementation (which is great!), and named it rows
. Again, I'm happy to switch to multiValues
if you prefer that. Thanks!
@NeedleInAJayStack Any chance you'd be able to update this to resolve the conflicts? I'd be willing to merge it as SQLKit 3's last new feature.
Sure, I can have that done in the next day or so if that works
Hey @gwynne, I've resolved the merge conflicts and updated the tests to the new test formatting. I wasn't sure if any of the tests in the original PR were obsoleted by new work, so just let me know if you'd like any removed/organized differently. Thanks!
These changes are now available in 3.32.0
This adds functionality to do a multi-row inserts with a single
values
method call.Previously, to insert multiple rows a user had to call
values
repeatedly:This was a bit awkward when inserting rows from an array, where an instance of the builder had to be saved off and edited:
This MR simplifies the mutli-row insert situation by adding a
values
method overload that accepts a nested array:NOTE
This functionality was only added to the
SQLExpression
version ofvalues
, NOT theEncodable
version ofvalues
. There are known issues with[Encodable]
conforming toEncodable
that prevent adequate type checks.For example, if a
values(_ rows: [[Encodable]])
is defined, it is undeterministic since the same call would also matchvalues(_ rows: [Encodable])
. If instead we changevalues(_ rows: [Encodable])
to detect[[Encodable]]
cases at runtime, then it is difficult to guarantee that a caller hasn't mixedEncodable
and[Encodable]
values.