@@ -238,41 +238,38 @@ impl CompletionScore<'_> {
238238 }
239239
240240 fn check_columns_in_stmt ( & mut self , ctx : & CompletionContext ) {
241- match self . data {
242- CompletionRelevanceData :: Column ( column) => {
243- /*
244- * Columns can be mentioned in one of two ways:
245- *
246- * 1) With an alias: `select u.id`.
247- * If the currently investigated suggestion item is "id" of the "users" table,
248- * we want to check
249- * a) whether the name of the column matches.
250- * b) whether we know which table is aliased by "u" (if we don't, we ignore the alias).
251- * c) whether the aliased table matches the currently investigated suggestion item's table.
252- *
253- * 2) Without an alias: `select id`.
254- * In that case, we only check whether the mentioned column fits our currently investigated
255- * suggestion item's name.
256- *
257- */
258- if ctx
259- . mentioned_columns
260- . get ( & ctx. wrapping_clause_type )
261- . is_some_and ( |set| {
262- set. iter ( ) . any ( |mentioned| match mentioned. alias . as_ref ( ) {
263- Some ( als) => {
264- let aliased_table = ctx. mentioned_table_aliases . get ( als. as_str ( ) ) ;
265- column. name == mentioned. column
266- && aliased_table. is_none_or ( |t| t == & column. table_name )
267- }
268- None => mentioned. column == column. name ,
269- } )
241+ if let CompletionRelevanceData :: Column ( column) = self . data {
242+ /*
243+ * Columns can be mentioned in one of two ways:
244+ *
245+ * 1) With an alias: `select u.id`.
246+ * If the currently investigated suggestion item is "id" of the "users" table,
247+ * we want to check
248+ * a) whether the name of the column matches.
249+ * b) whether we know which table is aliased by "u" (if we don't, we ignore the alias).
250+ * c) whether the aliased table matches the currently investigated suggestion item's table.
251+ *
252+ * 2) Without an alias: `select id`.
253+ * In that case, we only check whether the mentioned column fits our currently investigated
254+ * suggestion item's name.
255+ *
256+ */
257+ if ctx
258+ . mentioned_columns
259+ . get ( & ctx. wrapping_clause_type )
260+ . is_some_and ( |set| {
261+ set. iter ( ) . any ( |mentioned| match mentioned. alias . as_ref ( ) {
262+ Some ( als) => {
263+ let aliased_table = ctx. mentioned_table_aliases . get ( als. as_str ( ) ) ;
264+ column. name == mentioned. column
265+ && aliased_table. is_none_or ( |t| t == & column. table_name )
266+ }
267+ None => mentioned. column == column. name ,
270268 } )
271- {
272- self . score -= 10 ;
273- }
269+ } )
270+ {
271+ self . score -= 10 ;
274272 }
275- _ => { }
276273 }
277274 }
278275}
0 commit comments