Skip to content

Add way to style identifiers (i.e. schema, table, and column names) #147

@wkeese

Description

@wkeese

As seen from the ‘getSegments’ tests, identifiers with backticks are classified as “string”,

it('complex query', () => {
  expect(getSegments("SELECT COUNT(id), `id`, `username` FROM `users` WHERE `email` = 'test@example.com' AND `foo` = 'BAR' OR 1=1"))
    .toStrictEqual([
      ...
      { name: 'string', content: '`email`' },
      ...
      { name: 'string', content: "'test@example.com'" },

That means that you can’t set a specific style for backticked identifiers, they just appear in the same color as strings. In the example above, `email` and 'test@example.com' end up with the same styling.

Furthermore, identifiers without backticks are lumped together with whitespace and identified as “default”.:

it('test how default works', () => {
  expect(getSegments('SELECT * FROM hr.emp'))
    .toStrictEqual([
      { name: 'keyword', content: 'SELECT' },
      { name: 'default', content: ' ' },
      { name: 'special', content: '*' },
      { name: 'default', content: ' ' },
      { name: 'keyword', content: 'FROM' },
      { name: 'default', content: ' hr.emp' }
    ])
})

That means that (for example) you can’t set a background-color for identifiers like “hr.emp”, because then the background-color would apply to the whitespace before “hr.emp” too, in addition to the whitespace before and after the * character.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions