Skip to content

Commit

Permalink
refactor: replace delete statement json-test with jest-test in genera…
Browse files Browse the repository at this point in the history
…l parser (#91)

* refactor: replace generic parser delete statement test with jest test

* refactor: add missing @jest/globals imports

* refactor: add review fixes
  • Loading branch information
NikitaShkaruba authored Nov 29, 2023
1 parent e6872d1 commit 7402be4
Show file tree
Hide file tree
Showing 12 changed files with 464 additions and 1,256 deletions.
1,327 changes: 300 additions & 1,027 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@commitlint/config-conventional": "^17.4.4",
"@gravity-ui/prettier-config": "^1.0.1",
"@gravity-ui/tsconfig": "^1.0.0",
"@types/jest": "27.0.2",
"@jest/globals": "^29.7.0",
"husky": "^8.0.3",
"jest": "^29.5.0",
"nano-staged": "^0.8.0",
Expand Down
21 changes: 17 additions & 4 deletions src/parsing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export interface ParseResult {
prependQuestionMark?: boolean;
onlyTables?: boolean;
};
suggestColumns?: {
source: string;
tables: Table[];
};
suggestColumns?: ColumnSuggestion;
suggestAggregateFunctions?: {
tables: Table[],
};
Expand All @@ -38,6 +35,10 @@ export interface ParseResult {
engines: string[],
functionalEngines: string[]
};

// Reasons for those fields are unknown
definitions?: [];
lowerCase: boolean;
}

export type StatementPart =
Expand Down Expand Up @@ -77,8 +78,20 @@ export type StatementPart =
location: Location
missing: boolean
subquery?: true
}
| {
type: 'column'
location: Location,
identifierChain: IdentifierChainEntry[]
tables: Table[]
qualified: boolean,
};

export interface ColumnSuggestion {
source?: string;
tables: Table[];
}

export interface KeywordSuggestion {
value: string;
weight: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// and limitations under the License.

import {clickhouseAutocompleteParser} from './clickhouseAutocompleteParser';
import {describe, expect, it, beforeAll} from '@jest/globals';

// prettier-ignore-start

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import structure from './jison/structure.json';
import type { AutocompleteParser } from '../../lib/types';
import { extractTestCases, runTestCases } from '../../test/testing';
import { assertPartials, CommonParser } from '../../lib/parsing-typed';
import {describe, it} from '@jest/globals';

const jisonFolder = 'src/parsing/parsers/clickhouse/jison';
const groupedTestCases = extractTestCases(jisonFolder, structure.autocomplete);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// and limitations under the License.

import {genericAutocompleteParser} from './genericAutocompleteParser';
import {describe, expect, it, beforeAll} from '@jest/globals';

// prettier-ignore-start

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import structure from './jison/structure.json';
import type { AutocompleteParser } from '../../lib/types';
import { extractTestCases, runTestCases } from '../../test/testing';
import { assertPartials, CommonParser } from '../../lib/parsing-typed';
import {describe, it} from '@jest/globals';

const jisonFolder = 'src/parsing/parsers/generic/jison';
const groupedTestCases = extractTestCases(jisonFolder, structure.autocomplete);
Expand Down
224 changes: 0 additions & 224 deletions src/parsing/parsers/generic/jison/delete/delete.test.json

This file was deleted.

Loading

0 comments on commit 7402be4

Please sign in to comment.