Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: add jsonb support #1756

Closed
wants to merge 1 commit into from

Conversation

ziccardi
Copy link
Contributor

@ziccardi ziccardi commented Jun 6, 2024

Description

------------------------------------------------------------------

This PR is NOT MEANT TO BE MERGED. There is a piece of software into the Kas Fleet Manager called 'SQL Parser' that could be useful for another project where we need to parse JSONB queries.
This PR just shows what would be needed to use it to parse them

------------------------------------------------------------------

This PR adds support for JSONB queries to the SQL parser.

Unit tests has been added as described below

JSONB Query
INPUT:

manifest->'data'->'manifest'->'metadata'->'labels'->>'foo' = 'bar'

OUTPUT: Query must be parsed successfully end the following output must be produced:

Parsed query: "manifest -> 'data' -> 'manifest' -> 'metadata' -> 'labels' ->> 'foo' = ?"
Values to be passed to the statement: []interface{}{"bar"},

Complex JSONB query
INPUT:

manifest->'data'->'manifest'->'metadata'->'labels'->>'foo' = 'bar' and
( manifest->'data'->'manifest' ->> 'foo' in ('value1', 'value2') or
manifest->'data'->'manifest'->>'labels' <> 'foo1')

Invalid JSONB query
INPUT:

manifest->'data'->'manifest'->'metadata'->'labels'->'foo' = 'bar'

OUTPUT: parsing error with a message that describes where the error.
The text of the error must be: "[59] error parsing the filter: unexpected token =" where 59 is the position of the unexpected token into the string (first position is '1').

Verification Steps

Checklist (Definition of Done)

  • All acceptance criteria specified in JIRA have been completed
  • Unit and integration tests added that prove the fix is effective or the feature works (tested against emulated and non-emulated OCM environment)
  • Documentation added for the feature
  • CI and all relevant tests are passing
  • Code Review completed
  • Verified independently by reviewer
  • All PR comments are resolved either by addressing them or creating follow up tasks
  • Required metrics/dashboards/alerts have been added (or PR created).
  • Required Standard Operating Procedure (SOP) is added.
  • JIRA has been created for changes required on the client side

@ziccardi ziccardi requested review from a team as code owners June 6, 2024 15:23
@github-actions github-actions bot added the common label Jun 6, 2024
@ziccardi ziccardi force-pushed the JSONB_SUPPORT branch 2 times, most recently from 6afc9a2 to cbbd871 Compare June 7, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants