[V3.1.3 Backport] fix(schema): align date/time operators with BNF; widen timeLiteralPattern#613
Open
sebbader-sap wants to merge 2 commits into
Open
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
$dayOfWeek,$dayOfMonth,$month, and$yearas numeric extraction functions accepting adateTimeOperand(literal, cast, or attribute access). However, the schema restricted these todateTimeLiteralPattern, rejecting valid constructs like{"$dayOfWeek": {"$attribute": {"GLOBAL": "UTCNOW"}}}.timeLiteralPatterndidn't support fractional seconds despite the BNF allowing them.Solution:
#/definitions/Valueinstead of literal patternstimeLiteralPatternregex to permit optional seconds and fractional components:^[0-9]{2}:[0-9]{2}(:[0-9]{2})?(\.[0-9]+)?$Related