-
-
Notifications
You must be signed in to change notification settings - Fork 18
Enhance table settings generation by filtering required fields and updating columns view logic #1714
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
Enhance table settings generation by filtering required fields and updating columns view logic #1714
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -301,12 +301,26 @@ IMPORTANT: | |||||||||||||||||
| const tableInfo = tablesInformation.find((t) => t.table_name === tableSettings.table_name); | ||||||||||||||||||
| const validColumnNames = tableInfo?.structure.map((col) => col.column_name) || []; | ||||||||||||||||||
|
|
||||||||||||||||||
| const requiredFieldsWithoutDefault = new Set( | ||||||||||||||||||
| tableInfo?.structure | ||||||||||||||||||
| .filter((col) => !col.allow_null && col.column_default === null && !checkFieldAutoincrement(col.column_default, col.extra)) | ||||||||||||||||||
| .map((col) => col.column_name) || [], | ||||||||||||||||||
| ); | ||||||||||||||||||
|
|
||||||||||||||||||
| const settings = new TableSettingsEntity(); | ||||||||||||||||||
| settings.table_name = tableSettings.table_name; | ||||||||||||||||||
| settings.display_name = tableSettings.display_name; | ||||||||||||||||||
| settings.search_fields = this.filterValidColumns(tableSettings.search_fields, validColumnNames); | ||||||||||||||||||
| settings.readonly_fields = this.filterValidColumns(tableSettings.readonly_fields, validColumnNames); | ||||||||||||||||||
| settings.columns_view = this.filterValidColumns(tableSettings.columns_view, validColumnNames); | ||||||||||||||||||
| settings.readonly_fields = this.filterValidColumns(tableSettings.readonly_fields, validColumnNames).filter( | ||||||||||||||||||
| (field) => !requiredFieldsWithoutDefault.has(field), | ||||||||||||||||||
| ); | ||||||||||||||||||
| const filteredColumnsView = this.filterValidColumns(tableSettings.columns_view, validColumnNames); | ||||||||||||||||||
| for (const requiredField of requiredFieldsWithoutDefault) { | ||||||||||||||||||
| if (!filteredColumnsView.includes(requiredField)) { | ||||||||||||||||||
| filteredColumnsView.push(requiredField); | ||||||||||||||||||
|
Comment on lines
+318
to
+320
|
||||||||||||||||||
| for (const requiredField of requiredFieldsWithoutDefault) { | |
| if (!filteredColumnsView.includes(requiredField)) { | |
| filteredColumnsView.push(requiredField); | |
| const filteredColumnsViewSet = new Set(filteredColumnsView); | |
| for (const requiredField of requiredFieldsWithoutDefault) { | |
| if (!filteredColumnsViewSet.has(requiredField)) { | |
| filteredColumnsView.push(requiredField); | |
| filteredColumnsViewSet.add(requiredField); |
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.
requiredFieldsWithoutDefaultcallscheckFieldAutoincrement(col.column_default, col.extra)in a branch wherecol.column_defaultis guaranteed to benull. The helper is typed ascheckFieldAutoincrement(defaultValue: string, ...), so this is type-inconsistent and can break compilation understrictNullChecks(and makes the intent unclear). Consider updating the helper signature to acceptstring | null(andextra?: string | null) or coalescing the argument at the call site.