Sha256: 07d40445da46008e5bd0f67e8965b1742daea129b30819997feb8de3e0a1a44c
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:, 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(manifest, directive).call end def fetch_has_many(directive) TableSaw::DependencyGraph::HasManyDirectives.new(manifest, directive).call end def primary_key TableSaw.schema_cache.primary_keys(name) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
table_saw-3.2.0 | lib/table_saw/dependency_graph/dump_table.rb |