@@ -18,7 +18,7 @@ impl CompletionFilter<'_> {
18
18
self . completable_context ( ctx) ?;
19
19
self . check_clause ( ctx) ?;
20
20
self . check_invocation ( ctx) ?;
21
- self . check_mentioned_schema ( ctx) ?;
21
+ self . check_mentioned_schema_or_alias ( ctx) ?;
22
22
23
23
Some ( ( ) )
24
24
}
@@ -86,54 +86,28 @@ impl CompletionFilter<'_> {
86
86
Some ( ( ) )
87
87
}
88
88
89
- fn check_mentioned_schema ( & self , ctx : & CompletionContext ) -> Option < ( ) > {
89
+ fn check_mentioned_schema_or_alias ( & self , ctx : & CompletionContext ) -> Option < ( ) > {
90
90
if ctx. schema_or_alias_name . is_none ( ) {
91
91
return Some ( ( ) ) ;
92
92
}
93
93
94
- let name = ctx. schema_or_alias_name . as_ref ( ) . unwrap ( ) ;
94
+ let schema_or_alias = ctx. schema_or_alias_name . as_ref ( ) . unwrap ( ) ;
95
95
96
- let does_not_match = match self . data {
97
- CompletionRelevanceData :: Table ( table) => & table. schema != name,
98
- CompletionRelevanceData :: Function ( f) => & f. schema != name,
99
- CompletionRelevanceData :: Column ( _) => {
100
- // columns belong to tables, not schemas
101
- true
102
- }
103
- CompletionRelevanceData :: Schema ( _) => {
104
- // we should never allow schema suggestions if there already was one.
105
- true
106
- }
107
- } ;
96
+ let matches = match self . data {
97
+ CompletionRelevanceData :: Table ( table) => & table. schema == schema_or_alias,
98
+ CompletionRelevanceData :: Function ( f) => & f. schema == schema_or_alias,
99
+ CompletionRelevanceData :: Column ( col) => ctx
100
+ . mentioned_table_aliases
101
+ . get ( schema_or_alias)
102
+ . is_some_and ( |t| t == & col. table_name ) ,
108
103
109
- if does_not_match {
110
- return None ;
111
- }
112
-
113
- Some ( ( ) )
114
- }
115
-
116
- fn check_mentioned_alias ( & self , ctx : & CompletionContext ) -> Option < ( ) > {
117
- if ctx. schema_or_alias_name . is_none ( ) {
118
- return Some ( ( ) ) ;
119
- }
120
-
121
- let name = ctx. schema_or_alias_name . as_ref ( ) . unwrap ( ) ;
122
-
123
- let does_not_match = match self . data {
124
- CompletionRelevanceData :: Table ( table) => & table. schema != name,
125
- CompletionRelevanceData :: Function ( f) => & f. schema != name,
126
- CompletionRelevanceData :: Column ( _) => {
127
- // columns belong to tables, not schemas
128
- true
129
- }
130
104
CompletionRelevanceData :: Schema ( _) => {
131
105
// we should never allow schema suggestions if there already was one.
132
- true
106
+ false
133
107
}
134
108
} ;
135
109
136
- if does_not_match {
110
+ if !matches {
137
111
return None ;
138
112
}
139
113
0 commit comments