Sha256: d1c2b830f60985190b619f2d2fedd750bf882441f984243aa16a00374f20198b

Contents?: true

Size: 473 Bytes

Versions: 4

Compression:

Stored size: 473 Bytes

Contents

# frozen_string_literal: true

module TemporalTables
  # This is required for eager_load to work
  module ArelTable
    def create_join(to, constraint = nil, klass = Arel::Nodes::InnerJoin)
      join = super
      at_value = Thread.current[:at_time]
      if at_value
        join =
          join
          .and(to[:eff_to].gteq(at_value))
          .and(to[:eff_from].lteq(at_value))
      end
      join
    end
  end
end

Arel::Table.prepend TemporalTables::ArelTable

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
temporal_tables-1.1.0 lib/temporal_tables/arel_table.rb
temporal_tables-1.0.3 lib/temporal_tables/arel_table.rb
temporal_tables-1.0.2 lib/temporal_tables/arel_table.rb
temporal_tables-1.0.1 lib/temporal_tables/arel_table.rb