Skip to content

Commit

Permalink
[Obs AI assistant] Replace with double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Jul 2, 2024
1 parent 640baee commit 3c2fe19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ describe('correctCommonEsqlMistakes', () => {
);
});

it(`replaces " or ' escaping in FROM statements with backticks`, () => {
expectQuery(`FROM "logs-*" | LIMIT 10`, 'FROM logs-*\n| LIMIT 10');
expectQuery(`FROM 'logs-*' | LIMIT 10`, 'FROM logs-*\n| LIMIT 10');
it("replaces ` or ' escaping in FROM statements with backticks", () => {
expectQuery(`FROM "logs-*" | LIMIT 10`, 'FROM "logs-*"\n| LIMIT 10');
expectQuery(`FROM 'logs-*' | LIMIT 10`, 'FROM "logs-*"\n| LIMIT 10');
expectQuery(`FROM logs-* | LIMIT 10`, 'FROM logs-*\n| LIMIT 10');
});

Expand Down Expand Up @@ -143,7 +143,7 @@ describe('correctCommonEsqlMistakes', () => {
| EVAL "@timestamp" = TO_DATETIME(timestamp)
| WHERE statement LIKE 'SELECT%'
| STATS avg_duration = AVG(duration)`,
`FROM postgres-logs*
`FROM "postgres-logs*"
| GROK message "%{TIMESTAMP_ISO8601:timestamp} %{TZ} \[%{NUMBER:process_id}\]: \[%{NUMBER:log_line}\] user=%{USER:user},db=%{USER:database},app=\[%{DATA:application}\],client=%{IP:client_ip} LOG: duration: %{NUMBER:duration:float} ms statement: %{GREEDYDATA:statement}"
| EVAL @timestamp = TO_DATETIME(timestamp)
| WHERE statement LIKE "SELECT%"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ export function correctCommonEsqlMistakes(query: string): {
switch (name) {
case 'FROM':
formattedCommand = formattedCommand
.replaceAll(/FROM "(.*)"/g, 'FROM $1')
.replaceAll(/FROM '(.*)'/g, 'FROM $1')
.replaceAll(/FROM `(.*)`/g, 'FROM $1');
.replaceAll(/FROM '(.*)'/g, 'FROM "$1"')
.replaceAll(/FROM `(.*)`/g, 'FROM "$1"');
break;

case 'WHERE':
Expand Down

0 comments on commit 3c2fe19

Please sign in to comment.