-
Notifications
You must be signed in to change notification settings - Fork 103
make _create_from_dict more resilient #1929
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -400,6 +400,26 @@ def _create_from_dict( | |
| self, | ||
| config: dict, | ||
| ) -> Union[Collection, Awaitable[CollectionAsync]]: | ||
| # Support both "name" and "class" fields for backward compatibility | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand it right, this is becasue the TS client provides a different output? Is that correct? If yes, could you update the comment? |
||
| # If "name" is provided without "class", use it as "class" | ||
| if "name" in config and "class" not in config: | ||
| config = config.copy() | ||
| config["class"] = config.pop("name") | ||
|
|
||
| # Normalize dataType: if it's a string, convert to array | ||
| # This supports both "text" and ["text"] formats, | ||
| # as well as "text[]" -> ["text[]"] | ||
| if "properties" in config: | ||
| config = config.copy() | ||
| properties = [] | ||
| for prop in config["properties"]: | ||
| prop = prop.copy() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can skip the copy |
||
| if "dataType" in prop and isinstance(prop["dataType"], str): | ||
| # Wrap string in array: "text" -> ["text"], "text[]" -> ["text[]"] | ||
| prop["dataType"] = [prop["dataType"]] | ||
| properties.append(prop) | ||
| config["properties"] = properties | ||
|
|
||
| return self.__create(config=config) | ||
|
|
||
| def _create_from_config( | ||
|
|
||
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.
this needs a testcanse for the "name" - you could also parametrice our test to make it more readable, check for example
test_replication_config