Skip to content

Commit

Permalink
Fix(parser): use _parse_bitwise for values of JSON_OBJECT
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas committed Sep 5, 2023
1 parent f0bddde commit dcacef1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4151,7 +4151,7 @@ def _parse_json_key_value(self) -> t.Optional[exp.JSONKeyValue]:
key = self._parse_column()
self._match_set((TokenType.COLON, TokenType.COMMA))
self._match_text_seq("VALUE")
value = self._parse_column()
value = self._parse_bitwise()

if not key and not value:
return None
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class TestOracle(Validator):
dialect = "oracle"

def test_oracle(self):
self.validate_identity("SELECT JSON_OBJECT('name': first_name || ' ' || last_name) FROM t")
self.validate_identity("COALESCE(c1, c2, c3)")
self.validate_identity("SELECT * FROM TABLE(foo)")
self.validate_identity("SELECT a$x#b")
Expand Down

1 comment on commit dcacef1

@georgesittas
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See example at https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/JSON_OBJECT.html#GUID-1EF347AE-7FDA-4B41-AFE0-DD5A49E8B370:

SELECT JSON_OBJECT(
'name' : first_name || ' ' || last_name,
'email' : email,
'phone' : phone_number,
'hire_date' : hire_date
)
FROM employees
WHERE employee_id = 140;

Please sign in to comment.