diff --git a/src/xml2db/table/table.py b/src/xml2db/table/table.py
index 735465e..db42635 100644
--- a/src/xml2db/table/table.py
+++ b/src/xml2db/table/table.py
@@ -163,6 +163,8 @@ def add_column(
allow_empty: is nullable?
ngroup: a string id signaling that the column belongs to a nested sequence
"""
+ if name in self.columns and self.columns[name].data_type == data_type:
+ return
self.columns[name] = DataModelColumn(
name,
[(name, None)],
diff --git a/tests/sample_models/orders/orders.xsd b/tests/sample_models/orders/orders.xsd
index 912bbe3..294e107 100644
--- a/tests/sample_models/orders/orders.xsd
+++ b/tests/sample_models/orders/orders.xsd
@@ -84,6 +84,18 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -104,6 +116,7 @@
+
diff --git a/tests/sample_models/orders/orders_ddl_mssql_version0.sql b/tests/sample_models/orders/orders_ddl_mssql_version0.sql
index 275829f..e0d31ef 100644
--- a/tests/sample_models/orders/orders_ddl_mssql_version0.sql
+++ b/tests/sample_models/orders/orders_ddl_mssql_version0.sql
@@ -70,6 +70,8 @@ CREATE TABLE item (
currency CHAR(3) NULL,
delivery_from_fk_orderperson INTEGER NULL,
delivery_to_fk_orderperson INTEGER NULL,
+ catalog_ref_id VARCHAR(1000) NULL,
+ catalog_ref_urn VARCHAR(1000) NULL,
record_hash BINARY(20) NULL,
CONSTRAINT cx_pk_item PRIMARY KEY CLUSTERED (pk_item),
CONSTRAINT item_xml2db_record_hash UNIQUE (record_hash),
diff --git a/tests/sample_models/orders/orders_ddl_mssql_version1.sql b/tests/sample_models/orders/orders_ddl_mssql_version1.sql
index c07ff1d..ebf59b2 100644
--- a/tests/sample_models/orders/orders_ddl_mssql_version1.sql
+++ b/tests/sample_models/orders/orders_ddl_mssql_version1.sql
@@ -120,6 +120,8 @@ CREATE TABLE item (
currency CHAR(3) NULL,
delivery_from_fk_orderperson INTEGER NULL,
delivery_to_fk_orderperson INTEGER NULL,
+ catalog_ref_id VARCHAR(1000) NULL,
+ catalog_ref_urn VARCHAR(1000) NULL,
CONSTRAINT cx_pk_item PRIMARY KEY CLUSTERED (pk_item),
FOREIGN KEY(fk_parent_shiporder) REFERENCES shiporder (pk_shiporder),
FOREIGN KEY(delivery_from_fk_orderperson) REFERENCES orderperson (pk_orderperson),
diff --git a/tests/sample_models/orders/orders_ddl_mssql_version2.sql b/tests/sample_models/orders/orders_ddl_mssql_version2.sql
index 6a51408..230a6ac 100644
--- a/tests/sample_models/orders/orders_ddl_mssql_version2.sql
+++ b/tests/sample_models/orders/orders_ddl_mssql_version2.sql
@@ -106,6 +106,8 @@ CREATE TABLE item (
currency CHAR(3) NULL,
delivery_from_fk_orderperson INTEGER NULL,
delivery_to_fk_orderperson INTEGER NULL,
+ catalog_ref_id VARCHAR(1000) NULL,
+ catalog_ref_urn VARCHAR(1000) NULL,
xml2db_record_hash BINARY(20) NULL,
CONSTRAINT cx_pk_item PRIMARY KEY CLUSTERED (pk_item),
CONSTRAINT item_xml2db_record_hash UNIQUE (xml2db_record_hash),
diff --git a/tests/sample_models/orders/orders_ddl_mysql_version0.sql b/tests/sample_models/orders/orders_ddl_mysql_version0.sql
index bf5f96c..4bf4089 100644
--- a/tests/sample_models/orders/orders_ddl_mysql_version0.sql
+++ b/tests/sample_models/orders/orders_ddl_mysql_version0.sql
@@ -70,6 +70,8 @@ CREATE TABLE item (
currency VARCHAR(3),
delivery_from_fk_orderperson INTEGER,
delivery_to_fk_orderperson INTEGER,
+ catalog_ref_id VARCHAR(255),
+ catalog_ref_urn VARCHAR(1000),
record_hash BINARY(20),
CONSTRAINT cx_pk_item PRIMARY KEY (pk_item),
CONSTRAINT item_xml2db_record_hash UNIQUE (record_hash),
diff --git a/tests/sample_models/orders/orders_ddl_mysql_version1.sql b/tests/sample_models/orders/orders_ddl_mysql_version1.sql
index ed0f1fe..d0781c1 100644
--- a/tests/sample_models/orders/orders_ddl_mysql_version1.sql
+++ b/tests/sample_models/orders/orders_ddl_mysql_version1.sql
@@ -120,6 +120,8 @@ CREATE TABLE item (
currency VARCHAR(3),
delivery_from_fk_orderperson INTEGER,
delivery_to_fk_orderperson INTEGER,
+ catalog_ref_id VARCHAR(255),
+ catalog_ref_urn VARCHAR(1000),
CONSTRAINT cx_pk_item PRIMARY KEY (pk_item),
FOREIGN KEY(fk_parent_shiporder) REFERENCES shiporder (pk_shiporder),
FOREIGN KEY(delivery_from_fk_orderperson) REFERENCES orderperson (pk_orderperson),
diff --git a/tests/sample_models/orders/orders_ddl_mysql_version2.sql b/tests/sample_models/orders/orders_ddl_mysql_version2.sql
index 0ad69c4..e6f9df1 100644
--- a/tests/sample_models/orders/orders_ddl_mysql_version2.sql
+++ b/tests/sample_models/orders/orders_ddl_mysql_version2.sql
@@ -106,6 +106,8 @@ CREATE TABLE item (
currency VARCHAR(3),
delivery_from_fk_orderperson INTEGER,
delivery_to_fk_orderperson INTEGER,
+ catalog_ref_id VARCHAR(255),
+ catalog_ref_urn VARCHAR(1000),
xml2db_record_hash BINARY(20),
CONSTRAINT cx_pk_item PRIMARY KEY (pk_item),
CONSTRAINT item_xml2db_record_hash UNIQUE (xml2db_record_hash),
diff --git a/tests/sample_models/orders/orders_ddl_postgresql_version0.sql b/tests/sample_models/orders/orders_ddl_postgresql_version0.sql
index 7e16662..06323dc 100644
--- a/tests/sample_models/orders/orders_ddl_postgresql_version0.sql
+++ b/tests/sample_models/orders/orders_ddl_postgresql_version0.sql
@@ -70,6 +70,8 @@ CREATE TABLE item (
currency VARCHAR(3),
delivery_from_fk_orderperson INTEGER,
delivery_to_fk_orderperson INTEGER,
+ catalog_ref_id VARCHAR(1000),
+ catalog_ref_urn VARCHAR(1000),
record_hash BYTEA,
CONSTRAINT cx_pk_item PRIMARY KEY (pk_item),
CONSTRAINT item_xml2db_record_hash UNIQUE (record_hash),
diff --git a/tests/sample_models/orders/orders_ddl_postgresql_version1.sql b/tests/sample_models/orders/orders_ddl_postgresql_version1.sql
index ddc317c..000f957 100644
--- a/tests/sample_models/orders/orders_ddl_postgresql_version1.sql
+++ b/tests/sample_models/orders/orders_ddl_postgresql_version1.sql
@@ -120,6 +120,8 @@ CREATE TABLE item (
currency VARCHAR(3),
delivery_from_fk_orderperson INTEGER,
delivery_to_fk_orderperson INTEGER,
+ catalog_ref_id VARCHAR(1000),
+ catalog_ref_urn VARCHAR(1000),
CONSTRAINT cx_pk_item PRIMARY KEY (pk_item),
FOREIGN KEY(fk_parent_shiporder) REFERENCES shiporder (pk_shiporder),
FOREIGN KEY(delivery_from_fk_orderperson) REFERENCES orderperson (pk_orderperson),
diff --git a/tests/sample_models/orders/orders_ddl_postgresql_version2.sql b/tests/sample_models/orders/orders_ddl_postgresql_version2.sql
index d05dd75..c7812c8 100644
--- a/tests/sample_models/orders/orders_ddl_postgresql_version2.sql
+++ b/tests/sample_models/orders/orders_ddl_postgresql_version2.sql
@@ -106,6 +106,8 @@ CREATE TABLE item (
currency VARCHAR(3),
delivery_from_fk_orderperson INTEGER,
delivery_to_fk_orderperson INTEGER,
+ catalog_ref_id VARCHAR(1000),
+ catalog_ref_urn VARCHAR(1000),
xml2db_record_hash BYTEA,
CONSTRAINT cx_pk_item PRIMARY KEY (pk_item),
CONSTRAINT item_xml2db_record_hash UNIQUE (xml2db_record_hash),
diff --git a/tests/sample_models/orders/orders_erd_version0.md b/tests/sample_models/orders/orders_erd_version0.md
index 0008dd2..0fc05e0 100644
--- a/tests/sample_models/orders/orders_erd_version0.md
+++ b/tests/sample_models/orders/orders_erd_version0.md
@@ -27,6 +27,8 @@ erDiagram
integer quantity
decimal price
string currency
+ string catalog_ref_id
+ anyURI catalog_ref_urn
}
stringfeature {
string id
diff --git a/tests/sample_models/orders/orders_erd_version1.md b/tests/sample_models/orders/orders_erd_version1.md
index dee3be0..f82f9f4 100644
--- a/tests/sample_models/orders/orders_erd_version1.md
+++ b/tests/sample_models/orders/orders_erd_version1.md
@@ -12,6 +12,8 @@ erDiagram
integer quantity
decimal price
string currency
+ string catalog_ref_id
+ anyURI catalog_ref_urn
}
orders ||--o{ shiporder : "shiporder*"
orders {
diff --git a/tests/sample_models/orders/orders_erd_version2.md b/tests/sample_models/orders/orders_erd_version2.md
index 002b10f..c3a761c 100644
--- a/tests/sample_models/orders/orders_erd_version2.md
+++ b/tests/sample_models/orders/orders_erd_version2.md
@@ -31,6 +31,8 @@ erDiagram
integer quantity
decimal price
string currency
+ string catalog_ref_id
+ anyURI catalog_ref_urn
}
product ||--o{ intfeature_with_peculiarly_long_suffix_which_overflow_max_length : "features_intfeature_with_peculiarly_long_suffix_which_overflow_max_length*"
product ||--o{ stringfeature : "features_stringfeature*"
diff --git a/tests/sample_models/orders/orders_source_tree_version0.txt b/tests/sample_models/orders/orders_source_tree_version0.txt
index 44b3b86..2635b02 100644
--- a/tests/sample_models/orders/orders_source_tree_version0.txt
+++ b/tests/sample_models/orders/orders_source_tree_version0.txt
@@ -96,6 +96,9 @@ orders:
detail[0, None]:
weight[1, 1]: decimal
unit[1, 1]: string
+ catalog_ref[0, 1] (choice):
+ id[0, 1]: string
+ urn[0, 1]: anyURI
detail[0, None]:
reference[1, 1]: string
carrier[1, 1]: string
diff --git a/tests/sample_models/orders/orders_source_tree_version1.txt b/tests/sample_models/orders/orders_source_tree_version1.txt
index 44b3b86..2635b02 100644
--- a/tests/sample_models/orders/orders_source_tree_version1.txt
+++ b/tests/sample_models/orders/orders_source_tree_version1.txt
@@ -96,6 +96,9 @@ orders:
detail[0, None]:
weight[1, 1]: decimal
unit[1, 1]: string
+ catalog_ref[0, 1] (choice):
+ id[0, 1]: string
+ urn[0, 1]: anyURI
detail[0, None]:
reference[1, 1]: string
carrier[1, 1]: string
diff --git a/tests/sample_models/orders/orders_source_tree_version2.txt b/tests/sample_models/orders/orders_source_tree_version2.txt
index 44b3b86..2635b02 100644
--- a/tests/sample_models/orders/orders_source_tree_version2.txt
+++ b/tests/sample_models/orders/orders_source_tree_version2.txt
@@ -96,6 +96,9 @@ orders:
detail[0, None]:
weight[1, 1]: decimal
unit[1, 1]: string
+ catalog_ref[0, 1] (choice):
+ id[0, 1]: string
+ urn[0, 1]: anyURI
detail[0, None]:
reference[1, 1]: string
carrier[1, 1]: string
diff --git a/tests/sample_models/orders/orders_target_tree_version0.txt b/tests/sample_models/orders/orders_target_tree_version0.txt
index 06ca732..db0b307 100644
--- a/tests/sample_models/orders/orders_target_tree_version0.txt
+++ b/tests/sample_models/orders/orders_target_tree_version0.txt
@@ -76,6 +76,8 @@ orders:
detail[0, None]:
weight[1, 1]: decimal
unit[1, 1]: string
+ catalog_ref_id[0, 1]: string
+ catalog_ref_urn[0, 1]: anyURI
detail[0, None]:
reference[1, 1]: string
carrier[1, 1]: string
diff --git a/tests/sample_models/orders/orders_target_tree_version1.txt b/tests/sample_models/orders/orders_target_tree_version1.txt
index 7ec2b7b..17b6d33 100644
--- a/tests/sample_models/orders/orders_target_tree_version1.txt
+++ b/tests/sample_models/orders/orders_target_tree_version1.txt
@@ -80,6 +80,8 @@ orders:
detail[0, None]:
weight[1, 1]: decimal
unit[1, 1]: string
+ catalog_ref_id[0, 1]: string
+ catalog_ref_urn[0, 1]: anyURI
detail[0, None]:
reference[1, 1]: string
carrier[1, 1]: string
diff --git a/tests/sample_models/orders/orders_target_tree_version2.txt b/tests/sample_models/orders/orders_target_tree_version2.txt
index 9ad2d82..80b555d 100644
--- a/tests/sample_models/orders/orders_target_tree_version2.txt
+++ b/tests/sample_models/orders/orders_target_tree_version2.txt
@@ -76,6 +76,8 @@ orders:
detail[0, None]:
weight[1, 1]: decimal
unit[1, 1]: string
+ catalog_ref_id[0, 1]: string
+ catalog_ref_urn[0, 1]: anyURI
detail[0, None]:
reference[1, 1]: string
carrier[1, 1]: string
diff --git a/tests/sample_models/orders/xml/order3.xml b/tests/sample_models/orders/xml/order3.xml
index b2aff96..c80030c 100644
--- a/tests/sample_models/orders/xml/order3.xml
+++ b/tests/sample_models/orders/xml/order3.xml
@@ -55,6 +55,10 @@
0.8
m3
+
+ CAT-001
+ urn:catalog:product:1
+
-
@@ -74,6 +78,9 @@
US
+
+ urn:catalog:product:1
+
BL-2023-45