Skip to content

Implement ADD Subdoc Update for FlatPostgresCollection#272

Open
suddendust wants to merge 1 commit intohypertrace:mainfrom
suddendust:pg_write_subdoc_add
Open

Implement ADD Subdoc Update for FlatPostgresCollection#272
suddendust wants to merge 1 commit intohypertrace:mainfrom
suddendust:pg_write_subdoc_add

Conversation

@suddendust
Copy link
Contributor

@suddendust suddendust commented Feb 6, 2026

Add ADD sub-document update operator for flat collections

Summary

Implements the ADD operator for FlatPostgresCollection, enabling atomic numeric increment/decrement operations on both top-level columns and nested JSONB fields.

Changes

  • Added [FlatCollectionSubDocAddOperatorParser] to handle ADD operations
  • Registered the parser in FlatPostgresCollection.SUB_DOC_UPDATE_PARSERS

SQL Generated

Scenario Generated SQL
Top-level column "price" = COALESCE("price", 0) + ?::integer
Nested JSONB "metrics" = jsonb_set(COALESCE("metrics", '{}'), '{sales,total}'::text[], (COALESCE("metrics"#>>'{sales,total}', '0')::integer + ?::integer)::text::jsonb, true)

Features

  • Type-aware: Uses column schema type for top-level, infers from Java value type for JSONB. This information is then use for the apt type-cast.
  • NULL-safe: COALESCE handles NULL columns/fields (treats as 0)
  • Creates missing JSONB keys via jsonb_set(..., true)

@suddendust suddendust changed the title Subdoc update - ADD Implement ADD Subdoc Update for FlatPostgresCollection Feb 6, 2026
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 70.21277% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.47%. Comparing base (6a2b05d) to head (469ead1).

Files with missing lines Patch % Lines
.../parser/FlatCollectionSubDocAddOperatorParser.java 68.88% 11 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #272      +/-   ##
============================================
- Coverage     80.52%   80.47%   -0.05%     
- Complexity     1396     1398       +2     
============================================
  Files           239      240       +1     
  Lines          6695     6741      +46     
  Branches        615      619       +4     
============================================
+ Hits           5391     5425      +34     
- Misses          900      910      +10     
- Partials        404      406       +2     
Flag Coverage Δ
integration 80.47% <70.21%> (-0.05%) ⬇️
unit 54.35% <10.63%> (-0.32%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant