Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(completion): definition for mssql column (#12520)
rebelice70607cb14971
diff --git a/backend/plugin/parser/tsql/completion.go b/backend/plugin/parser/tsql/completion.goindex 0d087e8c46..6c2838e711 100644--- a/backend/plugin/parser/tsql/completion.go+++ b/backend/plugin/parser/tsql/completion.go@@ -318,9 +318,16 @@ func (m CompletionMap) insertMetadataColumns(c *Completer, linkedServer string,tableMetadata := schemaMetadata.GetTable(table)for _, column := range tableMetadata.GetColumns() {if _, ok := m[column.Name]; !ok {+ definition := fmt.Sprintf("%s | %s", table, column.Type)+ if !column.Nullable {+ definition += ", NOT NULL"+ }+ comment := column.UserCommentm[column.Name] = base.Candidate{- Type: base.CandidateTypeColumn,- Text: c.quotedIdentifierIfNeeded(column.Name),+ Type: base.CandidateTypeColumn,+ Text: c.quotedIdentifierIfNeeded(column.Name),+ Definition: definition,+ Comment: comment,}}}diff --git a/backend/plugin/parser/tsql/completion_test.go b/backend/plugin/parser/tsql/completion_test.goindex 8551b77574..19cc7625e6 100644--- a/backend/plugin/parser/tsql/completion_test.go+++ b/backend/plugin/parser/tsql/completion_test.go@@ -110,9 +110,11 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{Columns: []*storepb.ColumnMetadata{{Name: "Id",+ Type: "int",},{Name: "Name",+ Type: "varchar",},},},@@ -121,9 +123,11 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{Columns: []*storepb.ColumnMetadata{{Name: "EmployeeId",+ Type: "int",},{Name: "Street",+ Type: "varchar",},},},@@ -137,9 +141,11 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{Columns: []*storepb.ColumnMetadata{{Name: "Id",+ Type: "int",},{Name: "SalaryUpBound",+ Type: "int",},},},@@ -158,9 +164,11 @@ var databaseMetadatas = []*storepb.DatabaseSchemaMetadata{Columns: []*storepb.ColumnMetadata{{Name: "Id",+ Type: "int",},{Name: "ParentName",+ Type: "varchar",},},},diff --git a/backend/plugin/parser/tsql/test-data/test_completion.yaml b/backend/plugin/parser/tsql/test-data/test_completion.yamlindex 7b4a74d8fb..fdf5b252cf 100644--- a/backend/plugin/parser/tsql/test-data/test_completion.yaml+++ b/backend/plugin/parser/tsql/test-data/test_completion.yaml@@ -27,11 +27,11 @@comment: ""- text: EmployeeIdtype: COLUMN- definition: ""+ definition: Address | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: ""+ definition: Employees | int, NOT NULLcomment: ""- text: IdAliastype: COLUMN@@ -39,22 +39,22 @@comment: ""- text: Nametype: COLUMN- definition: ""+ definition: Employees | varchar, NOT NULLcomment: ""- text: Streettype: COLUMN- definition: ""+ definition: Address | varchar, NOT NULLcomment: ""- description: Table alias referenced by select iteminput: SELECT tableAlias.| FROM Employees AS tableAlias;want:- text: Idtype: COLUMN- definition: ""+ definition: Employees | int, NOT NULLcomment: ""- text: Nametype: COLUMN- definition: ""+ definition: Employees | varchar, NOT NULLcomment: ""- description: Full column name considering CTEinput: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT MyCTE_01.| FROM MyCTE_01;@@ -96,19 +96,19 @@comment: ""- text: EmployeeIdtype: COLUMN- definition: ""+ definition: Address | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: ""+ definition: Employees | int, NOT NULLcomment: ""- text: Nametype: COLUMN- definition: ""+ definition: Employees | varchar, NOT NULLcomment: ""- text: Streettype: COLUMN- definition: ""+ definition: Address | varchar, NOT NULLcomment: ""- description: Asterisk appearred in select item listinput: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT |.* FROM MyCTE_01 JOIN dbo.Address ON MyCTE_01.EmployeeID = dbo.Address.EmployeeID@@ -143,19 +143,19 @@comment: ""- text: EmployeeIdtype: COLUMN- definition: ""+ definition: Address | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: ""+ definition: Employees | int, NOT NULLcomment: ""- text: Nametype: COLUMN- definition: ""+ definition: Employees | varchar, NOT NULLcomment: ""- text: Streettype: COLUMN- definition: ""+ definition: Address | varchar, NOT NULLcomment: ""- description: Completion should not consider CTE if no schema specifiedinput: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT * FROM MySchema.|@@ -166,11 +166,11 @@comment: ""- text: Idtype: COLUMN- definition: ""+ definition: SalaryLevel | int, NOT NULLcomment: ""- text: SalaryUpBoundtype: COLUMN- definition: ""+ definition: SalaryLevel | int, NOT NULLcomment: ""- description: Completion should consider CTE if no schema specifiedinput: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT * FROM |@@ -205,19 +205,19 @@comment: ""- text: EmployeeIdtype: COLUMN- definition: ""+ definition: Address | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: ""+ definition: Employees | int, NOT NULLcomment: ""- text: Nametype: COLUMN- definition: ""+ definition: Employees | varchar, NOT NULLcomment: ""- text: Streettype: COLUMN- definition: ""+ definition: Address | varchar, NOT NULLcomment: ""- description: Completion table in specify schemainput: SELECT * FROM dbo.|@@ -232,19 +232,19 @@comment: ""- text: EmployeeIdtype: COLUMN- definition: ""+ definition: Address | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: ""+ definition: Employees | int, NOT NULLcomment: ""- text: Nametype: COLUMN- definition: ""+ definition: Employees | varchar, NOT NULLcomment: ""- text: Streettype: COLUMN- definition: ""+ definition: Address | varchar, NOT NULLcomment: ""- description: Completion table for simple selectinput: SELECT * FROM |@@ -275,17 +275,17 @@comment: ""- text: EmployeeIdtype: COLUMN- definition: ""+ definition: Address | int, NOT NULLcomment: ""- text: Idtype: COLUMN- definition: ""+ definition: Employees | int, NOT NULLcomment: ""- text: Nametype: COLUMN- definition: ""+ definition: Employees | varchar, NOT NULLcomment: ""- text: Streettype: COLUMN- definition: ""+ definition: Address | varchar, NOT NULLcomment: ""