Skip to content

Conversation

@MirakuSan
Copy link
Contributor

Adds a new jsonb_document Doctrine type that leverages DBAL 4.3.0+ native JsonbType.

The type is conditionally registered only when DBAL 4.3.0+ is available, ensuring backward compatibility.

Shared serialization logic has been extracted into a trait to avoid duplication.

Closes #152


This is my first contribution to this project, hope I did it right! 🙂

@MirakuSan MirakuSan force-pushed the feat/jsonb-document-type branch from 34ad85f to 3532d76 Compare December 2, 2025 14:50
@MirakuSan MirakuSan marked this pull request as draft December 2, 2025 14:50
@MirakuSan MirakuSan force-pushed the feat/jsonb-document-type branch 3 times, most recently from f327692 to d679dc7 Compare December 2, 2025 15:49
@MirakuSan MirakuSan marked this pull request as ready for review December 2, 2025 16:12
@MirakuSan
Copy link
Contributor Author

@dunglas I tried something here, not sure it is the right think to do.
The tests are passing in the CI, but it failes anyway.
Don't really now why...


namespace Dunglas\DoctrineJsonOdm\Tests;

use Doctrine\DBAL\Types\JsonbType;
Copy link

Choose a reason for hiding this comment

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

It seems this class is not used in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes totaly, good catch

@dunglas
Copy link
Owner

dunglas commented Jan 6, 2026

Could you please rebase? This should also fix the CI.

MirakuSan and others added 6 commits January 6, 2026 15:35
New jsonb_document type leveraging native DBAL JsonbType.
Shared serialization logic extracted into JsonDocumentTypeTrait.
Type is conditionally registered when DBAL 4.3.0+ is available.

# Conflicts:
#	tests/Fixtures/AppKernel.php
Move ProductJsonb entity to separate directory with conditional mapping.
Enable native lazy objects for PHP 8.4+ compatibility.
@MirakuSan MirakuSan force-pushed the feat/jsonb-document-type branch from bcdd7a4 to e5bfc90 Compare January 6, 2026 14:41
@MirakuSan MirakuSan force-pushed the feat/jsonb-document-type branch from e5bfc90 to 902d7cf Compare January 6, 2026 14:41
@MirakuSan
Copy link
Contributor Author

@dunglas done ✅

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for the native JSONB type introduced in Doctrine DBAL 4.3.0+ by creating a new jsonb_document type that leverages the JsonbType class. The implementation ensures backward compatibility by conditionally registering the new type only when DBAL 4.3.0+ is available.

Key changes:

  • Extracted shared serialization logic into JsonDocumentTypeTrait to avoid code duplication
  • Added JsonbDocumentType class that extends DBAL's native JsonbType and uses the shared trait
  • Conditionally registered the new type based on DBAL version availability
  • Updated test entities to use the new type when available

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Type/JsonDocumentTypeTrait.php New trait extracting common serialization logic from JsonDocumentType to be shared with JsonbDocumentType
src/Type/JsonbDocumentType.php New type class extending DBAL's JsonbType to support native JSONB with object serialization
src/Type/JsonDocumentType.php Refactored to use the new shared trait, removing duplicated code
src/Bundle/DunglasDoctrineJsonOdmBundle.php Added conditional registration of jsonb_document type and serializer injection
tests/Fixtures/TestBundle/Entity/Product.php Updated to conditionally use jsonb_document type when DBAL 4.3.0+ is available
tests/Fixtures/TestBundle/Entity/Foo.php Updated to conditionally use jsonb_document type when DBAL 4.3.0+ is available
README.md Added documentation for the new jsonb_document type and updated usage examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dunglas dunglas merged commit d5162f5 into dunglas:main Jan 6, 2026
7 checks passed
@dunglas
Copy link
Owner

dunglas commented Jan 6, 2026

Thanks!

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.

Add new type jsonb_document

3 participants