Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: fix unit tests (#14075)
rebelice638c1e99271a
diff --git a/backend/plugin/parser/tsql/completion_test.go b/backend/plugin/parser/tsql/completion_test.goindex dac6cea8e2..8d6f705354 100644--- a/backend/plugin/parser/tsql/completion_test.go+++ b/backend/plugin/parser/tsql/completion_test.go@@ -4,6 +4,7 @@ import ("context""io""os"+ "sort""strings""testing"@@ -70,6 +71,15 @@ func TestCompletion(t *testing.T) {filteredResult = append(filteredResult, r)}}+ sort.Slice(filteredResult, func(i, j int) bool {+ if filteredResult[i].Type != filteredResult[j].Type {+ return filteredResult[i].Type < filteredResult[j].Type+ }+ if filteredResult[i].Text != filteredResult[j].Text {+ return filteredResult[i].Text < filteredResult[j].Text+ }+ return filteredResult[i].Definition < filteredResult[j].Definition+ })if record {tests[i].Want = filteredResultdiff --git a/backend/plugin/parser/tsql/test-data/test_completion.yaml b/backend/plugin/parser/tsql/test-data/test_completion.yamlindex 8dd05ed8f2..4af280d051 100644--- a/backend/plugin/parser/tsql/test-data/test_completion.yaml+++ b/backend/plugin/parser/tsql/test-data/test_completion.yaml@@ -3,6 +3,30 @@select count(1) from t1 where id; SELECT * FROM |select * from QRTZ_J0B_DETAILS qjd where J0B_NAME like '%gray';want:+ - text: EmployeeId+ type: COLUMN+ definition: Company.dbo.Address | int, NOT NULL+ comment: ""+ - text: Id+ type: COLUMN+ definition: Company.MySchema.SalaryLevel | int, NOT NULL+ comment: ""+ - text: Id+ type: COLUMN+ definition: Company.dbo.Employees | int, NOT NULL+ comment: ""+ - text: Name+ type: COLUMN+ definition: Company.dbo.Employees | varchar, NOT NULL+ comment: ""+ - text: SalaryUpBound+ type: COLUMN+ definition: Company.MySchema.SalaryLevel | int, NOT NULL+ comment: ""+ - text: Street+ type: COLUMN+ definition: Company.dbo.Address | varchar, NOT NULL+ comment: ""- text: Companytype: DATABASEdefinition: ""@@ -31,17 +55,24 @@type: TABLEdefinition: ""comment: ""+- description: Column alias can be used in order by clause+ input: SELECT Id AS IdAlias, Name FROM Employees ORDER BY |;+ want:- text: EmployeeIdtype: COLUMNdefinition: Company.dbo.Address | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: Company.dbo.Employees | int, NOT NULL+ definition: Company.MySchema.SalaryLevel | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL+ definition: Company.dbo.Employees | int, NOT NULL+ comment: ""+ - text: IdAlias+ type: COLUMN+ definition: ""comment: ""- text: Nametype: COLUMN@@ -55,9 +86,6 @@type: COLUMNdefinition: Company.dbo.Address | varchar, NOT NULLcomment: ""-- description: Column alias can be used in order by clause- input: SELECT Id AS IdAlias, Name FROM Employees ORDER BY |;- want:- text: Companytype: DATABASEdefinition: ""@@ -82,37 +110,39 @@type: TABLEdefinition: ""comment: ""- - text: EmployeeId- type: COLUMN- definition: Company.dbo.Address | int, NOT NULL- comment: ""+- description: Table alias referenced by select item+ input: SELECT tableAlias.| FROM Employees AS tableAlias;+ want:- text: Idtype: COLUMNdefinition: Company.dbo.Employees | int, NOT NULLcomment: ""- - text: Id+ - text: Nametype: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL+ definition: Company.dbo.Employees | varchar, NOT NULLcomment: ""- - text: IdAlias+- description: Full column name considering CTE+ input: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT MyCTE_01.| FROM MyCTE_01;+ want:+ - text: Idtype: COLUMNdefinition: ""comment: ""- text: Nametype: COLUMN- definition: Company.dbo.Employees | varchar, NOT NULL+ definition: ""comment: ""- - text: SalaryUpBound+- description: Full column name+ input: SELECT | FROM Employees;+ want:+ - text: EmployeeIdtype: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL+ definition: Company.dbo.Address | int, NOT NULLcomment: ""- - text: Street+ - text: Idtype: COLUMN- definition: Company.dbo.Address | varchar, NOT NULL+ definition: Company.MySchema.SalaryLevel | int, NOT NULLcomment: ""-- description: Table alias referenced by select item- input: SELECT tableAlias.| FROM Employees AS tableAlias;- want:- text: Idtype: COLUMNdefinition: Company.dbo.Employees | int, NOT NULL@@ -121,20 +151,14 @@type: COLUMNdefinition: Company.dbo.Employees | varchar, NOT NULLcomment: ""-- description: Full column name considering CTE- input: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT MyCTE_01.| FROM MyCTE_01;- want:- - text: Id+ - text: SalaryUpBoundtype: COLUMN- definition: ""+ definition: Company.MySchema.SalaryLevel | int, NOT NULLcomment: ""- - text: Name+ - text: Streettype: COLUMN- definition: ""+ definition: Company.dbo.Address | varchar, NOT NULLcomment: ""-- description: Full column name- input: SELECT | FROM Employees;- want:- text: Companytype: DATABASEdefinition: ""@@ -159,17 +183,20 @@type: TABLEdefinition: ""comment: ""+- description: Asterisk appearred in select item list+ input: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT |.* FROM MyCTE_01 JOIN dbo.Address ON MyCTE_01.EmployeeID = dbo.Address.EmployeeID+ want:- text: EmployeeIdtype: COLUMNdefinition: Company.dbo.Address | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: Company.dbo.Employees | int, NOT NULL+ definition: Company.MySchema.SalaryLevel | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL+ definition: Company.dbo.Employees | int, NOT NULLcomment: ""- text: Nametype: COLUMN@@ -183,9 +210,6 @@type: COLUMNdefinition: Company.dbo.Address | varchar, NOT NULLcomment: ""-- description: Asterisk appearred in select item list- input: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT |.* FROM MyCTE_01 JOIN dbo.Address ON MyCTE_01.EmployeeID = dbo.Address.EmployeeID- want:- text: Companytype: DATABASEdefinition: ""@@ -214,17 +238,35 @@type: TABLEdefinition: ""comment: ""+- description: Completion should not consider CTE if no schema specified+ input: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT * FROM MySchema.|+ want:+ - text: Id+ type: COLUMN+ definition: Company.MySchema.SalaryLevel | int, NOT NULL+ comment: ""+ - text: SalaryUpBound+ type: COLUMN+ definition: Company.MySchema.SalaryLevel | int, NOT NULL+ comment: ""+ - text: SalaryLevel+ type: TABLE+ definition: ""+ comment: ""+- description: Completion should consider CTE if no schema specified+ input: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT * FROM |+ want:- text: EmployeeIdtype: COLUMNdefinition: Company.dbo.Address | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: Company.dbo.Employees | int, NOT NULL+ definition: Company.MySchema.SalaryLevel | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL+ definition: Company.dbo.Employees | int, NOT NULLcomment: ""- text: Nametype: COLUMN@@ -238,24 +280,6 @@type: COLUMNdefinition: Company.dbo.Address | varchar, NOT NULLcomment: ""-- description: Completion should not consider CTE if no schema specified- input: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT * FROM MySchema.|- want:- - text: SalaryLevel- type: TABLE- definition: ""- comment: ""- - text: Id- type: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL- comment: ""- - text: SalaryUpBound- type: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL- comment: ""-- description: Completion should consider CTE if no schema specified- input: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT * FROM |- want:- text: Companytype: DATABASEdefinition: ""@@ -284,6 +308,9 @@type: TABLEdefinition: ""comment: ""+- description: Completion table in specify schema+ input: SELECT * FROM dbo.|+ want:- text: EmployeeIdtype: COLUMNdefinition: Company.dbo.Address | int, NOT NULL@@ -292,25 +319,14 @@type: COLUMNdefinition: Company.dbo.Employees | int, NOT NULLcomment: ""- - text: Id- type: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL- comment: ""- text: Nametype: COLUMNdefinition: Company.dbo.Employees | varchar, NOT NULLcomment: ""- - text: SalaryUpBound- type: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL- comment: ""- text: Streettype: COLUMNdefinition: Company.dbo.Address | varchar, NOT NULLcomment: ""-- description: Completion table in specify schema- input: SELECT * FROM dbo.|- want:- text: Addresstype: TABLEdefinition: ""@@ -319,10 +335,17 @@type: TABLEdefinition: ""comment: ""+- description: Completion table for simple select+ input: SELECT * FROM |+ want:- text: EmployeeIdtype: COLUMNdefinition: Company.dbo.Address | int, NOT NULLcomment: ""+ - text: Id+ type: COLUMN+ definition: Company.MySchema.SalaryLevel | int, NOT NULL+ comment: ""- text: Idtype: COLUMNdefinition: Company.dbo.Employees | int, NOT NULL@@ -331,13 +354,14 @@type: COLUMNdefinition: Company.dbo.Employees | varchar, NOT NULLcomment: ""+ - text: SalaryUpBound+ type: COLUMN+ definition: Company.MySchema.SalaryLevel | int, NOT NULL+ comment: ""- text: Streettype: COLUMNdefinition: Company.dbo.Address | varchar, NOT NULLcomment: ""-- description: Completion table for simple select- input: SELECT * FROM |- want:- text: Companytype: DATABASEdefinition: ""@@ -362,27 +386,3 @@type: TABLEdefinition: ""comment: ""- - text: EmployeeId- type: COLUMN- definition: Company.dbo.Address | int, NOT NULL- comment: ""- - text: Id- type: COLUMN- definition: Company.dbo.Employees | int, NOT NULL- comment: ""- - text: Id- type: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL- comment: ""- - text: Name- type: COLUMN- definition: Company.dbo.Employees | varchar, NOT NULL- comment: ""- - text: SalaryUpBound- type: COLUMN- definition: Company.MySchema.SalaryLevel | int, NOT NULL- comment: ""- - text: Street- type: COLUMN- definition: Company.dbo.Address | varchar, NOT NULL- comment: ""