diff --git a/src/parsing/index.ts b/src/parsing/index.ts index 44b6ec6e..1b1f297f 100644 --- a/src/parsing/index.ts +++ b/src/parsing/index.ts @@ -22,8 +22,9 @@ export interface ParseResult { suggestColumnAliases?: ColumnAliasSuggestion[]; suggestCommonTableExpressions?: unknown; suggestDatabases?: DatabasesSuggestion; - suggestFilters?: unknown; - suggestFunctions?: unknown; + suggestFilters?: FiltersSuggestion; + suggestFunctions?: FunctionsSuggestion; + suggestValues?: ValuesSuggestion; suggestGroupBys?: unknown; suggestIdentifiers?: IdentifierSuggestion[]; suggestTemplates?: boolean; @@ -31,6 +32,7 @@ export interface ParseResult { engines: Engines; functionalEngines: Engines; }; + colRef?: ColumnReference; // Reasons for those fields are unknown definitions?: []; // TODO: figure our if it's optional @@ -106,9 +108,28 @@ export interface AggregateFunctionsSuggestion { export interface ColumnSuggestion { source?: string; // TODO: figure our if it's optional + types?: string[]; tables: Table[]; } +export interface FunctionsSuggestion { + types?: string[]; +} + +export interface FiltersSuggestion { + prefix?: string; + tables: Table[]; +} + +export interface ValuesSuggestion { + missingEndQuote?: boolean; + partialQuote?: boolean; +} + +export interface ColumnReference { + identifierChain: IdentifierChainEntry[]; +} + export interface KeywordSuggestion { value: string; weight: number; diff --git a/src/parsing/parsers/generic/jison/update/update_table.test.json b/src/parsing/parsers/generic/jison/update/update_table.test.json deleted file mode 100644 index fb5dbd4a..00000000 --- a/src/parsing/parsers/generic/jison/update/update_table.test.json +++ /dev/null @@ -1,850 +0,0 @@ -[ - { - "namePrefix": "should suggest keywords", - "beforeCursor": "", - "afterCursor": "", - "containsKeywords": ["UPDATE"], - "expectedResult": { - "lowerCase": false - } - }, - { - "namePrefix": "should suggest keywords", - "beforeCursor": "UPDATE bar ", - "afterCursor": "", - "expectedResult": { - "lowerCase": false, - "suggestKeywords": ["SET"], - "locations": [ - { - "type": "statement", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 1, - "last_column": 12 - } - }, - { - "type": "table", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 8, - "last_column": 11 - }, - "identifierChain": [ - { - "name": "bar" - } - ] - } - ] - } - }, - { - "namePrefix": "should suggest keywords", - "beforeCursor": "UPDATE bar SET id=1, foo=2 ", - "afterCursor": "", - "containsKeywords": ["WHERE"], - "expectedResult": { - "lowerCase": false, - "locations": [ - { - "type": "statement", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 1, - "last_column": 27 - } - }, - { - "type": "table", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 8, - "last_column": 11 - }, - "identifierChain": [ - { - "name": "bar" - } - ] - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 16, - "last_column": 18 - }, - "identifierChain": [ - { - "name": "id" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - } - ] - } - ], - "qualified": false - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 22, - "last_column": 25 - }, - "identifierChain": [ - { - "name": "foo" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - } - ] - } - ], - "qualified": false - } - ] - } - }, - { - "namePrefix": "should suggest keywords", - "beforeCursor": "UPDATE bar SET id ", - "afterCursor": "", - "expectedResult": { - "lowerCase": false, - "suggestKeywords": ["="], - "locations": [ - { - "type": "statement", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 1, - "last_column": 18 - } - }, - { - "type": "table", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 8, - "last_column": 11 - }, - "identifierChain": [ - { - "name": "bar" - } - ] - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 16, - "last_column": 18 - }, - "identifierChain": [ - { - "name": "id" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - } - ] - } - ], - "qualified": false - } - ] - } - }, - { - "namePrefix": "should suggest tables", - "beforeCursor": "UPDATE ", - "afterCursor": "", - "expectedResult": { - "lowerCase": false, - "suggestTables": {}, - "suggestDatabases": { - "appendDot": true - } - } - }, - { - "namePrefix": "should suggest tables", - "beforeCursor": "UPDATE bla", - "afterCursor": "", - "expectedResult": { - "lowerCase": false, - "suggestTables": {}, - "suggestDatabases": { - "appendDot": true - } - } - }, - { - "namePrefix": "should suggest tables", - "beforeCursor": "UPDATE bar.", - "afterCursor": "", - "expectedResult": { - "lowerCase": false, - "suggestTables": { - "identifierChain": [ - { - "name": "bar" - } - ] - } - } - }, - { - "namePrefix": "should suggest tables", - "beforeCursor": "UPDATE bar.foo", - "afterCursor": "", - "expectedResult": { - "lowerCase": false, - "suggestTables": { - "identifierChain": [ - { - "name": "bar" - } - ] - } - } - }, - { - "namePrefix": "should suggest columns", - "beforeCursor": "UPDATE bar.foo SET ", - "afterCursor": "", - "expectedResult": { - "lowerCase": false, - "suggestColumns": { - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ] - }, - "locations": [ - { - "type": "statement", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 1, - "last_column": 19 - } - }, - { - "type": "database", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 8, - "last_column": 11 - }, - "identifierChain": [ - { - "name": "bar" - } - ] - }, - { - "type": "table", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 12, - "last_column": 15 - }, - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ] - } - }, - { - "namePrefix": "should suggest columns", - "beforeCursor": "UPDATE bar.foo SET id = 1, bla = 'foo', ", - "afterCursor": "", - "expectedResult": { - "lowerCase": false, - "suggestColumns": { - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ] - }, - "locations": [ - { - "type": "statement", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 1, - "last_column": 40 - } - }, - { - "type": "database", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 8, - "last_column": 11 - }, - "identifierChain": [ - { - "name": "bar" - } - ] - }, - { - "type": "table", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 12, - "last_column": 15 - }, - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 20, - "last_column": 22 - }, - "identifierChain": [ - { - "name": "id" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ], - "qualified": false - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 28, - "last_column": 31 - }, - "identifierChain": [ - { - "name": "bla" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ], - "qualified": false - } - ] - } - }, - { - "namePrefix": "should suggest columns", - "beforeCursor": "UPDATE bar.foo SET bla = 'foo' WHERE ", - "afterCursor": "", - "expectedResult": { - "lowerCase": false, - "suggestFunctions": {}, - "suggestColumns": { - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ] - }, - "suggestFilters": { - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ] - }, - "suggestKeywords": ["EXISTS", "NOT EXISTS"], - "locations": [ - { - "type": "statement", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 1, - "last_column": 37 - } - }, - { - "type": "database", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 8, - "last_column": 11 - }, - "identifierChain": [ - { - "name": "bar" - } - ] - }, - { - "type": "table", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 12, - "last_column": 15 - }, - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 20, - "last_column": 23 - }, - "identifierChain": [ - { - "name": "bla" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ], - "qualified": false - } - ] - } - }, - { - "namePrefix": "should suggest values", - "beforeCursor": "UPDATE bar.foo SET bla = 'foo' WHERE id = ", - "afterCursor": "", - "containsKeywords": ["CASE"], - "expectedResult": { - "locations": [ - { - "type": "statement", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 1, - "last_column": 42 - } - }, - { - "type": "database", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 8, - "last_column": 11 - }, - "identifierChain": [ - { - "name": "bar" - } - ] - }, - { - "type": "table", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 12, - "last_column": 15 - }, - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 20, - "last_column": 23 - }, - "identifierChain": [ - { - "name": "bla" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ], - "qualified": false - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 38, - "last_column": 40 - }, - "identifierChain": [ - { - "name": "id" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ], - "qualified": false - } - ], - "suggestFunctions": { - "types": ["COLREF"] - }, - "suggestValues": {}, - "colRef": { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - }, - { - "name": "id" - } - ] - }, - "suggestColumns": { - "types": ["COLREF"], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ] - }, - "lowerCase": false - } - }, - { - "namePrefix": "should suggest columns", - "beforeCursor": "UPDATE bar.foo SET bla = 'foo' WHERE id = 1 AND ", - "afterCursor": "", - "containsKeywords": ["CASE"], - "expectedResult": { - "lowerCase": false, - "suggestFunctions": {}, - "suggestColumns": { - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ] - }, - "suggestFilters": { - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ] - }, - "locations": [ - { - "type": "statement", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 1, - "last_column": 48 - } - }, - { - "type": "database", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 8, - "last_column": 11 - }, - "identifierChain": [ - { - "name": "bar" - } - ] - }, - { - "type": "table", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 12, - "last_column": 15 - }, - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 20, - "last_column": 23 - }, - "identifierChain": [ - { - "name": "bla" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ], - "qualified": false - }, - { - "type": "column", - "location": { - "first_line": 1, - "last_line": 1, - "first_column": 38, - "last_column": 40 - }, - "identifierChain": [ - { - "name": "id" - } - ], - "tables": [ - { - "identifierChain": [ - { - "name": "bar" - }, - { - "name": "foo" - } - ] - } - ], - "qualified": false - } - ] - } - }, - { - "namePrefix": "should suggest tables with set error", - "beforeCursor": "UPDATE ", - "afterCursor": " SET ", - "noErrors": false, - "expectedErrors": [ - { - "text": "", - "token": "EOF", - "line": 0, - "loc": { - "first_line": 1, - "last_line": 1, - "first_column": 15, - "last_column": 15 - } - } - ], - "expectedResult": { - "lowerCase": false, - "suggestTables": {}, - "suggestDatabases": { - "appendDot": true - } - } - }, - { - "namePrefix": "should suggest tables with set error and empty where", - "beforeCursor": "UPDATE ", - "afterCursor": " SET WHERE ", - "expectedErrors": [ - { - "text": "WHERE", - "token": "WHERE", - "line": 0, - "loc": { - "first_line": 1, - "last_line": 1, - "first_column": 16, - "last_column": 21 - } - } - ], - "expectedResult": { - "lowerCase": false, - "suggestTables": {}, - "suggestDatabases": { - "appendDot": true - } - } - } -] diff --git a/src/parsing/parsers/generic/jison/update/update_table.test.ts b/src/parsing/parsers/generic/jison/update/update_table.test.ts new file mode 100644 index 00000000..d6e6a97c --- /dev/null +++ b/src/parsing/parsers/generic/jison/update/update_table.test.ts @@ -0,0 +1,497 @@ +import {expect, test} from '@jest/globals'; + +import { + ColumnReference, + ColumnSuggestion, + DatabasesSuggestion, + FiltersSuggestion, + FunctionsSuggestion, + KeywordSuggestion, + ParserSyntaxError, + StatementPart, + TablesSuggestion, + ValuesSuggestion, + parseGenericSql, + parseGenericSqlWithoutCursor, +} from '../../../../index'; + +test('should suggest UPDATE', () => { + const parseResult = parseGenericSql('', ''); + + expect(parseResult.errors).toBeUndefined(); + + const suggestion: KeywordSuggestion = {value: 'UPDATE', weight: -1}; + expect(parseResult.suggestKeywords).toContainEqual(suggestion); +}); + +test('should suggest SET', () => { + const parseResult = parseGenericSql('UPDATE test_table ', ''); + + expect(parseResult.errors).toBeUndefined(); + + const suggestion: KeywordSuggestion = {value: 'SET', weight: -1}; + expect(parseResult.suggestKeywords).toContainEqual(suggestion); +}); + +test('should suggest WHERE', () => { + const parseResult = parseGenericSql( + 'UPDATE test_table SET test_column_1=1, test_column_2=2 ', + '', + ); + + expect(parseResult.errors).toBeUndefined(); + + const suggestion: KeywordSuggestion = {value: 'WHERE', weight: -1}; + expect(parseResult.suggestKeywords).toContainEqual(suggestion); +}); + +test('should suggest equal sign', () => { + const parseResult = parseGenericSql('UPDATE test_table SET test_column ', ''); + + expect(parseResult.errors).toBeUndefined(); + + const suggestion: KeywordSuggestion = {value: '=', weight: -1}; + expect(parseResult.suggestKeywords).toContainEqual(suggestion); +}); + +test('should suggest databases or table', () => { + const parseResult = parseGenericSql('UPDATE ', ''); + + expect(parseResult.errors).toBeUndefined(); + + const tablesSuggestion: TablesSuggestion = {}; + expect(parseResult.suggestTables).toEqual(tablesSuggestion); + + const databasesSuggestion: DatabasesSuggestion = { + appendDot: true, + }; + expect(parseResult.suggestDatabases).toEqual(databasesSuggestion); +}); + +test('should suggest databases or table midway', () => { + const parseResult = parseGenericSql('UPDATE test_table', ''); + + expect(parseResult.errors).toBeUndefined(); + + const tablesSuggestion: TablesSuggestion = {}; + expect(parseResult.suggestTables).toEqual(tablesSuggestion); + + const databasesSuggestion: DatabasesSuggestion = { + appendDot: true, + }; + expect(parseResult.suggestDatabases).toEqual(databasesSuggestion); +}); + +test('should suggest tables after database', () => { + const parseResult = parseGenericSql('UPDATE test_database.', ''); + + expect(parseResult.errors).toBeUndefined(); + + const tablesSuggestion: TablesSuggestion = { + identifierChain: [ + { + name: 'test_database', + }, + ], + }; + expect(parseResult.suggestTables).toEqual(tablesSuggestion); +}); + +test('should suggest tables midway after database', () => { + const parseResult = parseGenericSql('UPDATE test_database.test_table', ''); + + expect(parseResult.errors).toBeUndefined(); + + const tablesSuggestion: TablesSuggestion = { + identifierChain: [ + { + name: 'test_database', + }, + ], + }; + expect(parseResult.suggestTables).toEqual(tablesSuggestion); +}); + +test('should suggest columns', () => { + const parseResult = parseGenericSql('UPDATE test_database.test_table SET ', ''); + + expect(parseResult.errors).toBeUndefined(); + + const columnSuggestion: ColumnSuggestion = { + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + }; + expect(parseResult.suggestColumns).toEqual(columnSuggestion); +}); + +test('should suggest columns after comma', () => { + const parseResult = parseGenericSql( + 'UPDATE test_database.test_table SET test_column_1=1, test_column_2=2, ', + '', + ); + + expect(parseResult.errors).toBeUndefined(); + + const columnSuggestion: ColumnSuggestion = { + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + }; + expect(parseResult.suggestColumns).toEqual(columnSuggestion); +}); + +test('should suggest columns, functions, filters, keywords after WHERE', () => { + const parseResult = parseGenericSql( + 'UPDATE test_database.test_table SET test_column_1=1 WHERE ', + '', + ); + + expect(parseResult.errors).toBeUndefined(); + + const columnSuggestion: ColumnSuggestion = { + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + }; + expect(parseResult.suggestColumns).toEqual(columnSuggestion); + + const functionsSuggestion: FunctionsSuggestion = {}; + expect(parseResult.suggestFunctions).toEqual(functionsSuggestion); + + const filtersSuggestion: FiltersSuggestion = { + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + }; + expect(parseResult.suggestFilters).toEqual(filtersSuggestion); + + const keywordsSuggestion: KeywordSuggestion[] = [ + {value: 'EXISTS', weight: -1}, + {value: 'NOT EXISTS', weight: -1}, + ]; + expect(parseResult.suggestKeywords).toEqual(keywordsSuggestion); +}); + +test('should suggest columns, functions, values, keywords, colRef after equal sign', () => { + const parseResult = parseGenericSql( + 'UPDATE test_database.test_table SET test_column_1=1 WHERE test_column_2 = ', + '', + ); + + expect(parseResult.errors).toBeUndefined(); + + const columnSuggestion: ColumnSuggestion = { + types: ['COLREF'], + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + }; + expect(parseResult.suggestColumns).toEqual(columnSuggestion); + + const functionsSuggestion: FunctionsSuggestion = {types: ['COLREF']}; + expect(parseResult.suggestFunctions).toEqual(functionsSuggestion); + + const valuesSuggestion: ValuesSuggestion = {}; + expect(parseResult.suggestValues).toEqual(valuesSuggestion); + + const keywordSuggestion: KeywordSuggestion = {value: 'CASE', weight: 450}; + expect(parseResult.suggestKeywords).toContainEqual(keywordSuggestion); + + const colRef: ColumnReference = { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + { + name: 'test_column_2', + }, + ], + }; + expect(parseResult.colRef).toEqual(colRef); +}); + +test('should suggest columns, functions, filters after AND', () => { + const parseResult = parseGenericSql( + 'UPDATE test_database.test_table SET test_column_1=1 WHERE test_column_2=2 AND ', + '', + ); + + expect(parseResult.errors).toBeUndefined(); + + const columnSuggestion: ColumnSuggestion = { + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + }; + expect(parseResult.suggestColumns).toEqual(columnSuggestion); + + const functionsSuggestion: FunctionsSuggestion = {}; + expect(parseResult.suggestFunctions).toEqual(functionsSuggestion); + + const filtersSuggestion: FiltersSuggestion = { + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + }; + expect(parseResult.suggestFilters).toEqual(filtersSuggestion); +}); + +test('should suggest databases or table with SET error', () => { + const parseResult = parseGenericSql('UPDATE ', ' SET '); + + const error: Partial = { + text: '', + token: 'EOF', + line: 0, + loc: { + first_line: 1, + last_line: 1, + first_column: 15, + last_column: 15, + }, + }; + expect(parseResult.errors).toContainEqual(expect.objectContaining(error)); + + const tablesSuggestion: TablesSuggestion = {}; + expect(parseResult.suggestTables).toEqual(tablesSuggestion); + + const databasesSuggestion: DatabasesSuggestion = { + appendDot: true, + }; + expect(parseResult.suggestDatabases).toEqual(databasesSuggestion); +}); + +test('should suggest databases or table with SET error and empty WHERE', () => { + const parseResult = parseGenericSql('UPDATE ', ' SET WHERE '); + + const error: Partial = { + text: 'WHERE', + token: 'WHERE', + line: 0, + loc: { + first_line: 1, + last_line: 1, + first_column: 16, + last_column: 21, + }, + }; + expect(parseResult.errors).toContainEqual(expect.objectContaining(error)); + + const tablesSuggestion: TablesSuggestion = {}; + expect(parseResult.suggestTables).toEqual(tablesSuggestion); + + const databasesSuggestion: DatabasesSuggestion = { + appendDot: true, + }; + expect(parseResult.suggestDatabases).toEqual(databasesSuggestion); +}); + +test('should properly fill locations', () => { + const parseResult = parseGenericSqlWithoutCursor( + 'UPDATE test_database.test_table SET test_column_1=1 WHERE test_column_2=2 AND test_column_3=3;', + ); + + expect(parseResult.errors).toBeUndefined(); + + const locations: StatementPart[] = [ + { + type: 'statement', + location: { + first_line: 1, + last_line: 1, + first_column: 1, + last_column: 94, + }, + }, + { + type: 'database', + location: { + first_line: 1, + last_line: 1, + first_column: 8, + last_column: 21, + }, + identifierChain: [ + { + name: 'test_database', + }, + ], + }, + { + type: 'table', + location: { + first_line: 1, + last_line: 1, + first_column: 22, + last_column: 32, + }, + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + { + type: 'statementType', + identifier: 'SET', + location: { + first_column: 33, + first_line: 1, + last_column: 36, + last_line: 1, + }, + }, + { + type: 'column', + location: { + first_line: 1, + last_line: 1, + first_column: 37, + last_column: 50, + }, + identifierChain: [ + { + name: 'test_column_1', + }, + ], + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + qualified: false, + }, + { + type: 'column', + location: { + first_line: 1, + last_line: 1, + first_column: 59, + last_column: 72, + }, + identifierChain: [ + { + name: 'test_column_2', + }, + ], + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + qualified: false, + }, + { + type: 'column', + location: { + first_line: 1, + last_line: 1, + first_column: 79, + last_column: 92, + }, + identifierChain: [ + { + name: 'test_column_3', + }, + ], + tables: [ + { + identifierChain: [ + { + name: 'test_database', + }, + { + name: 'test_table', + }, + ], + }, + ], + qualified: false, + }, + ]; + expect(parseResult.locations).toEqual(locations); +});