Sha256: ad53a1f377b7a0cd271c4d5609c561861db3746f7d42abee498670e9cb0bb196
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module ActiveRecord module Dbt module DbtPackage module DbtUtils module Table module Testable module UniqueCombinationOfColumnsTestable REQUIRED_UNIQUE_COMBINATION_OF_COLUMNS_TESTABLE_METHODS = %i[table_name @config].freeze delegate :used_dbt_utils?, to: :@config REQUIRED_UNIQUE_COMBINATION_OF_COLUMNS_TESTABLE_METHODS.each do |method_name| define_method(method_name) do raise NotImplementedError, "You must implement #{self.class}##{__method__}" end end def unique_combination_of_columns_test return nil unless used_dbt_utils? ActiveRecord::Base.connection.indexes(table_name).each_with_object([]) do |index, array| next if index.unique == false next if (unique_indexes = index.columns).size == 1 array.push( { 'dbt_utils.unique_combination_of_columns' => { 'combination_of_columns' => unique_indexes } } ) end.presence end end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord-dbt-0.1.0 | lib/active_record/dbt/dbt_package/dbt_utils/table/testable/unique_combination_of_columns_testable.rb |