Skip to content

Allow users to opt into storing BigInteger as Decimal128 [DATAMONGO-2590] #3444

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
spring-projects-issues opened this issue Jul 16, 2020 · 4 comments
Assignees
Labels
in: mapping Mapping and conversion infrastructure status: feedback-provided Feedback has been provided type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

Christoph Strobl opened DATAMONGO-2590 and commented


Issue Links:

  • DATACMNS-1615 Allow fine grained store specific converter registration
    ("depends on")
  • DATAMONGO-1517 Add support for Decimal128 BSON type

1 votes, 3 watchers

@spring-projects-issues
Copy link
Author

Jeff Yemin commented

BigDecimal is probably the more common type that users would want to map to Decimal128

@spring-projects-issues spring-projects-issues added in: mapping Mapping and conversion infrastructure type: task A general task labels Dec 30, 2020
@christophstrobl
Copy link
Member

BigDecimal to Decimal128 conversion is possible by using the @Field annotation as shown below.

@Field(targetType = FieldType.DECIMAL128)
BigDecimal bigDecimal;

By registering a custom BigInteger -> Decimal128 converter it is possible to apply the above also to BigInteger properties.

enum BigIntegerToDecimal128Converter implements Converter<BigInteger, Decimal128> {
	INSTANCE;

	public Decimal128 convert(BigInteger source) {
		return ...
	}
}

// ...

@Field(targetType = FieldType.DECIMAL128)
BigInteger bigInteger;

@christophstrobl christophstrobl added the status: waiting-for-feedback We need additional information before we can continue label Jan 20, 2021
@mp911de
Copy link
Member

mp911de commented Jan 20, 2021

Should we consider defaulting to Decimal128 for Spring Data 3.0 with a config setting to revert to String?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 20, 2021
@Mcfloy
Copy link

Mcfloy commented Mar 6, 2025

Should we consider defaulting to Decimal128 for Spring Data 3.0 with a config setting to revert to String?

Sorry to necrobump 4 years later, I 100% agree with @mp911de on defaulting to Decimal128 instead of String as we would be able to use expressions on numbers like $lt, $lte, $gt, $gte that we cannot do "easily" with String as it would require the usage of $toDecimal (in an aggregation).

We missed the 3.0 milestone, but can we try to push this modification for the next version* ?

@mp911de mp911de added this to the 4.5 M2 (2025.0.0) milestone Mar 11, 2025
@mp911de mp911de added type: enhancement A general enhancement and removed type: task A general task labels Mar 11, 2025
mp911de added a commit that referenced this issue Mar 11, 2025
Refine documentation. Simplify NumberToNumberConverter. Replace Environment-based configuration with config API.

See: #3444
Original pull request: #4916
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mapping Mapping and conversion infrastructure status: feedback-provided Feedback has been provided type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants