-
Notifications
You must be signed in to change notification settings - Fork 14
Allow passing display_name parameter when creating tables #164
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
48953e7
fb15340
315cd34
27f1af8
bcc7b75
62aaa89
bf45a33
be8350a
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 |
|---|---|---|
|
|
@@ -1636,6 +1636,7 @@ def _create_table( | |
| schema: Dict[str, Any], | ||
| solution_unique_name: Optional[str] = None, | ||
| primary_column_schema_name: Optional[str] = None, | ||
| display_name: Optional[str] = None, | ||
| ) -> Dict[str, Any]: | ||
| """Create a custom table with specified columns. | ||
|
|
||
|
|
@@ -1647,6 +1648,8 @@ def _create_table( | |
| :type solution_unique_name: ``str`` | ``None`` | ||
| :param primary_column_schema_name: Optional primary column schema name. | ||
| :type primary_column_schema_name: ``str`` | ``None`` | ||
| :param display_name: Human-readable display name for the table. Defaults to ``table_schema_name``. | ||
| :type display_name: ``str`` | ``None`` | ||
|
|
||
| :return: Metadata summary for the created table including created column schema names. | ||
| :rtype: ``dict[str, Any]`` | ||
|
|
@@ -1690,9 +1693,13 @@ def _create_table( | |
| if not solution_unique_name: | ||
| raise ValueError("solution_unique_name cannot be empty") | ||
|
|
||
| if display_name is not None: | ||
| if not isinstance(display_name, str) or not display_name.strip(): | ||
| raise TypeError("display_name must be a non-empty string when provided") | ||
|
|
||
| metadata = self._create_entity( | ||
| table_schema_name=table_schema_name, | ||
| display_name=table_schema_name, | ||
| display_name=display_name if display_name is not None else table_schema_name, | ||
| attributes=attributes, | ||
| solution_unique_name=solution_unique_name, | ||
|
abelmilash-msft marked this conversation as resolved.
|
||
| ) | ||
|
|
@@ -2099,6 +2106,7 @@ def _build_create_entity( | |
| columns: Dict[str, Any], | ||
| solution: Optional[str] = None, | ||
| primary_column: Optional[str] = None, | ||
| display_name: Optional[str] = None, | ||
| ) -> _RawRequest: | ||
| """Build an EntityDefinitions POST request without sending it.""" | ||
| if primary_column: | ||
|
|
@@ -2114,12 +2122,16 @@ def _build_create_entity( | |
| subcode=VALIDATION_UNSUPPORTED_COLUMN_TYPE, | ||
| ) | ||
| attributes.append(attr) | ||
| if display_name is not None: | ||
| if not isinstance(display_name, str) or not display_name.strip(): | ||
| raise TypeError("display_name must be a non-empty string when provided") | ||
| label = display_name if display_name is not None else table | ||
| body = { | ||
| "@odata.type": "Microsoft.Dynamics.CRM.EntityMetadata", | ||
| "SchemaName": table, | ||
| "DisplayName": self._label(table), | ||
| "DisplayCollectionName": self._label(table + "s"), | ||
| "Description": self._label(f"Custom entity for {table}"), | ||
| "DisplayName": self._label(label), | ||
| "DisplayCollectionName": self._label(label + "s"), | ||
|
Contributor
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. this will be wrong if the DisplayName is 'Person'. Instead of computing, there should be a library we are using to convert to plural. Try to use that.
Contributor
Author
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. Created an issue for this: #166 |
||
| "Description": self._label(f"Custom entity for {label}"), | ||
| "OwnershipType": "UserOwned", | ||
| "HasActivities": False, | ||
| "HasNotes": True, | ||
|
|
||
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.
in one of the existing integration tests, pass the display name to make sure coverage.
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 display name to integration walkthrough tests on commit be8350a