chime-experiment / chime-experiment/ch_util
layout db: Entries created using the LTF interface are not always editable with the python interface
- Dominant language
- Python
- Stars
- 5
- Forks
- 3
- Avg merge
- 35m
- Merged PRs (30d)
- 1
Description
In the Layout DB, it is not always possible to edit certain fields using the python interface (`peewee`) if they were created using the LTF interface.
For example, see the entry with component name `allenby_cylinder` created by @mondana using the LTF text interface. It is not possible to add/sever connexions for this entry (and others created using LTF). This is just one example, but this issue is general.
If the components are added using python (`peewee`), then there is no issue.
```
Traceback (most recent call last):
File "add_allenby_outrigger_components.py", line 45, in
if __name__ == main():
File "add_allenby_outrigger_components.py", line 42, in main
fix_allenby_cylinder_name() # Fix barcode name of allenby cylinder
File "add_allenby_outrigger_components.py", line 36, in fix_allenby_cylinder_name
layoutdb_utils.change_component_serial_num(serial_num, new_serial_num, user_name)
File "../utilities/layoutdb_utils.py", line 86, in change_component_serial_num
component_id.save()
File "/home/pearlman/.local/lib/python3.7/site-packages/peewee.py", line 6532, in save
rows = self.update(**field_dict).where(self._pk_expr()).execute()
File "/home/pearlman/.local/lib/python3.7/site-packages/peewee.py", line 1898, in inner
return method(self, database, *args, **kwargs)
File "/home/pearlman/.local/lib/python3.7/site-packages/peewee.py", line 1969, in execute
return self._execute(database)
File "/home/pearlman/.local/lib/python3.7/site-packages/peewee.py", line 2465, in _execute
cursor = database.execute(self)
File "/home/pearlman/.local/lib/python3.7/site-packages/peewee.py", line 3142, in execute
return self.execute_sql(sql, params, commit=commit)
File "/data/user-data/pearlman/.conda/envs/layoutdb/lib/python3.7/site-packages/chimedb/core/connectdb.py", line 253, in execute_sql
cursor = super(RetryOperationalError, self).execute_sql(sql, params, commit)
File "/home/pearlman/.local/lib/python3.7/site-packages/peewee.py", line 3136, in execute_sql
self.commit()
File "/home/pearlman/.local/lib/python3.7/site-packages/peewee.py", line 2902, in __exit__
reraise(new_type, new_type(exc_value, *exc_args), traceback)
File "/home/pearlman/.local/lib/python3.7/site-packages/peewee.py", line 185, in reraise
raise value.with_traceback(tb)
File "/home/pearlman/.local/lib/python3.7/site-packages/peewee.py", line 3129, in execute_sql
cursor.execute(sql, params or ())
File "/home/pearlman/.local/lib/python3.7/site-packages/pymysql/cursors.py", line 148, in execute
result = self._query(query)
File "/home/pearlman/.local/lib/python3.7/site-packages/pymysql/cursors.py", line 310, in _query
conn.query(q)
File "/home/pearlman/.local/lib/python3.7/site-packages/pymysql/connections.py", line 548, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/home/pearlman/.local/lib/python3.7/site-packages/pymysql/connections.py", line 775, in _read_query_result
result.read()
File "/home/pearlman/.local/lib/python3.7/site-packages/pymysql/connections.py", line 1156, in read
first_packet = self.connection._read_packet()
File "/home/pearlman/.local/lib/python3.7/site-packages/pymysql/connections.py", line 725, in _read_packet
packet.raise_for_error()
File "/home/pearlman/.local/lib/python3.7/site-packages/pymysql/protocol.py", line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File "/home/pearlman/.local/lib/python3.7/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
raise errorclass(errno, errval)
peewee.IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`ch_data`.`connexion`, CONSTRAINT `connexion_ibfk_2` FOREIGN KEY (`comp_sn1`) REFERENCES `component` (`sn`))')
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.