Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: add tests for completion (#12706)
rebelice5fdda01be471
diff --git a/backend/plugin/parser/mysql/test-data/test_completion.yaml b/backend/plugin/parser/mysql/test-data/test_completion.yamlindex 284a168405..08111345a7 100644--- a/backend/plugin/parser/mysql/test-data/test_completion.yaml+++ b/backend/plugin/parser/mysql/test-data/test_completion.yaml@@ -1,3 +1,23 @@+- input: |-+ select count(1) from t1 where id 'asdfsadf'; SELECT * FROM |+ select * from QRTZ_J0B_DETAILS qjd where J0B_NAME like '%gray';+ want:+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ - text: v1+ type: VIEW+ definition: ""+ comment: ""- input: INSERT INTO t1(|);want:- text: dbdiff --git a/backend/plugin/parser/partiql/test-data/test_completion.yaml b/backend/plugin/parser/partiql/test-data/test_completion.yamlindex 98564178b3..0bcc6190bf 100644--- a/backend/plugin/parser/partiql/test-data/test_completion.yaml+++ b/backend/plugin/parser/partiql/test-data/test_completion.yaml@@ -1,7 +1,14 @@+- description: Multiple statements+ input: |-+ select count(1) from t1 where id; SELECT * FROM |+ select * from QRTZ_J0B_DETAILS qjd where J0B_NAME like '%gray';+ want:+ - text: Music+ type: TABLE+ definition: ""+ comment: ""- description: Tricky- input: -|- SELECT * FROM Music- SELECT * FROM |+ input: -| SELECT * FROM Music SELECT * FROM |- description: Simple Select Complete Tableinput: SELECT * FROM |want:diff --git a/backend/plugin/parser/pg/test-data/test_completion.yaml b/backend/plugin/parser/pg/test-data/test_completion.yamlindex a54edc5a34..d3cf82c851 100644--- a/backend/plugin/parser/pg/test-data/test_completion.yaml+++ b/backend/plugin/parser/pg/test-data/test_completion.yaml@@ -1,3 +1,23 @@+- input: |-+ select count(1) from t1 where id; SELECT * FROM |+ select * from QRTZ_J0B_DETAILS qjd where J0B_NAME like '%gray';+ want:+ - text: public+ type: SCHEMA+ definition: ""+ comment: ""+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ - text: t2+ type: TABLE+ definition: ""+ comment: ""+ - text: v1+ type: VIEW+ definition: ""+ comment: ""- input: SELECT x.| FROM (SELECT * FROM t2) xwant:- text: c1diff --git a/backend/plugin/parser/tokenizer/tokenizer.go b/backend/plugin/parser/tokenizer/tokenizer.goindex c5991bc08f..7672f3f466 100644--- a/backend/plugin/parser/tokenizer/tokenizer.go+++ b/backend/plugin/parser/tokenizer/tokenizer.go@@ -620,7 +620,7 @@ func (t *Tokenizer) SplitStandardMultiSQL() ([]base.SingleSQL, error) {if t.f == nil {res = append(res, base.SingleSQL{Text: text,- LastLine: t.line,+ LastLine: t.line - 1, // Convert to 0-based.Empty: t.emptyStatement,})}@@ -648,7 +648,7 @@ func (t *Tokenizer) SplitStandardMultiSQL() ([]base.SingleSQL, error) {// but we want to get the line of last line of the SQL// which means the line of ')'.// So we need minus the aboveNonBlankLineDistance.- LastLine: t.line - t.aboveNonBlankLineDistance(),+ LastLine: t.line - t.aboveNonBlankLineDistance() - 1, // Convert to 0-based.Empty: t.emptyStatement,})}diff --git a/backend/plugin/parser/tsql/test-data/test_completion.yaml b/backend/plugin/parser/tsql/test-data/test_completion.yamlindex fdf5b252cf..44447fd12f 100644--- a/backend/plugin/parser/tsql/test-data/test_completion.yaml+++ b/backend/plugin/parser/tsql/test-data/test_completion.yaml@@ -1,3 +1,52 @@+- description: Multiple statements+ input: |-+ select count(1) from t1 where id; SELECT * FROM |+ select * from QRTZ_J0B_DETAILS qjd where J0B_NAME like '%gray';+ want:+ - text: Company+ type: DATABASE+ definition: ""+ comment: ""+ - text: School+ type: DATABASE+ definition: ""+ comment: ""+ - text: MySchema+ type: SCHEMA+ definition: ""+ comment: ""+ - text: dbo+ type: SCHEMA+ definition: ""+ comment: ""+ - text: Address+ type: TABLE+ definition: ""+ comment: ""+ - text: Employees+ type: TABLE+ definition: ""+ comment: ""+ - text: qjd+ type: TABLE+ definition: ""+ comment: ""+ - text: EmployeeId+ type: COLUMN+ definition: Address | int, NOT NULL+ comment: ""+ - text: Id+ type: COLUMN+ definition: Employees | int, NOT NULL+ comment: ""+ - text: Name+ type: COLUMN+ definition: Employees | varchar, NOT NULL+ comment: ""+ - text: Street+ type: COLUMN+ definition: Address | varchar, NOT NULL+ comment: ""- description: Column alias can be used in order by clauseinput: SELECT Id AS IdAlias, Name FROM Employees ORDER BY |;want: