#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
8607112 to
5e0e8bc
Compare
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
|
hey @samin-z! Thank you so much for taking care of this. I've just opened similar PR for Views #2547. Few ideas that came to my mind when I worked on it:
WDYT about adding same things to your PR? |
009fc5d to
788e780
Compare
|
i compared playwright fails against main, failures are in known flaky datetime/login/navigation tests and are reproducible outside this branch, none of the failures point to technical_name or dataByAlias code paths. |
|
|
||
| return $this->filterRowResult($view ?? null, $updatedRow); | ||
| $updatedRow = $this->filterRowResult($view ?? null, $updatedRow); | ||
| $this->attachAliasPayload($updatedRow, $columns); |
There was a problem hiding this comment.
Did you test out the webbook event to see what the payload is? Cuz from the code, it seems like above we dispatch the event with new RowUpdatedEvent($updatedRow, $previousData) before even attaching dataByAlias? So webhook results doesn't get the dataByAlias value?
There was a problem hiding this comment.
you're right, fixed it in RowService by ensuring alias payload is attached before event dispatch.
| * ownership: string, | ||
| * ownerDisplayName: string|null, | ||
| * createdBy: string, | ||
| * dataByAlias: array<string, array{columnId: int, value: mixed}>, |
There was a problem hiding this comment.
i'de keep it as none optional, the row serializer always returns this key and it gets normalized to an array, so clients get a stable contract anyway.
| if ($column->getTechnicalName() === $technicalName) { | ||
| throw new BadRequestError('Technical name must be unique in the table.'); | ||
| } |
There was a problem hiding this comment.
I think status 400 is better, not 500
7d347a8 to
87afb9e
Compare
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
87afb9e to
5eb1c41
Compare




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.
