ncs_mdes_warehouse 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  NCS Navigator MDES Warehouse History
2
2
  ====================================
3
3
 
4
+ 0.7.2
5
+ -----
6
+
7
+ - Correct behavior of FK index with database external key provider. (#2387)
8
+
9
+ - Remove transaction handling in SqlTransformer. (Transformers are automatically
10
+ wrapped in a transaction, so it's redundant for the transformer to do it
11
+ itself.)
12
+
4
13
  0.7.1
5
14
  -----
6
15
 
@@ -92,7 +92,7 @@ module NcsNavigator::Warehouse::Transformers
92
92
  def verify_relationship(record, belongs_to)
93
93
  reference_name = belongs_to.child_key.first.name
94
94
  reference_value = record.send(reference_name)
95
- foreign_model = belongs_to.parent_model.to_s
95
+ foreign_model = belongs_to.parent_model
96
96
 
97
97
  if reference_value && !seen?(foreign_model, reference_value)
98
98
  interim_unsatisfied << RelationshipInstance.new(
@@ -13,6 +13,8 @@ module NcsNavigator::Warehouse::Transformers
13
13
  end
14
14
 
15
15
  def existing_keys(model_class)
16
+ # validation is to help with the uses of this class in specs
17
+ fail 'model_class must be a string' unless Class === model_class
16
18
  known_keys[model_class.to_s]
17
19
  end
18
20
  end
@@ -29,6 +29,7 @@ module NcsNavigator::Warehouse::Transformers
29
29
  end
30
30
 
31
31
  extend Forwardable
32
+ include NcsNavigator::Warehouse::StringifyTrace
32
33
 
33
34
  def_delegators :@configuration, :shell, :log
34
35
  attr_reader :statements, :name
@@ -70,24 +71,23 @@ module NcsNavigator::Warehouse::Transformers
70
71
  # @return [void]
71
72
  # @param [TransformStatus] transform_status
72
73
  def transform(transform_status)
73
- NcsNavigator::Warehouse::TransformStatus.transaction do |tx|
74
- stmt_ct = statements.size
75
- statements.each_with_index do |stmt, i|
76
- log.debug("Executing SQL statement in SQL transformer: \n#{stmt}")
77
- shell.clear_line_and_say("[#{name}] Executing statement #{i + 1}/#{stmt_ct}...")
78
- begin
79
- result = adapter.execute(stmt)
80
- transform_status.record_count += result.affected_rows
81
- rescue Exception => e
82
- transform_status.transform_errors << NcsNavigator::Warehouse::TransformError.
83
- for_exception(e, "Exception while executing SQL statement \"#{stmt}\" (#{i + 1} of #{stmt_ct}).")
84
- shell.clear_line_and_say("[#{name}] Failed on #{i + 1}/#{stmt_ct}.")
85
- tx.rollback
86
- return
87
- end
74
+ stmt_ct = statements.size
75
+ statements.each_with_index do |stmt, i|
76
+ log.info("Executing SQL statement in SQL transformer: \n#{stmt}")
77
+ shell.clear_line_and_say("[#{name}] Executing statement #{i + 1}/#{stmt_ct}...")
78
+ begin
79
+ result = adapter.execute(stmt)
80
+ transform_status.record_count += result.affected_rows
81
+ log.debug("Previous statement affected #{result.affected_rows} row#{result.affected_rows == 1 ? '' : 's'}.")
82
+ rescue Exception => e
83
+ transform_status.transform_errors << NcsNavigator::Warehouse::TransformError.
84
+ for_exception(e, "Exception while executing SQL statement \"#{stmt}\" (#{i + 1} of #{stmt_ct}).")
85
+ shell.clear_line_and_say("[#{name}] Failed on #{i + 1}/#{stmt_ct}.\n")
86
+ log.error("Previous statement failed with exception.\n#{e.class}: #{e}\n#{stringify_trace(e.backtrace)}")
87
+ return
88
88
  end
89
- shell.clear_line_and_say("[#{name}] Executed #{stmt_ct} SQL statement#{stmt_ct == 1 ? '' : 's'}.")
90
89
  end
90
+ shell.clear_line_and_say("[#{name}] Executed #{stmt_ct} SQL statement#{stmt_ct == 1 ? '' : 's'}.\n")
91
91
  end
92
92
 
93
93
  private
@@ -1,5 +1,5 @@
1
1
  module NcsNavigator
2
2
  module Warehouse
3
- VERSION = '0.7.1'
3
+ VERSION = '0.7.2'
4
4
  end
5
5
  end
@@ -24,7 +24,7 @@ module NcsNavigator::Warehouse::Transformers
24
24
  end
25
25
 
26
26
  let(:fk_index) { ForeignKeyIndex.new(:existing_key_provider => key_provider) }
27
- let(:key_provider) { ForeignKeyIndex::StaticKeyProvider.new(Addr.to_s => [120, 180]) }
27
+ let(:key_provider) { ForeignKeyIndex::StaticKeyProvider.new(Addr.to_s => [120, 180], Frob.to_s => [80]) }
28
28
  let(:transform_status) { NcsNavigator::Warehouse::TransformStatus.memory_only('test') }
29
29
  let(:errors) { transform_status.transform_errors }
30
30
 
@@ -73,6 +73,15 @@ module NcsNavigator::Warehouse::Transformers
73
73
  errors.should == []
74
74
  end
75
75
 
76
+ it 'does not report for a key which is provided by the external key provider when the associated model class has not previously been referenced' do
77
+ another_index = ForeignKeyIndex.new(:existing_key_provider => key_provider)
78
+
79
+ another_index.record_and_verify(Addr.new(:id => 8, :frob_id => 80))
80
+ another_index.report_errors(transform_status)
81
+
82
+ errors.should == []
83
+ end
84
+
76
85
  describe 'when a key is never satisfied' do
77
86
  before do
78
87
  fk_index.record_and_verify(Addr.new(:frob_id => 4, :id => 1))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncs_mdes_warehouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000 Z
12
+ date: 2012-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ncs_mdes
@@ -1817,7 +1817,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1817
1817
  version: '0'
1818
1818
  segments:
1819
1819
  - 0
1820
- hash: 614804368533218739
1820
+ hash: -207131653451212377
1821
1821
  required_rubygems_version: !ruby/object:Gem::Requirement
1822
1822
  none: false
1823
1823
  requirements:
@@ -1826,7 +1826,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1826
1826
  version: '0'
1827
1827
  segments:
1828
1828
  - 0
1829
- hash: 614804368533218739
1829
+ hash: -207131653451212377
1830
1830
  requirements: []
1831
1831
  rubyforge_project:
1832
1832
  rubygems_version: 1.8.24