Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 use more precise foreign key constraints #62

Merged
merged 1 commit into from
Jan 1, 2024
Merged

Conversation

techouse
Copy link
Owner

@techouse techouse commented Dec 31, 2023

Addresses #61

@techouse techouse added the bug Something isn't working label Dec 31, 2023
@techouse techouse self-assigned this Dec 31, 2023
Copy link

codecov bot commented Dec 31, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (29ceb9f) 87.16% compared to head (cdaa3bc) 87.16%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #62   +/-   ##
=======================================
  Coverage   87.16%   87.16%           
=======================================
  Files           8        8           
  Lines         553      553           
=======================================
  Hits          482      482           
  Misses         71       71           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@techouse techouse changed the title 🐛 fix #61 🐛 use more precise foreign key constraints Dec 31, 2023
@techouse techouse linked an issue Dec 31, 2023 that may be closed by this pull request
@dethrophes
Copy link

dethrophes commented Dec 31, 2023

so without this change I get

2023-12-31 23:14:06 ERROR    SQLite failed creating table owners: unknown column "ERROR_NUMBER" in foreign key definition
Traceback (most recent call last):
  File "/home/jokearney/.local/bin/mysql2sqlite", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/jokearney/.local/lib/python3.8/site-packages/mysql_to_sqlite3/cli.py", line 170, in cli
    converter.transfer()
  File "/home/jokearney/.local/lib/python3.8/site-packages/mysql_to_sqlite3/transporter.py", line 614, in transfer
    self._create_table(table_name)  # type: ignore[arg-type]
  File "/home/jokearney/.local/lib/python3.8/site-packages/mysql_to_sqlite3/transporter.py", line 484, in _create_table
    self._sqlite_cur.executescript(self._build_create_table_sql(table_name))
sqlite3.OperationalError: unknown column "ERROR_NUMBER" in foreign key definition

with the code change.


2023-12-31 23:19:47 INFO     Transferring table archs
2023-12-31 23:19:48 INFO     Transferring table coids
2023-12-31 23:19:48 INFO     Transferring table customers
2023-12-31 23:19:48 INFO     Transferring table fd_stats_view
2023-12-31 23:19:48 INFO     Transferring table fdescs
2023-12-31 23:19:48 INFO     Transferring table fds
2023-12-31 23:19:48 INFO     Transferring table fds_view
2023-12-31 23:19:48 INFO     Transferring table hostnames
2023-12-31 23:19:48 INFO     Transferring table ker_types
2023-12-31 23:19:48 INFO     Transferring table ker_vers
2023-12-31 23:19:48 INFO     Transferring table machine_strs
2023-12-31 23:19:48 INFO     Transferring table os_vers
2023-12-31 23:19:48 INFO     Transferring table owner_types
2023-12-31 23:19:48 INFO     Transferring table owners
2023-12-31 23:19:48 INFO     Transferring table pnames
2023-12-31 23:19:48 INFO     Transferring table process_stats_view
2023-12-31 23:19:48 INFO     Transferring table processes
2023-12-31 23:19:48 INFO     Transferring table processes_view
2023-12-31 23:19:48 INFO     Transferring table stat_groups
2023-12-31 23:19:48 INFO     Transferring table stat_names
2023-12-31 23:19:48 INFO     Transferring table stat_types
2023-12-31 23:19:48 INFO     Transferring table stats
2023-12-31 23:19:49 INFO     Transferring table stats_view
2023-12-31 23:19:49 INFO     Transferring table system_stats_view
2023-12-31 23:19:49 INFO     Transferring table systems
2023-12-31 23:19:49 INFO     Transferring table thread_stats_view
2023-12-31 23:19:49 INFO     Transferring table threads
2023-12-31 23:19:49 INFO     Transferring table threads_view
2023-12-31 23:19:49 INFO     Transferring table tickets
2023-12-31 23:19:49 INFO     Transferring table tnames
2023-12-31 23:19:49 INFO     Transferring table trace_cfgs
2023-12-31 23:19:49 INFO     Transferring table traces
2023-12-31 23:19:49 INFO     Done!

so looks good to me.

Here is the schema that seems to be causing the issue. I've seen it on 2 systems.
Server version: 8.0.35-0ubuntu0.20.04.1 - (Ubuntu)

trace_stats.zip

Note you have to be creating a new sqlite3 db to see the issue.

@techouse techouse merged commit 8fe0b1b into master Jan 1, 2024
71 checks passed
@techouse techouse deleted the fix/issue-61 branch January 1, 2024 08:19
@techouse
Copy link
Owner Author

techouse commented Jan 1, 2024

This has been released in v2.1.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unknown column "ERROR_NUMBER" in foreign key definition
2 participants