@@ -79,7 +79,7 @@ impl CompletionScore<'_> {
7979 } ;
8080
8181 let has_mentioned_tables = ctx. has_any_mentioned_relations ( ) ;
82- let has_mentioned_schema = ctx. schema_or_alias_name . is_some ( ) ;
82+ let has_qualifier = ctx. identifier_qualifiers . 1 . is_some ( ) ;
8383
8484 self . score += match self . data {
8585 CompletionRelevanceData :: Table ( _) => match clause_type {
@@ -122,13 +122,13 @@ impl CompletionScore<'_> {
122122 _ => -15 ,
123123 } ,
124124 CompletionRelevanceData :: Schema ( _) => match clause_type {
125- WrappingClause :: From if !has_mentioned_schema => 15 ,
126- WrappingClause :: Join { .. } if !has_mentioned_schema => 15 ,
127- WrappingClause :: Update if !has_mentioned_schema => 15 ,
128- WrappingClause :: Delete if !has_mentioned_schema => 15 ,
129- WrappingClause :: AlterPolicy if !has_mentioned_schema => 15 ,
130- WrappingClause :: DropPolicy if !has_mentioned_schema => 15 ,
131- WrappingClause :: CreatePolicy if !has_mentioned_schema => 15 ,
125+ WrappingClause :: From if !has_qualifier => 15 ,
126+ WrappingClause :: Join { .. } if !has_qualifier => 15 ,
127+ WrappingClause :: Update if !has_qualifier => 15 ,
128+ WrappingClause :: Delete if !has_qualifier => 15 ,
129+ WrappingClause :: AlterPolicy if !has_qualifier => 15 ,
130+ WrappingClause :: DropPolicy if !has_qualifier => 15 ,
131+ WrappingClause :: CreatePolicy if !has_qualifier => 15 ,
132132 _ => -50 ,
133133 } ,
134134 CompletionRelevanceData :: Policy ( _) => match clause_type {
@@ -149,15 +149,15 @@ impl CompletionScore<'_> {
149149 Some ( wn) => wn,
150150 } ;
151151
152- let has_mentioned_schema = ctx. schema_or_alias_name . is_some ( ) ;
152+ let has_single_qualifier = matches ! ( ctx. identifier_qualifiers , ( None , Some ( _ ) ) ) ;
153153 let has_node_text = ctx
154154 . get_node_under_cursor_content ( )
155155 . is_some_and ( |txt| !sanitization:: is_sanitized_token ( txt. as_str ( ) ) ) ;
156156
157157 self . score += match self . data {
158158 CompletionRelevanceData :: Table ( _) => match wrapping_node {
159- WrappingNode :: Relation if has_mentioned_schema => 15 ,
160- WrappingNode :: Relation if !has_mentioned_schema => 10 ,
159+ WrappingNode :: Relation if has_single_qualifier => 15 ,
160+ WrappingNode :: Relation if !has_single_qualifier => 10 ,
161161 WrappingNode :: BinaryExpression => 5 ,
162162 _ => -50 ,
163163 } ,
@@ -172,8 +172,8 @@ impl CompletionScore<'_> {
172172 _ => -15 ,
173173 } ,
174174 CompletionRelevanceData :: Schema ( _) => match wrapping_node {
175- WrappingNode :: Relation if !has_mentioned_schema && !has_node_text => 15 ,
176- WrappingNode :: Relation if !has_mentioned_schema && has_node_text => 0 ,
175+ WrappingNode :: Relation if !has_single_qualifier && !has_node_text => 15 ,
176+ WrappingNode :: Relation if !has_single_qualifier && has_node_text => 0 ,
177177 _ => -50 ,
178178 } ,
179179 CompletionRelevanceData :: Policy ( _) => 0 ,
@@ -191,20 +191,27 @@ impl CompletionScore<'_> {
191191 }
192192
193193 fn check_matches_schema ( & mut self , ctx : & TreesitterContext ) {
194- let schema_name = match ctx. schema_or_alias_name . as_ref ( ) {
195- None => return ,
196- Some ( n) => n. replace ( '"' , "" ) ,
197- } ;
194+ if matches ! ( ctx. identifier_qualifiers, ( None , None ) ) {
195+ return ;
196+ }
197+
198+ let schema_from_qualifier = ctx
199+ . identifier_qualifiers
200+ . 1
201+ . as_ref ( )
202+ . map ( |n| n. replace ( '"' , "" ) ) ;
198203
199204 let data_schema = match self . get_schema_name ( ) {
200205 Some ( s) => s,
201206 None => return ,
202207 } ;
203208
204- if schema_name == data_schema {
205- self . score += 25 ;
206- } else {
207- self . score -= 10 ;
209+ if let Some ( schema_name) = schema_from_qualifier {
210+ if schema_name == data_schema {
211+ self . score += 25 ;
212+ } else {
213+ self . score -= 10 ;
214+ }
208215 }
209216 }
210217
0 commit comments