Class: OpenehrRails::Aql::QueryValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/openehr_rails/aql/query_validator.rb

Overview

Pre-validates an AQL query against the openehr gem's known execution gaps (parses fine, raises OpenEHR::AQL::ExecutionError or silently misbehaves at run time), so callers (Model.aql, the REST endpoint, the admin console) can surface a specific, actionable error instead of a raw engine failure. See the openehr gem's own README/CHANGELOG for the authoritative, up-to-date list of what the engine can execute.

As of openehr 2.3.0, LIKE, MATCHES against a literal value list, CONTAINS standardPredicate/nodePredicate, and mixed aggregate/plain SELECT columns all execute correctly and are no longer guarded here. What remains genuinely unsupported: MATCHES against a TERMINOLOGY(...) value-set expansion (no terminology-server value-set lookup is wired up), generic function calls in WHERE, and VERSION-aware FROM classes.

Constant Summary collapse

VERSION_CLASS_NAMES =
%w[VERSION LATEST_VERSION ALL_VERSIONS VERSIONED_COMPOSITION].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aql_string) ⇒ QueryValidator

Returns a new instance of QueryValidator.



27
28
29
# File 'lib/openehr_rails/aql/query_validator.rb', line 27

def initialize(aql_string)
  @aql_string = aql_string
end

Class Method Details

.validate!(aql_string) ⇒ Object



23
24
25
# File 'lib/openehr_rails/aql/query_validator.rb', line 23

def self.validate!(aql_string)
  new(aql_string).validate!
end

Instance Method Details

#validate!Object



31
32
33
34
35
36
# File 'lib/openehr_rails/aql/query_validator.rb', line 31

def validate!
  query = parse
  check_from_clause(query.from_clause)
  check_where_clause(query.where_clause)
  query
end