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

When there is "false" in SQL, the format will fail #147

Closed
jiatianqi opened this issue May 25, 2021 · 6 comments
Closed

When there is "false" in SQL, the format will fail #147

jiatianqi opened this issue May 25, 2021 · 6 comments
Labels
Milestone

Comments

@jiatianqi
Copy link

jiatianqi commented May 25, 2021

input

CREATE TABLE run_stat(
  carId int, avg_speed double
  ) WITH (
  'connector.type' = 'jdbc',
  'connector.url' = 'jdbc:mysql://199.1XX.1XX.XXX:3306/aaa?useSSL=false',
  'connector.table' = 'mysql_run_log',
  'connector.username' = 'aaa',
  'connector.password' = 'aaa');

There will be errors during the formatting process, and the test will fail in thisonline site. The current version is 4.0.2, but it is normal to use 2.3.3.

@delanym
Copy link

delanym commented Aug 6, 2021

The tool is unusable like this

INSERT INTO matrix (first) VALUES ('false')

@inferrinizzard
Copy link
Collaborator

Hi, can you confirm if this is still an issue here: https://inferrinizzard.github.io/prettier-sql/ ?

@inferrinizzard
Copy link
Collaborator

Hi, this issue is fixed in my fork here:
https://github.com/inferrinizzard/prettier-sql
https://www.npmjs.com/package/prettier-sql

@baurine
Copy link

baurine commented Apr 15, 2022

exact the same issue, reported the following error by using 4.0.2 version:

Uncaught TypeError: Cannot read properties of undefined (reading 'slice')
    at parseKey (Tokenizer.js:191:20)
    at Tokenizer2.getPlaceholderTokenWithKey (Tokenizer.js:235:21)
    at Tokenizer2.getIdentNamedPlaceholderToken (Tokenizer.js:187:19)
    at Tokenizer2.getPlaceholderToken (Tokenizer.js:182:19)
    at Tokenizer2.getNextToken (Tokenizer.js:127:147)
    at Tokenizer2.tokenize (Tokenizer.js:107:24)
    at MySqlFormatter2.format7 (Formatter.js:87:38)
    at format8 (sqlFormatter.js:74:29)
    at formatSql (index.ts:15:19)
    at index.ts:32:23

my example SQL:

select `topics` . `id` from `topics` left outer join `categories` on `categories` . `id` = `topics` . `category_id` where ( `topics` . `archetype` <> ? ) and ( coalesce ( `categories` . `topic_id` , ? ) <> `topics` . `id` ) and `topics` . `visible` = true and ( `topics` . `deleted_at` is ? ) and ( `topics` . `category_id` is ? or `topics` . `category_id` in ( ... ) ) and ( `topics` . `category_id` != ? ) and `topics` . `closed` = false and `topics` . `archived` = false and ( `topics` . `created_at` > ? ) order by `rand` ( ) limit ?

@baurine
Copy link

baurine commented Apr 15, 2022

Hi, this issue is fixed in my fork here: https://github.com/inferrinizzard/prettier-sql https://www.npmjs.com/package/prettier-sql

Big thanks @inferrinizzard , your fork resolves my issue!

@nene
Copy link
Collaborator

nene commented May 3, 2022

Fixed also in latest master.

@nene nene closed this as completed May 3, 2022
@nene nene added the bug label May 3, 2022
@nene nene added this to the Version 6 milestone May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants