Skip to content

Conversation

@adrianviquez
Copy link
Contributor

@adrianviquez adrianviquez commented Jan 26, 2026

Adjust how we're serializing arrayfields with the sql_generator

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.


Note

Improves SQL export serialization to correctly handle Django ArrayFields.

  • serialize_value now accepts field and serializes lists as PostgreSQL arrays when the field is an ArrayField; otherwise lists/dicts are serialized as jsonb
  • New _serialize_pg_array builds typed PG array literals with proper escaping and casts (e.g., ::integer[], ::text[])
  • Enum serialization forwards field context; get_row_values passes model fields to serialize_value

Written by Cursor Bugbot for commit 903200d. This will update automatically on new commits. Configure here.

@sentry
Copy link

sentry bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 0% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.54%. Comparing base (3981c2e) to head (903200d).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...s/shared/shared/owner_data_export/sql_generator.py 0.00% 35 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #675      +/-   ##
==========================================
- Coverage   92.60%   92.54%   -0.07%     
==========================================
  Files        1296     1296              
  Lines       47640    47671      +31     
  Branches     1592     1601       +9     
==========================================
  Hits        44118    44118              
- Misses       3213     3244      +31     
  Partials      309      309              
Flag Coverage Δ
apiunit 96.36% <ø> (ø)
sharedintegration 37.47% <0.00%> (-0.09%) ⬇️
sharedunit 85.80% <0.00%> (-0.19%) ⬇️
workerintegration 58.59% <ø> (ø)
workerunit 90.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link

codecov-notifications bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 0% with 35 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...s/shared/shared/owner_data_export/sql_generator.py 0.00% 35 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 26, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing adrian/correctly-serializer-arrayfield (903200d) with main (3981c2e)

Open in CodSpeed

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

elements.append(str(item))
else:
cleaned = str(item).replace("\x00", "")
elements.append(cleaned)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested ArrayField produces invalid PostgreSQL array syntax

Medium Severity

The _serialize_pg_array function doesn't handle nested arrays (Django's ArrayField(ArrayField(...)) pattern). When an array element is itself a list, it falls through to the else branch and produces Python list syntax [1, 2, 3] instead of PostgreSQL array syntax {1, 2, 3}. This generates completely invalid SQL that would fail on import. Nested/multidimensional arrays require recursive serialization to produce the correct PostgreSQL format like '{{1,2},{3,4}}'::integer[][].

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is okay, we don't have nested ArrayField(ArrayField(...)) in the codebase

@adrianviquez adrianviquez added this pull request to the merge queue Jan 26, 2026
Merged via the queue into main with commit a8c620e Jan 26, 2026
51 of 53 checks passed
@adrianviquez adrianviquez deleted the adrian/correctly-serializer-arrayfield branch January 26, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants