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

Not support datetime Type #31

Open
PittyXu opened this issue Nov 17, 2023 · 6 comments
Open

Not support datetime Type #31

PittyXu opened this issue Nov 17, 2023 · 6 comments

Comments

@PittyXu
Copy link

PittyXu commented Nov 17, 2023

mysql sync error

TypeError: Object of type datetime is not JSON serializable

@kyp76
Copy link

kyp76 commented Nov 17, 2023

Hello I have the same issue

meilisync  | │ │               │   │   'XUserAccountId': 10,                              │ │
meilisync  | │ │               │   │   'DisabledDate': None,                              │ │
meilisync  | │ │               │   │   'EnabledDate': datetime.datetime(2019, 3, 4, 18,   │ │
meilisync  | │ │               43, 33),                                                   │ │
meilisync  | │ │               │   │   'AccessType': 2,                                   │ │
meilisync  | │ │               │   │   'AccountId': 15583,                                │ │
meilisync  | │ │               │   │   'UserId': 3869,                                    │ │
meilisync  | │ │               │   │   'DisabledById': None,                              │ │
meilisync  | │ │               │   │   'EnabledById': 2093                                │ │
meilisync  | │ │               │   },                                                     │ │
meilisync  | │ │               │   ... +990                                               │ │
meilisync  | │ │               ]                                                          │ │
meilisync  | │ │        self = <json.encoder.JSONEncoder object at 0x7ffffe91a2e0>        │ │
meilisync  | │ ╰──────────────────────────────────────────────────────────────────────────╯ │
meilisync  | │                                                                              │
meilisync  | │ /usr/local/lib/python3.9/json/encoder.py:179 in default                      │
meilisync  | │                                                                              │
meilisync  | │   176 │   │   │   │   return JSONEncoder.default(self, o)                    │
meilisync  | │   177 │   │                                                                  │
meilisync  | │   178 │   │   """                                                            │
meilisync  | │ ❱ 179 │   │   raise TypeError(f'Object of type {o.__class__.__name__} '      │
meilisync  | │   180 │   │   │   │   │   │   f'is not JSON serializable')                   │
meilisync  | │   181 │                                                                      │
meilisync  | │   182 │   def encode(self, o):                                               │
meilisync  | │                                                                              │
meilisync  | │ ╭────────────────────────── locals ──────────────────────────╮               │
meilisync  | │ │    o = datetime.datetime(2019, 2, 28, 22, 33, 54)          │               │
meilisync  | │ │ self = <json.encoder.JSONEncoder object at 0x7ffffe91a2e0> │               │
meilisync  | │ ╰────────────────────────────────────────────────────────────╯               │
meilisync  | ╰──────────────────────────────────────────────────────────────────────────────╯
meilisync  | TypeError: Object of type datetime is not JSON serializable

could you do fix this issue ASAP ?

Thank you

@long2ice
Copy link
Owner

What about try latest code

@kyp76
Copy link

kyp76 commented Nov 17, 2023

Hello I did a test with the latest version of our dev branch, I do not have the same error but I have a new one ==>

`meilisync  | │ │         │   {'EnabledDate': datetime.datetime(2019, 3, 4, 18, 43, 33)},  │ │
meilisync  | │ │         │   {'EnabledDate': datetime.datetime(2019, 3, 4, 18, 43, 33)},  │ │
meilisync  | │ │         │   {'EnabledDate': datetime.datetime(2019, 3, 4, 18, 43, 33)},  │ │
meilisync  | │ │         │   {'EnabledDate': datetime.datetime(2019, 3, 4, 18, 43, 33)},  │ │
meilisync  | │ │         │   ... +990                                                     │ │
meilisync  | │ │         ]                                                                │ │
meilisync  | │ │  self = <meilisync.meili.Meili object at 0x7ffffab23710>                 │ │
meilisync  | │ │  sync = Sync(                                                            │ │
meilisync  | │ │         │   plugins=[],                                                  │ │
meilisync  | │ │         │   table='xuseraccount',                                        │ │
meilisync  | │ │         │   pk='XUserAccountId',                                         │ │
meilisync  | │ │         │   full=True,                                                   │ │
meilisync  | │ │         │   index='xuseraccount',                                        │ │
meilisync  | │ │         │   fields={'EnabledDate': None}                                 │ │
meilisync  | │ │         )                                                                │ │
meilisync  | │ │ tasks = []                                                               │ │
meilisync  | │ ╰──────────────────────────────────────────────────────────────────────────╯ │
meilisync  | ╰──────────────────────────────────────────────────────────────────────────────╯
meilisync  | TypeError: 'async for' requires an object with __aiter__ method, got list`

could you tell me why ?? @long2ice

And also on the config.yml following parameters (index/fileds and sentry) are now mandatory, it s not coherent with your documentation (https://github.com/long2ice/meilisync/blob/dev/README.md?plain=1#L201).

@long2ice
Copy link
Owner

Fixed settings optional and try latest code. Also please show full stack.

@ThangBuiDuc
Copy link

I have same issue with docker container. Has this been fixed yet?

@markusthegeek
Copy link

markusthegeek commented Dec 3, 2023

@long2ice I got the same error as above when using your default MongoDB config with Full set to true, it works fine with Full set to false. Can you reproduce this? I tested with your latest code from Github. Error seems gone once the index is created in Meilisearch via Full set to false and then switching back to true but still no full sync happens...

The incremental sync works great with MongoDB and seems super fast :-D

https://github.com/long2ice/meilisync/blob/dev/tests/config/mongo.yml

C:\Users\marku\AppData\Local\Programs\Python\Python312\Lib\site-packages\meilisync\meili.py:33   │
│ in add_full_data                                                                                 │
│                                                                                                  │
│    30 │   async def add_full_data(self, sync: Sync, data: AsyncGenerator):                       │
│    31 │   │   tasks = []                                                                         │
│    32 │   │   count = 0                                                                          │
│ >  33 │   │   async for items in data:                                                           │
│    34 │   │   │   count += len(items)                                                            │
│    35 │   │   │   events = [Event(type=EventType.create, data=item) for item in items]           │
│    36 │   │   │   task = await self.handle_events_by_type(sync, events, EventType.create)

TypeError: 'async for' requires an object with __aiter__ method, got list

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

No branches or pull requests

5 participants