activefacts-compositions 1.9.12 → 1.9.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ca6ad3d9944b1f64ffde699ef36bd7b26764b0e
4
- data.tar.gz: 352761a4484292f70eeb90763d7518c892d9a562
3
+ metadata.gz: dd751029f078742f721c3a77358540eaacb549f1
4
+ data.tar.gz: f061fe150616c84bc70f169f6151838147b77a95
5
5
  SHA512:
6
- metadata.gz: ee1a8f1fe902ab61728c16adadedb68fe4bc2b40339d478c9b1d59e27d73c14a57c4d760a6cd61787b3eb0fe86cd9dc24da0c03bcb3609893b62967e4a6bc1bb
7
- data.tar.gz: f979de0913251692a2be5c7f115ce9d81fb58147c04af65746fd1e4574723513bd99f877fa0409df316fa8aa94ecf28c37498f6477432ca862d4a912129df761
6
+ metadata.gz: 128bdf31ffb389014a8cc059f13ee5178b1960615a1ba2bebb9bf304b4920269bf0616f1ecccbbaf5e1f6e49c0485d8bc64523758abab2f244df581eb210ace7
7
+ data.tar.gz: 4cbde3aa2f0d73b2ddc0f2bb6db69d28c3fb25c4ca91da50797a66e548a224e29a6c02ff1f1ba413970ce82f8ecb04b3fd9bd8b9a278022d6af8d39f490677e2
@@ -100,35 +100,6 @@ module ActiveFacts
100
100
  trace :binarize, "Populating #{a.inspect}"
101
101
  end
102
102
 
103
- def find_topic import_role
104
- if import = @constellation.Import.values.select{ |import| import.import_role == import_role }.first
105
- import.precursor_topic
106
- else
107
- nil
108
- end
109
- end
110
-
111
- def build_binary_mappings schema_topic
112
- trace :binarize, "Build_binary_mappings for #{schema_topic.topic_name}"
113
- if @schema_topics.key?(schema_topic)
114
- trace :binarize, "already built, skip"
115
- return
116
- end
117
- @schema_topics[schema_topic] = true
118
-
119
- # add binary mapping for all object types in this schema
120
- schema_topic.all_concept.each do |concept|
121
- if concept.object_type
122
- @binary_mappings[concept.object_type]
123
- end
124
- end
125
-
126
- # recurse through precursor schemas
127
- schema_topic.all_import.each do |import|
128
- build_binary_mappings(import.precursor_topic)
129
- end
130
- end
131
-
132
103
  def populate_references
133
104
  # A table of Mappings by object type, with a default Mapping for each:
134
105
  @binary_mappings = Hash.new do |h, object_type|
@@ -140,46 +111,16 @@ module ActiveFacts
140
111
  end
141
112
  @component_by_fact = {}
142
113
 
143
- @schema_topics = {}
144
- =begin
145
- if @option_source || @option_target
146
- import_role = @option_source ? 'source' : 'target'
147
- trace :binarize, "Build binary bindings for #{import_role} schema" do
148
- if schema_topic = find_topic(import_role)
149
- build_binary_mappings(schema_topic)
150
- else
151
- raise "Could not find #{import_role} schema"
152
- end
153
- end
154
- elsif @option_transform
155
- trace :binarize, "Build binary bindings for transform schema" do
156
- transform_topic = @constellation.Topic.values.select do |topic|
157
- nr_importers = @constellation.Import.values.select{|i| i.precursor_topic == topic}.size
158
- nr_importers == 0 # This topic is not imported by anything, it's the one
159
- end.first
160
-
161
- # add binary mapping for all object types in the transform schema
162
- transform_topic.all_concept.each do |concept|
163
- if concept.object_type
164
- @binary_mappings[concept.object_type]
165
- end
166
- end
114
+ trace :binarize, "Build binary bindings for full schema" do
115
+ @constellation.ObjectType.each do |key, object_type|
116
+ @binary_mappings[object_type] # Ensure we create the top Mapping even if it has no references
167
117
  end
168
- else
169
- =end
170
- trace :binarize, "Build binary bindings for full schema" do
171
- @constellation.ObjectType.each do |key, object_type|
172
- @binary_mappings[object_type] # Ensure we create the top Mapping even if it has no references
173
- end
174
- end
175
- # end
118
+ end
176
119
 
177
120
  @binary_mappings.each do |object_type, mapping|
178
121
  trace :binarize, "Populating possible absorptions for #{object_type.name}" do
179
122
 
180
123
  object_type.all_role.each do |role|
181
- # Exclude fact types not in @schema_topics
182
- next if @schema_topics.size > 0 && !@schema_topics.key?(role.fact_type.concept.topic)
183
124
  # Exclude base roles in objectified fact types (unless unary); just use link fact types
184
125
  next if role.fact_type.entity_type && role.fact_type.all_role.size != 1
185
126
  next if role.variable # REVISIT: Continue to ignore roles in derived fact types?
@@ -1,5 +1,5 @@
1
1
  module ActiveFacts
2
2
  module Compositions
3
- VERSION = "1.9.12"
3
+ VERSION = "1.9.13"
4
4
  end
5
5
  end
@@ -83,6 +83,18 @@ module ActiveFacts
83
83
  "#{s}\nGO\n"
84
84
  end
85
85
 
86
+ def open_escape
87
+ '['
88
+ end
89
+
90
+ def close_escape
91
+ ']'
92
+ end
93
+
94
+ def index_kind(index)
95
+ (index.composite_as_primary_index ? ' CLUSTERED' : ' NONCLUSTERED')
96
+ end
97
+
86
98
  class SQLServerDataTypeContext < SQLDataTypeContext
87
99
  def integer_ranges
88
100
  [
@@ -153,6 +153,10 @@ module ActiveFacts
153
153
  }"
154
154
  end
155
155
 
156
+ def index_kind(index)
157
+ ''
158
+ end
159
+
156
160
  def generate_index index, delayed_indices
157
161
  nullable_columns =
158
162
  index.all_index_field.select do |ixf|
@@ -162,16 +166,14 @@ module ActiveFacts
162
166
 
163
167
  primary = index.composite_as_primary_index && !contains_nullable_columns
164
168
  column_names =
165
- index.all_index_field.map do |ixf|
166
- column_name(ixf.component)
167
- end
168
- clustering =
169
- (index.composite_as_primary_index ? ' CLUSTERED' : ' NONCLUSTERED')
169
+ index.all_index_field.map do |ixf|
170
+ column_name(ixf.component)
171
+ end
170
172
 
171
173
  if contains_nullable_columns
172
174
  table_name = safe_table_name(index.composite)
173
175
  delayed_indices <<
174
- 'CREATE UNIQUE'+clustering+' INDEX '+
176
+ 'CREATE UNIQUE'+index_kind(index)+' INDEX '+
175
177
  escape("#{table_name(index.composite)}By#{column_names*''}", index_name_max) +
176
178
  " ON #{table_name}("+column_names.map{|n| escape(n, column_name_max)}*', ' +
177
179
  ") WHERE #{
@@ -184,7 +186,7 @@ module ActiveFacts
184
186
  else
185
187
  '-- '+index.inspect + "\n\t" +
186
188
  (primary ? 'PRIMARY KEY' : 'UNIQUE') +
187
- clustering +
189
+ index_kind(index) +
188
190
  "(#{column_names.map{|n| escape(n, column_name_max)}*', '})"
189
191
  end
190
192
  end
@@ -290,6 +292,14 @@ module ActiveFacts
290
292
  "#{s};\n\n"
291
293
  end
292
294
 
295
+ def open_escape
296
+ '"'
297
+ end
298
+
299
+ def close_escape
300
+ '"'
301
+ end
302
+
293
303
  def escape s, max = table_name_max
294
304
  # Escape SQL keywords and non-identifiers
295
305
  if s.size > max
@@ -299,7 +309,7 @@ module ActiveFacts
299
309
  end
300
310
 
301
311
  if s =~ /[^A-Za-z0-9_]/ || is_reserved_word(s)
302
- "[#{s}]"
312
+ "#{open_escape}#{s}#{close_escape}"
303
313
  else
304
314
  s
305
315
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefacts-compositions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.12
4
+ version: 1.9.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clifford Heath
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-27 00:00:00.000000000 Z
11
+ date: 2017-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler