expressir 2.4.13 → 2.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/expressir/express/checker.rb +81 -0
- data/lib/expressir/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ad3043a3dd1ac401e841249e3e081a7b3b6b3c3da99f6a9dbc136a127619ba49
|
|
4
|
+
data.tar.gz: '085e25b6e9b97d53fc5207aa651b37b080557626c6971b60029b98749ff4db82'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e92cca737def4e8432f30b98162262f83df7d81c719c7a1dd916173f65ff788c1145843e46131bfe7da5ef97e76c00a155215f7c4893befe7748601711438d93
|
|
7
|
+
data.tar.gz: 88d3f1008222838323a843a1b9a7117bf1b09465fa453de4bfd21868137b16439a680165e527555099ae67884cb8a77c8a2068e92b113f34408444c314482583
|
|
@@ -97,6 +97,11 @@ module Expressir
|
|
|
97
97
|
check_where_rules(schema, t, t.where_rules)
|
|
98
98
|
end
|
|
99
99
|
schema.rules.each { |r| check_where_rules(schema, r, r.where_rules) }
|
|
100
|
+
schema.entities.each do |entity|
|
|
101
|
+
check_aggregate_bounds(schema, entity)
|
|
102
|
+
check_attrib_name_fun(schema, entity)
|
|
103
|
+
end
|
|
104
|
+
check_string_references(schema)
|
|
100
105
|
check_unresolved_refs(schema)
|
|
101
106
|
end
|
|
102
107
|
|
|
@@ -342,6 +347,82 @@ module Expressir
|
|
|
342
347
|
:type if find_type(schema, id)
|
|
343
348
|
end
|
|
344
349
|
|
|
350
|
+
# eeng check-agg-type: a two-bound aggregate whose lower bound
|
|
351
|
+
# exceeds its upper bound is invalid.
|
|
352
|
+
def check_aggregate_bounds(schema, entity)
|
|
353
|
+
entity.attributes.to_a.each do |attr|
|
|
354
|
+
type = attr.type
|
|
355
|
+
next unless type.respond_to?(:bound1) && type.respond_to?(:bound2)
|
|
356
|
+
|
|
357
|
+
lower = integer_bound(type.bound1)
|
|
358
|
+
upper = integer_bound(type.bound2)
|
|
359
|
+
next if lower.nil? || upper.nil?
|
|
360
|
+
next if lower <= upper
|
|
361
|
+
|
|
362
|
+
note!(:check_agg_type, :error, schema,
|
|
363
|
+
"ENTITY #{entity.id}: aggregate '#{attr.id}' bounds " \
|
|
364
|
+
"[#{lower}:#{upper}] are inverted", attr)
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
def integer_bound(bound)
|
|
369
|
+
return nil unless bound.is_a?(Model::Literals::Integer)
|
|
370
|
+
|
|
371
|
+
bound.value.to_i
|
|
372
|
+
rescue StandardError
|
|
373
|
+
nil
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
# eeng check-attrib-name-fun: an attribute sharing its name with
|
|
377
|
+
# a function of the same schema can never be referenced cleanly.
|
|
378
|
+
def check_attrib_name_fun(schema, entity)
|
|
379
|
+
funs = schema.functions.to_a.map { |f| f.id.safe_downcase }
|
|
380
|
+
entity.attributes.to_a.each do |attr|
|
|
381
|
+
next unless attr.id && funs.include?(attr.id.safe_downcase)
|
|
382
|
+
|
|
383
|
+
note!(:check_attrib_name_fun, :warning, schema,
|
|
384
|
+
"ENTITY #{entity.id}: attribute '#{attr.id}' shadows a " \
|
|
385
|
+
"function of the same name", attr)
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
# eeng check-string-no-entity: string literals of the shape
|
|
390
|
+
# 'SCHEMA.ITEM' whose SCHEMA is known in the repository but whose
|
|
391
|
+
# ITEM is not declared in it (the TYPEOF idiom).
|
|
392
|
+
def check_string_references(schema)
|
|
393
|
+
known = @by_name
|
|
394
|
+
each_string(schema) do |literal, value|
|
|
395
|
+
match = /\A(\w+)\.(\w+)\z/.match(value)
|
|
396
|
+
next unless match
|
|
397
|
+
|
|
398
|
+
schema_id = match[1].safe_downcase
|
|
399
|
+
item_id = match[2].safe_downcase
|
|
400
|
+
target = known[schema_id]&.find { |s| s.id.safe_downcase == schema_id }
|
|
401
|
+
next unless target
|
|
402
|
+
next if Expressir::Express::SelfSchemaReference.declared?(target, item_id)
|
|
403
|
+
|
|
404
|
+
note!(:check_string_no_entity, :warning, schema,
|
|
405
|
+
"string '#{value}' references '#{item_id}' which is not " \
|
|
406
|
+
"declared in schema '#{target.id}'", literal)
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
def each_string(node, &)
|
|
411
|
+
case node
|
|
412
|
+
when Model::Literals::String then yield node, node.value
|
|
413
|
+
when Model::ModelElement
|
|
414
|
+
node.class.attributes.each_key do |attr|
|
|
415
|
+
next if Model::ModelElement::SKIP_ATTRIBUTES.include?(attr) || attr == :parent
|
|
416
|
+
|
|
417
|
+
value = node.public_send(attr)
|
|
418
|
+
case value
|
|
419
|
+
when Array then value.each { |item| each_string(item, &) }
|
|
420
|
+
when Model::ModelElement then each_string(value, &)
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
end
|
|
424
|
+
end
|
|
425
|
+
|
|
345
426
|
def check_where_rules(schema, owner, rules)
|
|
346
427
|
Array(rules).each do |wr|
|
|
347
428
|
next if wr.id.nil? || wr.id.match?(WHERE_LABEL)
|
data/lib/expressir/version.rb
CHANGED