Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/xml2db/table/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Expand Down
13 changes: 13 additions & 0 deletions tests/sample_models/orders/orders.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@
</xs:choice>
</xs:complexType>

<!-- catalogRefType tests the case where the same simple element appears in two branches
of a xs:choice (sequence branch and standalone branch) -->
<xs:complexType name="catalogRefType">
<xs:choice>
<xs:sequence>
<xs:element name="id" type="bt:stringtype"/>
<xs:element name="urn" type="xs:anyURI" minOccurs="0"/>
</xs:sequence>
<xs:element name="urn" type="xs:anyURI"/>
</xs:choice>
</xs:complexType>

<xs:complexType name="itemtype">
<xs:sequence>
<xs:element name="product" type="producttype" minOccurs="1" maxOccurs="1"/>
Expand All @@ -104,6 +116,7 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="catalog_ref" type="catalogRefType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_ddl_mssql_version0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_ddl_mssql_version1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_ddl_mssql_version2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_ddl_mysql_version0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_ddl_mysql_version1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_ddl_mysql_version2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_ddl_postgresql_version0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_ddl_postgresql_version1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_ddl_postgresql_version2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_erd_version0.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ erDiagram
integer quantity
decimal price
string currency
string catalog_ref_id
anyURI catalog_ref_urn
}
stringfeature {
string id
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_erd_version1.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ erDiagram
integer quantity
decimal price
string currency
string catalog_ref_id
anyURI catalog_ref_urn
}
orders ||--o{ shiporder : "shiporder*"
orders {
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_erd_version2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*"
Expand Down
3 changes: 3 additions & 0 deletions tests/sample_models/orders/orders_source_tree_version0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/sample_models/orders/orders_source_tree_version1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/sample_models/orders/orders_source_tree_version2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_target_tree_version0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_target_tree_version1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/sample_models/orders/orders_target_tree_version2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/sample_models/orders/xml/order3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<weight>0.8</weight>
<unit>m3</unit>
</detail>
<catalog_ref>
<id>CAT-001</id>
<urn>urn:catalog:product:1</urn>
</catalog_ref>
</item>
<item>
<product>
Expand All @@ -74,6 +78,9 @@
<country>US</country>
</to>
</delivery>
<catalog_ref>
<urn>urn:catalog:product:1</urn>
</catalog_ref>
</item>
<detail>
<reference>BL-2023-45</reference>
Expand Down
Loading