-
-
Notifications
You must be signed in to change notification settings - Fork 326
fix: Handle dots in custom field names for segments, workflows, and templates #347
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: next
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 |
|---|---|---|
|
|
@@ -818,7 +818,10 @@ export class SegmentService { | |
| value: unknown, | ||
| unit?: 'days' | 'hours' | 'minutes', | ||
| ): Prisma.ContactWhereInput { | ||
| const path = jsonPath.split('.'); | ||
| // Use the entire jsonPath as a single path element. | ||
| // Contact data is a flat JSON object, so field names like "prefix.key" | ||
| // must be treated as literal keys, not nested paths. | ||
| const path = [jsonPath]; | ||
|
Comment on lines
+821
to
+824
|
||
|
|
||
| switch (operator) { | ||
| case 'equals': | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1111,7 +1111,15 @@ export class WorkflowExecutionService { | |
| normalizedField = field.substring(8); // Remove "contact." prefix, leaving "data.X" | ||
| } | ||
|
|
||
| const parts = normalizedField.split('.'); | ||
| // Split only on the first dot to separate the top-level field (e.g., "data") | ||
| // from the custom field name. This preserves dots in custom field names | ||
| // (e.g., "data.prefix.key" → ["data", "prefix.key"]). | ||
| const firstDotIndex = normalizedField.indexOf('.'); | ||
| const parts = | ||
| firstDotIndex === -1 | ||
| ? [normalizedField] | ||
| : [normalizedField.substring(0, firstDotIndex), normalizedField.substring(firstDotIndex + 1)]; | ||
|
|
||
|
Comment on lines
+1114
to
+1122
|
||
| let value: unknown = data; | ||
|
|
||
| for (const part of parts) { | ||
|
|
||
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.
Changing Prisma JSON
pathfromjsonPath.split('.')to[jsonPath]removes support for querying nested JSON incontact.data(e.g. filtering ondata.profile.tierpreviously producedpath: ['profile','tier'], but will now look for a literal keyprofile.tier). Sincecontact.datais aJsoncolumn and other parts of the codebase/tests use nested objects, consider preserving backwards compatibility by generating filters that can match both interpretations when the field contains dots (e.g., OR between[jsonPath]andjsonPath.split('.')), or introducing an explicit escaping/syntax to disambiguate literal-dot keys vs nested paths.