Sha256: 36082734ab2f753e68a6bd89084bd163bfdde579c981029d93d7a7c305c988e3
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module TableSaw module DependencyGraph class DumpTable attr_reader :manifest, :name, :partial, :ids def initialize(manifest:, name:, partial: true) @manifest = manifest @name = name @partial = partial @ids = Set.new end def copy_statement if partial format 'select * from %{name} where %{clause}', name: name, clause: TableSaw::Queries::SerializeSqlInClause.new(name, primary_key, ids.to_a).call else "select * from #{name}" end end def fetch_associations(directive) directive.ids = directive.ids - ids.to_a ids.merge(directive.ids) fetch_belongs_to(directive) + fetch_has_many(directive) end private def fetch_belongs_to(directive) TableSaw::DependencyGraph::BelongsToDirectives.new(directive).call end def fetch_has_many(directive) TableSaw::DependencyGraph::HasManyDirectives.new(manifest, directive).call end def primary_key TableSaw.information_schema.primary_keys[name] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
table_saw-2.2.0 | lib/table_saw/dependency_graph/dump_table.rb |