Skip to content

Commit

Permalink
add id binding for dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
rpiazza committed Sep 13, 2024
1 parent dcd2a50 commit 16aaf9c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions stix2/datastore/relational_db/input_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ def generate_insert_information(self, dictionary_name, stix_object, **kwargs):
schema_name = kwargs.get("schema_name")
foreign_key_value = kwargs.get("foreign_key_value")
insert_statements = list()
if "id" in stix_object:
bindings["id"] = stix_object["id"]
elif foreign_key_value:
bindings["id"] = foreign_key_value

table = data_sink.tables_dictionary[
canonicalize_table_name(
table_name + "_" + dictionary_name,
Expand All @@ -54,6 +51,10 @@ def generate_insert_information(self, dictionary_name, stix_object, **kwargs):
valid_types = stix_object._properties[dictionary_name].valid_types
for name, value in stix_object[dictionary_name].items():
bindings = dict()
if "id" in stix_object:
bindings["id"] = stix_object["id"]
elif foreign_key_value:
bindings["id"] = foreign_key_value
if not valid_types or len(self.valid_types) == 1:
value_binding = "value"
elif isinstance(value, int) and IntegerProperty in valid_types:
Expand Down

0 comments on commit 16aaf9c

Please sign in to comment.