Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: ignore column in FROM clause (#15880)

rebelice0772ac049880
diff --git a/backend/plugin/parser/tsql/completion.go b/backend/plugin/parser/tsql/completion.go
index c0c02feca2..0a83c69d23 100644
--- a/backend/plugin/parser/tsql/completion.go
+++ b/backend/plugin/parser/tsql/completion.go
@@ -118,6 +118,12 @@ var (
tsqlparser.TSqlParserRULE_full_table_name: true,
tsqlparser.TSqlParserRULE_asterisk: true,
tsqlparser.TSqlParserRULE_full_column_name: true,
+
+ // The following rules are not used in the completion, we add them to the preferred rules to avoid deep recursion.
+ // Ignore xml_data_type_methods to avoid column completion in FROM clause.
+ tsqlparser.TSqlParserRULE_xml_data_type_methods: true,
+ // Ignore nodes_method to avoid column completion in FROM clause.
+ tsqlparser.TSqlParserRULE_nodes_method: true,
}
)
diff --git a/backend/plugin/parser/tsql/test-data/test_completion.yaml b/backend/plugin/parser/tsql/test-data/test_completion.yaml
index 4af280d051..dce6d39edb 100644
--- a/backend/plugin/parser/tsql/test-data/test_completion.yaml
+++ b/backend/plugin/parser/tsql/test-data/test_completion.yaml
@@ -3,30 +3,6 @@
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: Company
type: DATABASE
definition: ""
@@ -51,10 +27,6 @@
type: TABLE
definition: ""
comment: ""
- - text: qjd
- type: TABLE
- definition: ""
- comment: ""
- description: Column alias can be used in order by clause
input: SELECT Id AS IdAlias, Name FROM Employees ORDER BY |;
want:
@@ -241,14 +213,6 @@
- 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: ""
@@ -256,30 +220,6 @@
- description: Completion should consider CTE if no schema specified
input: WITH MyCTE_01 AS (SELECT * FROM dbo.Employees) SELECT * FROM |
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: Company
type: DATABASE
definition: ""
@@ -311,22 +251,6 @@
- description: Completion table in specify schema
input: SELECT * FROM dbo.|
want:
- - 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: Name
- type: COLUMN
- definition: Company.dbo.Employees | varchar, NOT NULL
- comment: ""
- - text: Street
- type: COLUMN
- definition: Company.dbo.Address | varchar, NOT NULL
- comment: ""
- text: Address
type: TABLE
definition: ""
@@ -338,30 +262,6 @@
- description: Completion table for simple select
input: SELECT * FROM |
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: Company
type: DATABASE
definition: ""