Skip to content

Commit 82aad1d

Browse files
committed
more fixes for reg-ex constraints
1 parent 3f06691 commit 82aad1d

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

stix2/datastore/relational_db/database_backends/database_backend_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any
22

3-
from sqlalchemy import Boolean, Float, Integer, Text, create_engine
3+
from sqlalchemy import Boolean, Float, Integer, String, Text, create_engine
44
from sqlalchemy_utils import create_database, database_exists, drop_database
55

66
from stix2.base import (
@@ -88,7 +88,7 @@ def determine_sql_type_for_integer_property(): # noqa: F811
8888

8989
@staticmethod
9090
def determine_sql_type_for_reference_property(): # noqa: F811
91-
return Text
91+
return String(255)
9292

9393
@staticmethod
9494
def determine_sql_type_for_string_property(): # noqa: F811
@@ -100,7 +100,7 @@ def determine_sql_type_for_key_as_int(): # noqa: F811
100100

101101
@staticmethod
102102
def determine_sql_type_for_key_as_id(): # noqa: F811
103-
return Text
103+
return String(255)
104104

105105
# =========================================================================
106106
# Other methods

stix2/datastore/relational_db/database_backends/postgres_backend.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ def determine_sql_type_for_hex_property(): # noqa: F811
6363
# return LargeBinary
6464
return PostgresBackend.determine_sql_type_for_string_property()
6565

66+
@staticmethod
67+
def determine_sql_type_for_reference_property(): # noqa: F811
68+
return Text
69+
70+
@staticmethod
71+
def determine_sql_type_for_string_property(): # noqa: F811
72+
return Text
73+
74+
@staticmethod
75+
def determine_sql_type_for_key_as_id(): # noqa: F811
76+
return Text
77+
6678
@staticmethod
6779
def determine_sql_type_for_timestamp_property(): # noqa: F811
6880
return TIMESTAMP(timezone=True)

stix2/datastore/relational_db/relational_db_testing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ def test_dictionary():
288288

289289
def main():
290290
store = RelationalDBStore(
291-
#PostgresBackend("postgresql://localhost/stix-data-sink", force_recreate=True),
292-
SQLiteBackend("sqlite:///stix-data-sink.db", force_recreate=True),
291+
PostgresBackend("postgresql://localhost/stix-data-sink", force_recreate=True),
292+
#SQLiteBackend("sqlite:///stix-data-sink.db", force_recreate=True),
293293
True,
294294
None,
295295
True,

stix2/datastore/relational_db/table_creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def create_kill_chain_phases_table(name, metadata, db_backend, schema_name, tabl
162162
def create_granular_markings_table(metadata, db_backend, sco_or_sdo):
163163
schema_name = db_backend.schema_for_core()
164164
tables = list()
165-
reg_ex = f"'^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}$'" # noqa: E131
165+
reg_ex = "'^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}$'" # noqa: E131
166166
columns = [
167167
Column(
168168
"id",

0 commit comments

Comments
 (0)