Sha256: a1bac7440b1d3f56441be728bf73851c680fd988482b491649af6ae405d20b1a

Contents?: true

Size: 519 Bytes

Versions: 5

Compression:

Stored size: 519 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].gt(at_value).or(to[:eff_to].eq(TemporalTables::END_OF_TIME)))
          .and(to[:eff_from].lteq(at_value))
      end
      join
    end
  end
end

Arel::Table.prepend TemporalTables::ArelTable

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
temporal_tables-3.0.2 lib/temporal_tables/arel_table.rb
temporal_tables-3.0.1 lib/temporal_tables/arel_table.rb
temporal_tables-3.0.0 lib/temporal_tables/arel_table.rb
temporal_tables-3.0.0.pre.rc.1 lib/temporal_tables/arel_table.rb
temporal_tables-2.0.0 lib/temporal_tables/arel_table.rb