- 
                Notifications
    You must be signed in to change notification settings 
- Fork 149
Description
In version 1.5.2  and later, write() will add FORMAT JSON to the end of some queries when it should not.
For example:
CREATE USER OR REPLACE {user} ON CLUSTER some_cluster IDENTIFIED WITH sha256_password BY \'{password}\'.
It will change this query to:
CREATE USER OR REPLACE {user} ON CLUSTER some_cluster IDENTIFIED WITH sha256_password BY \'{password}\' FORMAT JSON, which will crash.
[22000] Code: 62. DB::Exception: Syntax error: failed at position 122 (FORMAT): FORMAT JSON. Expected one of: VALID UNTIL, token, Comma, HOST, SettingsProfileElements, SETTINGS, SETTING, PROFILES, PROFILE, DEFAULT ROLE, GRANTEES, DEFAULT DATABASE, IN, ParallelWithClause, PARALLEL WITH, end of query. (SYNTAX_ERROR) (version 25.9.3.48 (official build))
phpClickHouse/src/Transport/Http.php
Line 640 in aaf2812
| str_starts_with($sql, 'CREATE') | 
if (
    str_starts_with($sql, 'CREATE')
    || str_starts_with($sql, 'DROP')
    || str_starts_with($sql, 'ALTER')
    || str_starts_with($sql, 'RENAME')
) {
    $query->setFormat('JSON');
}
Should this logic not be inverted to:
if (
    !str_starts_with($sql, 'CREATE')
    && !str_starts_with($sql, 'DROP')
    && !str_starts_with($sql, 'ALTER')
    && !str_starts_with($sql, 'RENAME')
) {
    $query->setFormat('JSON');
}
Or am I missing something here?
Realtes to: #214
I am willing to create a PR for this.