From 41104f2d2efe8dd2fa06995f00959756f2146ba6 Mon Sep 17 00:00:00 2001 From: Ming Fang Date: Tue, 10 Dec 2024 17:39:21 -0500 Subject: [PATCH] Update sql-type methods and reg-ex constraint for SQLite. --- .../database_backends/sqlite_backend.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/stix2/datastore/relational_db/database_backends/sqlite_backend.py b/stix2/datastore/relational_db/database_backends/sqlite_backend.py index 545f928b..d14738ec 100644 --- a/stix2/datastore/relational_db/database_backends/sqlite_backend.py +++ b/stix2/datastore/relational_db/database_backends/sqlite_backend.py @@ -39,6 +39,18 @@ def determine_sql_type_for_hex_property(): # noqa: F811 # return LargeBinary return SQLiteBackend.determine_sql_type_for_string_property() + @staticmethod + def determine_sql_type_for_reference_property(): # noqa: F811 + return Text + + @staticmethod + def determine_sql_type_for_string_property(): # noqa: F811 + return Text + + @staticmethod + def determine_sql_type_for_key_as_id(): # noqa: F811 + return Text + @staticmethod def determine_sql_type_for_timestamp_property(): # noqa: F811 return TIMESTAMP(timezone=True) @@ -49,3 +61,7 @@ def determine_sql_type_for_timestamp_property(): # noqa: F811 @staticmethod def array_allowed(): return False + + @staticmethod + def create_regex_constraint_expression(column_name, pattern): + return f"{column_name} ~ {pattern}"