#1840: API structure improvement: expose columns through a technical name/slug/alias#2428
#1840: API structure improvement: expose columns through a technical name/slug/alias#2428
Conversation
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
8607112 to
5e0e8bc
Compare
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
There was a problem hiding this comment.
Looking at #1840, in order for this to be useful for workflows, we must expose it via AbstractRowEvent.php -> toPublicRow() ?
There was a problem hiding this comment.
I believe we're now doing 2 writes? Both create() and importColumn() create a column first and only then assign the fallback column_ name. If the second write fails, the request throws after the insert has already succeeded, so we leave behind a persisted column without the technicalName. Maybe we should have a transaction then?
There was a problem hiding this comment.
there is no problem even if the update of technicalName fails a 'null' value for the column is valid. When 'technicalName' is null, the code in RowService handles it:
$alias = $aliasByColumnId[$columnId] ?? ('column_' . $columnId);
this causes the column to behave correctly with the 'column_{columnId}' fallback.
also when the user edits and saves the column, the 'null' will be updated with either their chosen value or the default 'column_{columnId}'.
| normalizeTechnicalName(technicalName) { | ||
| const normalized = technicalName?.trim() | ||
| return normalized === '' ? null : normalized | ||
| }, | ||
| isTechnicalNameValid() { | ||
| const technicalName = this.normalizeTechnicalName(this.editColumn.technicalName) | ||
| if (technicalName === null) { | ||
| return false | ||
| } | ||
|
|
||
| return /^[a-z][a-z0-9_]*$/.test(technicalName) | ||
| }, |
There was a problem hiding this comment.
used here and in CreateColumn, could be moved to a shared file and reused
| if (technicalName === null) { | ||
| return false | ||
| } |
There was a problem hiding this comment.
we return false for null technicalName when we edit but true for creating? Why?
There was a problem hiding this comment.
that wa my mistake as i was going through it and forgot to update
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
Feature ticket: #1840
New response structure:
now we have new field added to columns called 'technical_name' which if user does not add it as default will be 'column_{id}', 'dataByAlias' added on top of 'data' not to break the current structure.
