@@ -149,10 +149,14 @@ pub struct Safety {
149149 #[ doc = "Dropping a NOT NULL constraint may break existing clients." ]
150150 #[ serde( skip_serializing_if = "Option::is_none" ) ]
151151 pub ban_drop_not_null : Option < RuleConfiguration < pglt_analyser:: options:: BanDropNotNull > > ,
152+ #[ doc = "Succinct description of the rule." ]
153+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
154+ pub ban_drop_table : Option < RuleConfiguration < pglt_analyser:: options:: BanDropTable > > ,
152155}
153156impl Safety {
154157 const GROUP_NAME : & ' static str = "safety" ;
155- pub ( crate ) const GROUP_RULES : & ' static [ & ' static str ] = & [ "banDropColumn" , "banDropNotNull" ] ;
158+ pub ( crate ) const GROUP_RULES : & ' static [ & ' static str ] =
159+ & [ "banDropColumn" , "banDropNotNull" , "banDropTable" ] ;
156160 const RECOMMENDED_RULES : & ' static [ & ' static str ] = & [ "banDropColumn" , "banDropNotNull" ] ;
157161 const RECOMMENDED_RULES_AS_FILTERS : & ' static [ RuleFilter < ' static > ] = & [
158162 RuleFilter :: Rule ( Self :: GROUP_NAME , Self :: GROUP_RULES [ 0 ] ) ,
@@ -161,6 +165,7 @@ impl Safety {
161165 const ALL_RULES_AS_FILTERS : & ' static [ RuleFilter < ' static > ] = & [
162166 RuleFilter :: Rule ( Self :: GROUP_NAME , Self :: GROUP_RULES [ 0 ] ) ,
163167 RuleFilter :: Rule ( Self :: GROUP_NAME , Self :: GROUP_RULES [ 1 ] ) ,
168+ RuleFilter :: Rule ( Self :: GROUP_NAME , Self :: GROUP_RULES [ 2 ] ) ,
164169 ] ;
165170 #[ doc = r" Retrieves the recommended rules" ]
166171 pub ( crate ) fn is_recommended_true ( & self ) -> bool {
@@ -187,6 +192,11 @@ impl Safety {
187192 index_set. insert ( RuleFilter :: Rule ( Self :: GROUP_NAME , Self :: GROUP_RULES [ 1 ] ) ) ;
188193 }
189194 }
195+ if let Some ( rule) = self . ban_drop_table . as_ref ( ) {
196+ if rule. is_enabled ( ) {
197+ index_set. insert ( RuleFilter :: Rule ( Self :: GROUP_NAME , Self :: GROUP_RULES [ 2 ] ) ) ;
198+ }
199+ }
190200 index_set
191201 }
192202 pub ( crate ) fn get_disabled_rules ( & self ) -> FxHashSet < RuleFilter < ' static > > {
@@ -201,6 +211,11 @@ impl Safety {
201211 index_set. insert ( RuleFilter :: Rule ( Self :: GROUP_NAME , Self :: GROUP_RULES [ 1 ] ) ) ;
202212 }
203213 }
214+ if let Some ( rule) = self . ban_drop_table . as_ref ( ) {
215+ if rule. is_disabled ( ) {
216+ index_set. insert ( RuleFilter :: Rule ( Self :: GROUP_NAME , Self :: GROUP_RULES [ 2 ] ) ) ;
217+ }
218+ }
204219 index_set
205220 }
206221 #[ doc = r" Checks if, given a rule name, matches one of the rules contained in this category" ]
@@ -245,6 +260,10 @@ impl Safety {
245260 . ban_drop_not_null
246261 . as_ref ( )
247262 . map ( |conf| ( conf. level ( ) , conf. get_options ( ) ) ) ,
263+ "banDropTable" => self
264+ . ban_drop_table
265+ . as_ref ( )
266+ . map ( |conf| ( conf. level ( ) , conf. get_options ( ) ) ) ,
248267 _ => None ,
249268 }
250269 }
0 commit comments