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

Unable to insert date fields from mysql source #8

Closed
brunoocasali opened this issue Apr 21, 2023 · 2 comments · Fixed by #10
Closed

Unable to insert date fields from mysql source #8

brunoocasali opened this issue Apr 21, 2023 · 2 comments · Fixed by #10

Comments

@brunoocasali
Copy link
Contributor

brunoocasali commented Apr 21, 2023

Hi @long2ice, first of all, thanks a lot for this tool. It will be incredibly helpful for everyone. Congratulations on your work!

Before officially starting sharing this tool, I want to ensure everything is working fine, so I'll raise some issues where we can work together to improve it!

So, my table is quite simple:

mysql> SHOW FULL FIELDS FROM authors;
+------------+--------------+--------------------+------+-----+-------------------+-------------------+---------------------------------+---------+
| Field      | Type         | Collation          | Null | Key | Default           | Extra             | Privileges                      | Comment |
+------------+--------------+--------------------+------+-----+-------------------+-------------------+---------------------------------+---------+
| id         | int          | NULL               | NO   | PRI | NULL              | auto_increment    | select,insert,update,references |         |
| first_name | varchar(50)  | utf8mb3_unicode_ci | NO   |     | NULL              |                   | select,insert,update,references |         |
| last_name  | varchar(50)  | utf8mb3_unicode_ci | NO   |     | NULL              |                   | select,insert,update,references |         |
| email      | varchar(100) | utf8mb3_unicode_ci | NO   | UNI | NULL              |                   | select,insert,update,references |         |
| birthdate  | date         | NULL               | NO   |     | NULL              |                   | select,insert,update,references |         |
| added      | timestamp    | NULL               | NO   |     | CURRENT_TIMESTAMP | DEFAULT_GENERATED | select,insert,update,references |         |
+------------+--------------+--------------------+------+-----+-------------------+-------------------+---------------------------------+---------+

fake data example:

INSERT INTO `authors` (`id`, `first_name`, `last_name`, `email`, `birthdate`, `added`) VALUES (1, 'Flo', 'Hansen', 'raynor.anika@example.com', '2012-06-07', '1977-01-27 22:00:53');
meilisync-meilisync-1    | TypeError: Object of type date is not JSON serializable
meilisync-meilisync-1    | 2023-04-21 15:32:23.624 | ERROR    | meilisync.main:interval:122 - Error when insert data to MeiliSearch: Object of type date is not JSON serializable

I'm running this MySQL version: 8.0.33 for Linux on aarch64 (MySQL Community Server - GPL).
And the import was not completed. Since there is no way to inform in the configuration file which types the column has, the system should automatically understand it, right?

@brunoocasali
Copy link
Contributor Author

By the way, I had some weird issues regarding my collation. So I set everything, even the database, to utf8mb4_unicode_ci and it worked fine. I didn't know if it was something caused by my poor-configurated test database.

@long2ice
Copy link
Owner

Yes, maybe we should convert datetime to str before insert into meilisearch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants