-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Description
users = [User.new(name: "John"), User.new(name: "Jake")]
users.insert == Onyx::SQL::BulkQuery(User).new.insert(users)
users.insert.build == {"INSERT INTO users (name) VALUES (?), (?)", ["John", "Jake"]}
users.delete.build == {"DELETE FROM users WHERE id IN (?, ?)", [1, 2]}This would require patching Enumerable like this:
module Enumerable(T)
def insert
{% if T < Onyx::SQL::Model %}
Onyx::SQL::BulkQuery(T).new.insert(self)
{% else %}
{% raise "Can only call argless Enumerable#insert on Enumerable(Onyx::SQL::Model)" %}
{% end %}
end
endWhich should work fine as Enumerable doesn't have #insert and #delete methods at all and other types like Array do not have these methods with zero arity.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request