Skip to content

fix(dql): support IRI-ref at query start#9667

Open
eileenaaa wants to merge 5 commits intodgraph-io:mainfrom
eileenaaa:fix/dql-lexer-iri-ref-regression
Open

fix(dql): support IRI-ref at query start#9667
eileenaaa wants to merge 5 commits intodgraph-io:mainfrom
eileenaaa:fix/dql-lexer-iri-ref-regression

Conversation

@eileenaaa
Copy link
Contributor

Description

This PR fixes a regression in DQL lexing where queries starting with an IRI-ref (names wrapped in < >, e.g., <caseNodeDel_xxx>) would fail with an Unexpected character: U+003C '<' error.

Root Cause:
In v25, the state function lexIdentifyMutationOrQuery was introduced to distinguish between mutations and queries. However, it lacked a case for the lsThan (<) character, causing the lexer to fail when a query block started with an IRI-ref instead of a standard name or keyword.

Changes:

  • Updated lexIdentifyMutationOrQuery in dql/state.go to handle the lsThan (<) case.
  • Ensures the lexer correctly calls lex.IRIRef and transitions to lexQuery.

Fixes #9666

Checklist

  • The PR title follows the Conventional Commits syntax, leading with fix:, feat:, chore:, ci:, etc.
  • Code compiles correctly and linting (via trunk) passes locally
  • Tests added for new functionality, or regression tests for bug fixes added as applicable

for it.Next() {
item := it.Item()
require.NotEqual(t, item.Typ, lex.ItemError, "Error: %v", item.String())
t.Log(item.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test only asserts absence of errors but doesn't verify the IRI ref was actually parsed. A broken implementation that silently drops the token would still pass. Add a positive assertion that "user-query" was emitted as a token value (similar to TestNumberInLang), and drop the t.Log.

Suggested change
t.Log(item.String())
var foundIRI bool
for it.Next() {
item := it.Item()
require.NotEqual(t, item.Typ, lex.ItemError, "Error: %v", item.String())
if item.Val == "user-query" {
foundIRI = true
}
}
require.True(t, foundIRI, "expected IRI ref 'user-query' to be lexed")```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Lexer error in v25.3.0: Unexpected character while lexing DQL: U+003C '<' when query starts with IRI-ref

3 participants