-
Notifications
You must be signed in to change notification settings - Fork 28
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
Mapping is not lazy! #10
Comments
Hi. Sorry for the very late answer - I have absolutely forgot to answer. Lazy evaluation is a good point. I'll look at it. But if you have a PR... :) |
After a few minutes looking at thecode and found the problem when I came up with one solution and would like to discuss: From this: object-mapper/mapper/object_mapper.py Lines 137 to 142 in b02c6d6
To this: from_obj_dict = {k: v for k, v in from_obj.__dict__.items() if not_private(k) and not_excluded(k)}
to_obj_dict = {k: v for k, v in inst.__dict__.items() if not_private(k)} I tested this over SQLAlchemy models in my company project and work like a charm. But this changes breaks the test I was thinking maybe we can include a flag like |
Hi. I will check it and let you know. I hope that tomorrow. Thanks for the post 👍. |
Thanks, Marazt! I'm really glad to contribute, this lib is helping a lot. I just stumbled upon a problem on this solution, I think it'll be better to create a module of |
Yes, Such composition of |
I'll try to work on a Pull Request in the next couple of days. |
The map function loads all the attribute values at first, although I expect when I give mappings as lambda, the attribute values get read lazily, that is, if some attribute has been set to null or other function, the getattr of source object must not be called. The reason is that I am using your library for mapping SqlAlchemy objects to DTO ones. Deferred loading feature of SqlAlchemy causes Select N+1 problem when using your library.
The text was updated successfully, but these errors were encountered: