This is my temporary patch for that:
module Patches
module SequelTransaction
DUMMY_TRANSACTION = ->(_, &block) { block.call }.freeze
def _import(columns, values, opts)
trans_opts = Hash[opts].merge!(server: @opts[:server])
trans = trans_opts.fetch(:transaction) { true }
trans_meth = trans ? @db.method(:transaction) : DUMMY_TRANSCATION
if opts[:return] == :primary_key
trans_meth.call(trans_opts){ values.map { |v| insert(columns, v) } }
else
stmts = multi_insert_sql(columns, values)
trans_meth.call(trans_opts){ stmts.each { |st| execute_dui(st) } }
end
end
end
end
Sequel::Dataset.prepend(Patches::SequelTransaction)
W dniu środa, 30 stycznia 2019 23:06:52 UTC+1 użytkownik Jeremy Evans
napisał:
>
> On Wednesday, January 30, 2019 at 12:50:43 PM UTC-8, Nikita Shilnikov
> wrote:
>>
>> Hello,
>>
>> It seems to me starting a new transaction in PG isn't necessary since it
>> will be executed as a single SQL statement
>> https://github.com/jeremyevans/sequel/blob/bd1e06f8b16c7311080c699e85080648ff14e602/lib/sequel/adapters/shared/postgres.rb#L1732
>> Is
>> it something to improve?
>>
>
> Dataset#multi_insert / #import could potentially not use an transaction if
> only a single query was required. However, transactions are currently used
> for all cases, and all options given are currently passed to
> Database#transaction. I think the best way to skip a transaction in a
> backwards compatible manner would be to add a new option explicitly for
> that approach.
>
> Note that this isn't a PostgreSQL-specific issue, this applies to all
> adapters.
>
> Thanks,
> Jeremy
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.