Skip to content

[V3.1.3 Backport] fix(schema): align date/time operators with BNF; widen timeLiteralPattern#613

Open
sebbader-sap wants to merge 2 commits into
IDTA-01001-3-1-3_workingfrom
backport/v3.1.3/pr582-datetime-schema
Open

[V3.1.3 Backport] fix(schema): align date/time operators with BNF; widen timeLiteralPattern#613
sebbader-sap wants to merge 2 commits into
IDTA-01001-3-1-3_workingfrom
backport/v3.1.3/pr582-datetime-schema

Conversation

@sebbader-sap
Copy link
Copy Markdown
Contributor

Backport from PR #582

This is a backport of the bugfix from PR #582 to the V3.1.3 release branch.

Original PR Description

This PR aligns JSON schemas with the BNF grammar for date and time semantics in the AAS Query Language.

Problem:

  1. The BNF defines $dayOfWeek, $dayOfMonth, $month, and $year as numeric extraction functions accepting a dateTimeOperand (literal, cast, or attribute access). However, the schema restricted these to dateTimeLiteralPattern, rejecting valid constructs like {"$dayOfWeek": {"$attribute": {"GLOBAL": "UTCNOW"}}}.
  2. timeLiteralPattern didn't support fractional seconds despite the BNF allowing them.

Solution:

  • Change the four extraction functions to reference #/definitions/Value instead of literal patterns
  • Expand timeLiteralPattern regex to permit optional seconds and fractional components: ^[0-9]{2}:[0-9]{2}(:[0-9]{2})?(\.[0-9]+)?$

Related

…h/$year and timeLiteralPattern

The BNF defines these keys as numeric-extraction functions over a
dateTime expression:

  <dateTimeToNum> ::=
      ( "$dayOfWeek" | "$dayOfMonth" | "$month" | "$year" )
      <ws> "(" <ws> <dateTimeOperand> <ws> ")" <ws>

where <dateTimeOperand> is a DateTimeLiteral, a cast to dateTime, or
a GlobalAttribute (e.g. GLOBAL(UTCNOW)). The argument is therefore a
Value expression that evaluates to a dateTime, not a literal
xsd:dateTime string.

The JSON schemas typed these four keys as
$ref: "#/definitions/dateTimeLiteralPattern"
which forced them to be literal ISO date-time strings and made
constructs like `{"$dayOfWeek": {"$attribute": {"GLOBAL": "UTCNOW"}}}`
invalid even though the BNF explicitly allows them.

timeLiteralPattern was also stricter than the grammar: it rejected
fractional seconds. The BNF <time> is:

  <hour> ":" <minute> ( ":" <second> )? ( "." <fraction> )?

Changes:

- $dayOfWeek, $dayOfMonth, $month, $year -> $ref Value
- timeLiteralPattern pattern
    before: ^[0-9][0-9]:[0-9][0-9](:[0-9][0-9])?$
    after : ^[0-9]{2}:[0-9]{2}(:[0-9]{2})?(\.[0-9]+)?$

Files:
- aas-specs-api: partials/query-json-schema.json, pages/schema.adoc
- aas-specs-security: partials/json/aas-queries-and-access-rules-schema.json, partials/json/formulas-and-logical-expressions.json

Refs: Review Finding T-14
Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants