Sha256: a225590910954354b58cdfc017ad00731b3d3219a7c28997e1fb3d79b0d8acc6
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
# rubocop:disable Naming/MethodName # rubocop:disable Naming/UncommunicativeMethodParamName module Arel module Nodes # https://www.postgresql.org/docs/10/sql-delete.html class DeleteStatement module DeleteStatementExtension attr_accessor :using attr_accessor :with attr_accessor :returning def initialize(relation = nil, wheres = []) super @returning = [] end end prepend DeleteStatementExtension end end module Visitors class ToSql # rubocop:disable Metrics/AbcSize def visit_Arel_Nodes_DeleteStatement(o, collector) if o.with collector = visit o.with, collector collector << SPACE end collector << 'DELETE FROM ' collector = visit o.relation, collector if o.using collector << ' USING ' collector = inject_join o.using, collector, ', ' end if o.wheres.any? collector << WHERE collector = inject_join o.wheres, collector, AND end unless o.returning.empty? collector << ' RETURNING ' collector = inject_join o.returning, collector, ', ' end maybe_visit o.limit, collector end # rubocop:enable Metrics/AbcSize end class Dot module DeleteStatementExtension def visit_Arel_Nodes_DeleteStatement(o) super visit_edge o, 'using' visit_edge o, 'with' visit_edge o, 'returning' end end prepend(DeleteStatementExtension) end end end # rubocop:enable Naming/MethodName # rubocop:enable Naming/UncommunicativeMethodParamName
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
arel_toolkit-0.4.2 | lib/arel/extensions/delete_statement.rb |
arel_toolkit-0.4.1 | lib/arel/extensions/delete_statement.rb |
arel_toolkit-0.4.0 | lib/arel/extensions/delete_statement.rb |