-
Notifications
You must be signed in to change notification settings - Fork 0
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
JDE: Added MongoDB insert action + example #81
Conversation
…quest reponse user properties
Please mark whether you used Copilot to assist coding in this PR
|
|
||
|
||
class MongoDBInsertComponent(MongoDBBaseComponent): | ||
"""Component for handling MongoDB database operations.""" | ||
|
||
def __init__(self, **kwargs): | ||
super().__init__(info, **kwargs) | ||
self.data_types_map = self.get_config("data_types") | ||
|
||
def invoke(self, message, data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give some examples of data_types and data. Since the data
variable may include any complex data structure (e.g., List[List[List]]), would your code expect to handle all possible combinations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added proper validation.
As for example, you can find some here
data_types: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about Mongo, but the code itself looks sound.
"Invalid data types provided for MongoDB insert. Expected a dictionary." | ||
) | ||
for key, field_type in self.data_types_map.items(): | ||
if not isinstance(key, str) or not isinstance(field_type, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[SUG] you can make an enumeration of known data types and compare the filed_type with them. If the type is not know, either raise and error or a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a list with all possible values and a checklist
SonarQube Quality Gate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
What is the purpose of this change?
The purpose of this change is to enhance the MongoDB component of the project to support the insertion of data with specified data types. This is important for improving data handling capabilities and ensuring that inserted data conforms to expected formats.
How is this accomplished?
Anything reviews should focus on/be aware of?
Reviewers should ensure that the type conversion implementation is robust, especially the handling of non-JSON types. Also, verify that the MongoDB insert feature is functioning as expected in various scenarios.