@@ -174,7 +174,7 @@ def create_granular_markings_table(metadata, db_backend, sco_or_sdo):
174174 "marking_ref" ,
175175 db_backend .determine_sql_type_for_reference_property (),
176176 CheckConstraint (
177- "marking_ref ~ '^marking-definition--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" ,
177+ "marking_ref REGEXP '^marking-definition--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" ,
178178 # noqa: E131
179179 ),
180180 ),
@@ -236,7 +236,7 @@ def create_external_references_tables(metadata, db_backend):
236236 db_backend .determine_sql_type_for_key_as_id (),
237237 ForeignKey ("common.core_sdo" + ".id" , ondelete = "CASCADE" ),
238238 CheckConstraint (
239- "id ~ '^[a-z][a-z0-9-]+[a-z0-9]--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" , # noqa: E131
239+ "id REGEXP '^[a-z][a-z0-9-]+[a-z0-9]--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" , # noqa: E131
240240 ),
241241 ),
242242 Column ("source_name" , db_backend .determine_sql_type_for_string_property ()),
@@ -260,7 +260,7 @@ def create_core_table(metadata, db_backend, stix_type_name):
260260 "id" ,
261261 db_backend .determine_sql_type_for_key_as_id (),
262262 CheckConstraint (
263- "id ~ '^[a-z][a-z0-9-]+[a-z0-9]--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" , # noqa: E131
263+ "id REGEXP '^[a-z][a-z0-9-]+[a-z0-9]--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" , # noqa: E131
264264 ),
265265 primary_key = True ,
266266 ),
@@ -272,7 +272,7 @@ def create_core_table(metadata, db_backend, stix_type_name):
272272 "created_by_ref" ,
273273 db_backend .determine_sql_type_for_reference_property (),
274274 CheckConstraint (
275- "created_by_ref ~ '^identity--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" , # noqa: E131
275+ "created_by_ref REGEXP '^identity--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" , # noqa: E131
276276 ),
277277 ),
278278 Column ("created" , db_backend .determine_sql_type_for_timestamp_property ()),
@@ -407,7 +407,7 @@ def generate_table_information(self, name, db_backend, **kwargs): # noqa: F811
407407 self .determine_sql_type (db_backend ),
408408 CheckConstraint (
409409 # this regular expression might accept or reject some legal base64 strings
410- f"{ name } ~ " + "'^[-A-Za-z0-9+/]*={0,3}$'" ,
410+ f"{ name } REGEXP " + "'^[-A-Za-z0-9+/]*={0,3}$'" ,
411411 ),
412412 nullable = not self .required ,
413413 )
@@ -535,7 +535,7 @@ def generate_table_information(self, name, db_backend, **kwargs): # noqa: F811
535535 name ,
536536 self .determine_sql_type (db_backend ),
537537 CheckConstraint (
538- f"{ name } ~ '^{ enum_re } $'" ,
538+ f"{ name } REGEXP '^{ enum_re } $'" ,
539539 ),
540540 nullable = not self .required ,
541541 )
@@ -630,7 +630,7 @@ def generate_table_information(self, name, db_backend, **kwargs): # noqa: F811
630630 db_backend .determine_sql_type_for_key_as_id (),
631631 ForeignKey (foreign_key_column , ondelete = "CASCADE" ),
632632 CheckConstraint (
633- f"{ name } ~ '^{ table_name } " + "--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" ,
633+ f"{ name } REGEXP '^{ table_name } " + "--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" ,
634634 # noqa: E131
635635 ),
636636 primary_key = True ,
@@ -745,13 +745,13 @@ def ref_column(name, specifics, db_backend, auth_type=0):
745745 if auth_type == 0 :
746746 constraint = \
747747 CheckConstraint (
748- f"{ name } ~ '^({ types } )" +
748+ f"{ name } REGEXP '^({ types } )" +
749749 "--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'" ,
750750 )
751751 else :
752752 constraint = \
753753 CheckConstraint (
754- f"(NOT({ name } ~ '^({ types } )')) AND ({ name } ~ " +
754+ f"(NOT({ name } REGEXP '^({ types } )')) AND ({ name } REGEXP " +
755755 "'--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$')" ,
756756 )
757757 return Column (name , db_backend .determine_sql_type_for_reference_property (), constraint )
0 commit comments