From ddf36d4f196a077b2ebc9d76efeeb94bd5dcc250 Mon Sep 17 00:00:00 2001 From: Rich Piazza Date: Sat, 14 Dec 2024 11:46:08 -0500 Subject: [PATCH] add REGEXP constraint to sqlite --- .../relational_db/database_backends/sqlite_backend.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/stix2/datastore/relational_db/database_backends/sqlite_backend.py b/stix2/datastore/relational_db/database_backends/sqlite_backend.py index b6cea195..a839b853 100644 --- a/stix2/datastore/relational_db/database_backends/sqlite_backend.py +++ b/stix2/datastore/relational_db/database_backends/sqlite_backend.py @@ -57,14 +57,11 @@ def determine_sql_type_for_timestamp_property(): # noqa: F811 def array_allowed(): return False - def create_regex_constraint_expression(self, column_name, pattern): - return None - - def create_regex_constraint_and_expression(self, clause1, clause2): - return None + def create_regex_constraint_clause(self, column_name, pattern): + return f"{column_name} REGEXP {pattern}" @staticmethod def next_id(data_sink): - # hack, which is nit reliable + # hack, which is not reliable, must look for a better solution SQLiteBackend.temp_sequence_count += 1 return SQLiteBackend.temp_sequence_count