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

[FORMATTING] Formatter inserts space in between @ operator in mariadb dialect #793

Open
mariadb-ThienLy opened this issue Oct 24, 2024 · 1 comment

Comments

@mariadb-ThienLy
Copy link

mariadb-ThienLy commented Oct 24, 2024

Input data

Which SQL and options did you provide as input?

CREATE USER newuser@localhost;

Expected Output

CREATE USER newuser@localhost;

Actual Output

CREATE USER newuser @localhost;

Having an extra space before the @ sign doesn't break the execution but it just doesn't look nice. The same thing happens even if I wrap it inside backticks. i.e.

CREATE USER `newuser` @`localhost`;

Usage

  • How are you calling / using the library?
import { formatDialect, mariadb } from 'sql-formatter'

export function formatSQL(v) {
  return formatDialect(v, { dialect: mariadb, tabWidth: 2, keywordCase: 'upper' })
}
  • What SQL language(s) does this apply to? mariadb
  • Which SQL Formatter version are you using? 15.3.2
@mariadb-ThienLy mariadb-ThienLy changed the title [FORMATTING] Issue Title Here [FORMATTING] Formatter inserts space in between @ operator in mariadb dialect Oct 24, 2024
@nene
Copy link
Collaborator

nene commented Oct 24, 2024

Thanks for reporting.

The formatter thinks that @localhost is a variable and formats it accordingly. This user@host syntax is kinda tricky to handle as it's specific to very few SQL statements. As this thankfully doesn't make the SQL invalid, it's unlikely that it'll get fixed by me. Especially as I'm avoiding any new feature development on this library.

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

No branches or pull requests

2 participants