Skip to content

feat: support Oracle JSON_OBJECT syntax (6973) - #4231

Open
benfdking wants to merge 1 commit into
port/sqlfluff-6964from
port/sqlfluff-6973
Open

benfdking wants to merge 1 commit into
port/sqlfluff-6964from
port/sqlfluff-6973

Conversation

@benfdking

Copy link
Copy Markdown
Collaborator

Stacked on sqruff #4230. Merge #4230 first.
#4230

Summary

  • Add Oracle JSON_OBJECT content grammar for colon and KEY/VALUE entries, FORMAT JSON, wildcard entries, null handling, RETURNING types, STRICT, and WITH UNIQUE KEYS.
  • Register the required TYPENAME keyword (ABSENT was already present) and connect the new content grammar alongside existing LISTAGG overflow handling.
  • Port all nine upstream examples and add ten option-coverage statements with generated parse fixtures. Upstream function trees match after accounting for the existing Oracle function-name node and YAML serialization.

Ported from SQLFluff b17ad001e338042f6dc78e3335cebbb8aa41b869
sqlfluff/sqlfluff#6973
sqlfluff/sqlfluff@b17ad00

Validation

  • cargo fmt --all -- --check
  • cargo build
  • cargo test
  • bazel test //... --test_timeout=600,300,900,3600 --local_test_jobs=1

Ported from SQLFluff b17ad001e338042f6dc78e3335cebbb8aa41b869
sqlfluff/sqlfluff#6973
sqlfluff/sqlfluff@b17ad00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T20:05:12.663009Z 99d9f60 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@benfdking
benfdking added this pull request to stack #4155 September 14, 2026 20:01

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99d9f60f93

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Ref::keyword("RETURNING").to_matchable(),
one_of(vec![
Sequence::new(vec![
Ref::keyword("VARCHAR").to_matchable(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept VARCHAR2 in the RETURNING clause

Oracle's canonical JSON return type is VARCHAR2, so valid calls such as JSON_OBJECT('a' VALUE 1 RETURNING VARCHAR2(100)) cannot match this branch: the other alternatives only accept CLOB, BLOB, or JSON, leaving the entire function contents unparsable. Include VARCHAR2 alongside VARCHAR and apply the same size and character-semantics grammar.

Useful? React with 👍 / 👎.

Comment on lines +5122 to +5129
one_of(vec![
Ref::new("StarSegment").to_matchable(),
Delimited::new(vec![Ref::new("JSONEntrySegment").to_matchable()])
.to_matchable(),
])
.config(|config| {
config.optional();
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Disambiguate option-only JSON_OBJECT calls

When an empty object specifies an option, such as JSON_OBJECT(ABSENT ON NULL) or JSON_OBJECT(RETURNING JSON), this optional entry matcher greedily treats ABSENT or RETURNING as a shorthand expression entry because those words are valid naked identifiers. The following option clause then starts at ON or JSON and cannot match, so these valid option-only forms become unparsable; exclude the option-clause starters when matching the optional entry list.

Useful? React with 👍 / 👎.

Comment on lines +5252 to +5254
Ref::new("SingleIdentifierGrammar")
.optional()
.to_matchable(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep STRICT from being consumed as a LOB identifier

For valid forms such as JSON_OBJECT('a' VALUE 1 RETURNING CLOB STRICT), STRICT is not reserved in this dialect, so this optional SingleIdentifierGrammar greedily consumes it as a naked identifier. The outer STRICT clause consequently never matches, producing an incorrect syntax tree and preventing rules from recognizing the strict modifier; exclude STRICT from this optional identifier or model the actual trailing construct explicitly.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark for f62e099

Click to view benchmark
Test Base PR %
DepthMap::from_parent 115.9±2.05µs 114.4±1.05µs -1.29%
fix_complex_query 25.8±0.53ms 24.9±0.66ms -3.49%
fix_superlong 90.3±3.32ms 85.5±6.61ms -5.32%
parse_complex_query 4.1±0.07µs 4.2±0.10µs +2.44%
parse_expression_recursion 6.9±0.25µs 7.1±0.27µs +2.90%
parse_simple_query 1020.5±18.50ns 1031.4±26.38ns +1.07%

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.

1 participant