Skip to content

TSynSQLSyn (sqlOracle dialect): q-quote / alternative quoting mechanism not recognized #294

@csm101

Description

@csm101

Description

TSynSQLSyn with SQLDialect = sqlOracle does not recognize Oracle's alternative quoting mechanism (q-quote operator), introduced in Oracle 10gR2.

The syntax uses a q or Q prefix followed by a chosen delimiter pair, allowing single quotes inside string literals without escaping:

SELECT q'[it's a string]'   FROM dual  -- delimiters [ ]
SELECT q'(it's a string)'   FROM dual  -- delimiters ( )
SELECT q'{it's a string}'   FROM dual  -- delimiters { }
SELECT q'<it's a string>'   FROM dual  -- delimiters < >
SELECT q'-it's a string-'   FROM dual  -- symmetric delimiter -
SELECT q'Xit's a stringX'   FROM dual  -- symmetric delimiter X

Current behavior

The highlighter does not recognize the q'...' literal. Everything from the opening q' onward is tokenized incorrectly (the string is not recognized as a string literal, and subsequent tokens are miscolored).

Expected behavior

When SQLDialect = sqlOracle, the highlighter should recognize q'<delim>...<closing-delim>' as a complete string token, where:

  • If the opening delimiter is [, (, {, or <, the closing delimiter is the matching ], ), }, or >
  • Otherwise the closing delimiter is the same character as the opening one
  • The token ends only when the closing delimiter is immediately followed by a single quote (')

Notes

  • The q prefix is case-insensitive (q or Q)
  • The delimiter can be any character except space, tab, newline, and '
  • This syntax is valid in both SQL and PL/SQL
  • It has been available since Oracle 10gR2 (2005)

Example screenshots:

1. This is a screenshot of of TSynEdit displaying some SQL using this syntax:
Image

2. This is the same SQL as highlighted by a commercial oracle-specific SQL tool which is aware of this syntax:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions