Description: _create_table_model crashes when tables_config returns None
In _create_table_model in model.py, tables_config.get(table_name, {}) can return None if a table is explicitly configured with a None value in the config dict (e.g., from a YAML config file where a key exists but has no value).
When this happens, the following line raises an AttributeError because None has no .get() method:
if table_config.get("reuse", True): # AttributeError if table_config is None
https://github.com/cre-dev/xml2db/blob/0.12.5/src/xml2db/model.py#L197
Steps to Reproduce
Provide a model config (e.g., via YAML) where a table key exists but has no value:
tables:
SomeTable: # this results in None, not {}
from xml2db import DataModel
model = DataModel(
xsd_file="path/to/file.xsd",
model_config={"tables": {"SomeTable": None}},
)
This raises:
AttributeError: 'NoneType' object has no attribute 'get'
Suggested Fix
Add a None-safe fallback:
if (table_config or {}).get("reuse", True):
This ensures that if table_config resolves to None, it falls back to an empty dict before calling .get().
Environment
- xml2db version: 0.12.5
- Python version: 3.14.2
- xmlschema version: 4.3.1
- OS: Windows
Description:
_create_table_modelcrashes whentables_configreturnsNoneIn
_create_table_modelinmodel.py,tables_config.get(table_name, {})can returnNoneif a table is explicitly configured with aNonevalue in the config dict (e.g., from a YAML config file where a key exists but has no value).When this happens, the following line raises an
AttributeErrorbecauseNonehas no.get()method:https://github.com/cre-dev/xml2db/blob/0.12.5/src/xml2db/model.py#L197
Steps to Reproduce
Provide a model config (e.g., via YAML) where a table key exists but has no value:
This raises:
Suggested Fix
Add a None-safe fallback:
This ensures that if
table_configresolves toNone, it falls back to an empty dict before calling.get().Environment