My current use-case is that I'm trying to do ./manage.py loaddata and it's fails because it tries to disable some constraints for a table in another schema.
I've been working with:
table_names = None
This executes line 430: cursor.execute("select 'ALTER TABLE ' || TRIM(tabname) || ' ALTER FOREIGN KEY ' || TRIM(constname) || ' NOT ENFORCED;' from syscat.references")
which identifies a number of tables across the entire DB, not just tables in the current schema
execute_query_fetched() [line 419] checks if the a constraint is already inforced
if not, executes a query to disable it
nowhere does it mention anything about the schema, so I get a query like this:
>>> operation = 'ALTER TABLE MYTABLE ALTER FOREIGN KEY SQL230324215718120 NOT ENFORCED;'
Traceback (most recent call last):
File "/home/tj/o/server/.venv/lib64/python3.9/site-packages/ibm_db_dbi.py", line 1312, in _execute_helper
return_value = ibm_db.execute(self.stmt_handler, parameters)
Exception: Statement Execute Failed: [IBM][CLI Driver][DB2/LINUXX8664] SQL0204N "OMNIO.MYTABLE" is an undefined name. SQLSTATE=42704 SQLCODE=-204
but MYTABLE is a table defined in another schema.
I can see a couple of options:
Somehow figure out how to set table_names so this constraint disabling/enabling is restricted to the tables in the current schema
make this logic schema-aware (the approach I'm investigating now)
try to completely disable this logic (not sure if there's a straight-forward configuration way to do that)
For example in
disable_constraint_checking
:https://github.com/ibmdb/python-ibmdb-django/blob/a8d5ccf91e4e985e20f0c9832e44a58582c2f230/ibm_db_django/base.py#L415-L437
My current use-case is that I'm trying to do
./manage.py loaddata
and it's fails because it tries to disable some constraints for a table in another schema.I've been working with:
nowhere does it mention anything about the schema, so I get a query like this:
but MYTABLE is a table defined in another schema.
I can see a couple of options: