lib/etl/control/destination.rb in activewarehouse-etl-0.9.5.rc1 vs lib/etl/control/destination.rb in activewarehouse-etl-1.0.0.rc1
- old
+ new
@@ -92,20 +92,11 @@
@generators ||= {}
end
# Get the order of elements from the source order
def order_from_source
- order = []
- control.sources.first.definition.each do |item|
- case item
- when Hash
- order << item[:name]
- else
- order << item
- end
- end
- order
+ control.sources.first.order
end
# Return true if the row is allowed. The row will not be allowed if the
# :unique option is specified in the configuration and the compound key
# already exists
@@ -133,11 +124,11 @@
@scd_fields
end
# returns the fields that are required to identify an SCD
def scd_required_fields
- if scd?
+ if scd? and scd_type == 2
[scd_effective_date_field, scd_end_date_field, scd_latest_version_field]
else
[]
end
end
@@ -247,11 +238,11 @@
generator = generators[key] ||= value.new
row[key] = generator.next
when Symbol
generator = generators[key] ||= ETL::Generator::Generator.class_for_name(value).new(options)
row[key] = generator.next
- when Proc
+ when Proc, Method
row[key] = value.call(row)
else
if value.is_a?(ETL::Generator::Generator)
row[key] = value.next
else
@@ -286,15 +277,13 @@
# by a natural key
def natural_key_equality_for_row(row)
statement = []
values = []
natural_key.each do |nk|
- statement << "#{nk} = ?"
- values << row[nk]
+ statement << "#{nk} = #{ActiveRecord::Base.send(:quote_bound_value, row[nk], connection)}"
end
statement = statement.join(" AND ")
- x=ActiveRecord::Base.send(:sanitize_sql_array, [statement, *values])
- return x
+ return statement
end
# Do all the steps required when a SCD *has* changed. Exact steps
# depend on what type of SCD we're handling.
def process_scd_change(row)