Class: Linkage::Expectations::Match
- Inherits:
-
Simple
- Object
- Linkage::Expectation
- Simple
- Linkage::Expectations::Match
- Defined in:
- lib/linkage/expectations/simple.rb
Constant Summary
Constants inherited from Simple
Instance Attribute Summary
Attributes inherited from Simple
#meta_object_1, #meta_object_2, #operator, #side
Instance Method Summary collapse
Methods inherited from Simple
create, #decollation_needed?, #exactly!, #initialize, #same_except_side?
Methods inherited from Linkage::Expectation
Constructor Details
This class inherits a constructor from Linkage::Expectations::Simple
Instance Method Details
#apply_to(dataset, side) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/linkage/expectations/simple.rb', line 123 def apply_to(dataset, side) target = if @meta_object_1.side == side @meta_object_1 elsif @meta_object_2.side == side @meta_object_2 else raise ArgumentError, "Invalid `side` argument: #{side}" end dataset.group_match_more({ :meta_object => target, :alias => merged_field.name }) end |
#display_warnings ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/linkage/expectations/simple.rb', line 143 def display_warnings object_1 = @meta_object_1.object object_2 = @meta_object_2.object if object_1.ruby_type[:type] == String && object_2.ruby_type[:type] == String if @meta_object_1.dataset.database_type != @meta_object_2.dataset.database_type warn "NOTE: You are comparing two string fields (#{object_1.name} and #{object_2.name}) from different databases. This may result in unexpected results, as different databases compare strings differently. Consider using the =binary= function." elsif object_1.respond_to?(:collation) && object_1.respond_to?(:collation) && object_1.collation != object_2.collation warn "NOTE: The two string fields you are comparing (#{object_1.name} and #{object_2.name}) have different collations (#{ldata.collation} vs. #{rdata.collation}). This may result in unexpected results, as the database may compare them differently. Consider using the =exactly= method." end end end |
#merged_field ⇒ Object
139 140 141 |
# File 'lib/linkage/expectations/simple.rb', line 139 def merged_field @merged_field ||= @meta_object_1.merge(@meta_object_2) end |