monica icon indicating copy to clipboard operation
monica copied to clipboard

Invalid SQL generated by export for `contact_photo` table

Open mnkhouri opened this issue 3 years ago • 1 comments

Describe the bug SQL export on 3.6.1 has malformed SQL for contact_photo table;

Which version are you using:

  • Export from app.monicahq.com version 3.6.1
  • Import to self-hosted 3.6.1

Additional context Attempting to import my .sql fails on this line from the export:

INSERT IGNORE INTO `contact_photo` (`contact_id`, `photo_id`, `created_at`, `updated_at`) VALUES
;

I believe this is invalid SQL -- the docs here indicate that VALUES should have at least one value following it.

mnkhouri avatar Feb 01 '22 02:02 mnkhouri

Yes, this is invalid SQL.

This does not only affect the contact_photo table, but all empty tables. Whether they're empty or not depends on your dataset. The SQL exporter does not check whether there is actual data when writing out the INSERT statements.

Edit: Hm, actually, no, but it definitely is an issue with this self-grown exporter. The generated SQL is far away from nice. Try using mysqldump instead, it can also lock tables cleanly to ensure data integrity, and generates better queries.

particleflux avatar Mar 10 '22 20:03 particleflux