@@ -47,6 +47,7 @@ impl CompletionScore<'_> {
4747 CompletionRelevanceData :: Column ( c) => c. name . as_str ( ) . to_ascii_lowercase ( ) ,
4848 CompletionRelevanceData :: Schema ( s) => s. name . as_str ( ) . to_ascii_lowercase ( ) ,
4949 CompletionRelevanceData :: Policy ( p) => p. name . as_str ( ) . to_ascii_lowercase ( ) ,
50+ CompletionRelevanceData :: Role ( r) => r. name . as_str ( ) . to_ascii_lowercase ( ) ,
5051 } ;
5152
5253 let fz_matcher = SkimMatcherV2 :: default ( ) ;
@@ -126,6 +127,8 @@ impl CompletionScore<'_> {
126127 WrappingClause :: PolicyName => 25 ,
127128 _ => -50 ,
128129 } ,
130+
131+ CompletionRelevanceData :: Role ( _) => 0 ,
129132 }
130133 }
131134
@@ -160,6 +163,7 @@ impl CompletionScore<'_> {
160163 _ => -50 ,
161164 } ,
162165 CompletionRelevanceData :: Policy ( _) => 0 ,
166+ CompletionRelevanceData :: Role ( _) => 0 ,
163167 }
164168 }
165169
@@ -178,7 +182,10 @@ impl CompletionScore<'_> {
178182 Some ( n) => n,
179183 } ;
180184
181- let data_schema = self . get_schema_name ( ) ;
185+ let data_schema = match self . get_schema_name ( ) {
186+ Some ( s) => s,
187+ None => return ,
188+ } ;
182189
183190 if schema_name == data_schema {
184191 self . score += 25 ;
@@ -187,13 +194,14 @@ impl CompletionScore<'_> {
187194 }
188195 }
189196
190- fn get_schema_name ( & self ) -> & str {
197+ fn get_schema_name ( & self ) -> Option < & str > {
191198 match self . data {
192- CompletionRelevanceData :: Function ( f) => f. schema . as_str ( ) ,
193- CompletionRelevanceData :: Table ( t) => t. schema . as_str ( ) ,
194- CompletionRelevanceData :: Column ( c) => c. schema_name . as_str ( ) ,
195- CompletionRelevanceData :: Schema ( s) => s. name . as_str ( ) ,
196- CompletionRelevanceData :: Policy ( p) => p. schema_name . as_str ( ) ,
199+ CompletionRelevanceData :: Function ( f) => Some ( f. schema . as_str ( ) ) ,
200+ CompletionRelevanceData :: Table ( t) => Some ( t. schema . as_str ( ) ) ,
201+ CompletionRelevanceData :: Column ( c) => Some ( c. schema_name . as_str ( ) ) ,
202+ CompletionRelevanceData :: Schema ( s) => Some ( s. name . as_str ( ) ) ,
203+ CompletionRelevanceData :: Policy ( p) => Some ( p. schema_name . as_str ( ) ) ,
204+ CompletionRelevanceData :: Role ( p) => None ,
197205 }
198206 }
199207
@@ -212,7 +220,10 @@ impl CompletionScore<'_> {
212220 _ => { }
213221 }
214222
215- let schema = self . get_schema_name ( ) . to_string ( ) ;
223+ let schema = match self . get_schema_name ( ) {
224+ Some ( s) => s. to_string ( ) ,
225+ None => return ,
226+ } ;
216227 let table_name = match self . get_table_name ( ) {
217228 Some ( t) => t,
218229 None => return ,
@@ -234,7 +245,10 @@ impl CompletionScore<'_> {
234245 }
235246
236247 fn check_is_user_defined ( & mut self ) {
237- let schema = self . get_schema_name ( ) . to_string ( ) ;
248+ let schema = match self . get_schema_name ( ) {
249+ Some ( s) => s. to_string ( ) ,
250+ None => return ,
251+ } ;
238252
239253 let system_schemas = [ "pg_catalog" , "information_schema" , "pg_toast" ] ;
240254
0 commit comments