Skip to content

[FORMATTING] MySQL: INTERVAL is not affected by keywordCase (it is in MariaDB) #985

Open

Description

@jemersonln5

With language: 'mysql' and keywordCase: 'upper', INTERVAL stays lower case, both inside and outside a function call. The same query with language: 'mariadb' upper-cases it, so it looks like INTERVAL is missing from the MySQL keyword list. (The unit — DAY, HOUR, … — stays as typed in both dialects; I'm not sure whether that is intended.)

Input data

select now() - interval 30 day;
select date_sub(now(), interval 30 day);

Expected Output

SELECT
  now() - INTERVAL 30 day;

SELECT
  date_sub(now(), INTERVAL 30 day);

Actual Output

SELECT
  now() - interval 30 day;

SELECT
  date_sub(now(), interval 30 day);

For comparison, mariadb:

SELECT
  date_sub(now(), INTERVAL 30 day);

Usage

  • Calling format() from the npm package directly (Node.js), options { language: ..., keywordCase: 'upper' }.
  • SQL language(s): mysql (works in mariadb)
  • SQL Formatter version: 15.9.0 (also reproduced on 15.6.12)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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