Skip to content

Add config option for Decimal128 representation of numerics. #4916

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

Closed
wants to merge 3 commits into from

Conversation

christophstrobl
Copy link
Member

This PR moves some of the statically configured conversions into more dynamic spot. This now allows to access environment and manual config options when registering numeric converters like those for BigInteger & BigDecimal.

Still a draft as this one might not be side effect free.

Closes: #3444

@mp911de mp911de marked this pull request as ready for review March 11, 2025 08:29
@@ -154,11 +161,18 @@ public static class MongoConverterConfigurationAdapter {
private static final Set<Class<?>> JAVA_DRIVER_TIME_SIMPLE_TYPES = Set.of(LocalDate.class, LocalTime.class, LocalDateTime.class);

private boolean useNativeDriverJavaTimeCodecs = false;
private String numericFormat;
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this an enum?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, either that or a flag like the native driver codecs.

private final List<Object> customConverters = new ArrayList<>();

private final PropertyValueConversions internalValueConversion = PropertyValueConversions.simple(it -> {});
private PropertyValueConversions propertyValueConversions = internalValueConversion;

{
Copy link
Member

Choose a reason for hiding this comment

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

Let's not introduce Environment lookups here. Ideally, Spring Boot is an entry point for these config values so that we can remain clear of any configuration concerns.

christophstrobl and others added 2 commits March 11, 2025 09:49
We now allow configuring the default representation for BigDecimal and BigInteger values, still defaulting to string. BigDecimal can be configured to use Decimal128 by default.
Refine documentation. Simplify NumberToNumberConverter. Replace Environment-based configuration with config API.
@mp911de mp911de added the type: enhancement A general enhancement label Mar 11, 2025
@mp911de mp911de added this to the 4.5 M2 (2025.0.0) milestone Mar 11, 2025
mp911de pushed a commit that referenced this pull request Mar 11, 2025
We now allow configuring the default representation for BigDecimal and BigInteger values, still defaulting to string. BigDecimal can be configured to use Decimal128 by default.

Closes: #3444
Original pull request: #4916
mp911de added a commit that referenced this pull request Mar 11, 2025
Refine documentation. Simplify NumberToNumberConverter. Replace Environment-based configuration with config API.

See: #3444
Original pull request: #4916
@mp911de mp911de closed this Mar 11, 2025
@mp911de
Copy link
Member

mp911de commented Mar 11, 2025

That's merged and polished now.

@mp911de mp911de deleted the issue/3444-II branch March 11, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow users to opt into storing BigInteger as Decimal128 [DATAMONGO-2590]
2 participants