Skip to content
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

PG Reactive Client: Cannot create Money value in Range (-1.00, 0.00) #36144

Closed
ghubstan opened this issue Sep 25, 2023 · 3 comments · Fixed by #36544
Closed

PG Reactive Client: Cannot create Money value in Range (-1.00, 0.00) #36144

ghubstan opened this issue Sep 25, 2023 · 3 comments · Fixed by #36544
Assignees
Labels
area/reactive-sql-clients kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency
Milestone

Comments

@ghubstan
Copy link

ghubstan commented Sep 25, 2023

Describe the bug

I cannot create a Money value of -0.XX, i.e., a Money value greater than -1.00, and less than 0.00. Range (-1.00 < value < 0.00)

If the integer value of the Number argument is non-zero, e.g., using Money constructor argument new BigDecimal("-1.11") works.

If the integer value of the Number argument is zero, e.g., using a Money constructor new BigDecimal("-0.11") does not work (as expected).

I am not certain this is a bug, due to my expectation that the integerPart of a Money(-0.11) could be represented as -0.

Reproducing tests and debugger screenshots are below.

Expected behavior

Calling new Money(new BigDecimal("-0.11")) results in a negative Money(-0,11)

The Money value represents minus 11 cents, as expected.

Actual behavior

Calling new Money(new BigDecimal("-0.11")) results in a positive Money(0,11)

The Money value represents plus 11cents, not minus 11cents.

How to Reproduce?

Reproduce Expected Behaviour

  1. Use a BigDecimal as a Money constructor argument.
    Money money = new Money(new BigDecimal("-1.11"));

  2. Examine resulting Money in debugger:
    right-money

  3. Print resulting Money value: Money(-1.11). As expected I see Money(-1.11).

Reproduce Unexpected Behaviour

  1. Use a BigDecimal as a Money constructor argument.
    Money money = new Money(new BigDecimal("-0.11"));

  2. Examine resulting Money in debugger:
    wrong-money

  3. Print resulting Money value: Money(0.11). I expect to see Money(-0.11).

Below are some test cases.

 @Test
    public void testRightMoney() {
        Money money = new Money(new BigDecimal("-1.11"));
        System.out.println(money);
        assertEquals(-1, money.getIntegerPart());
        assertEquals(11, money.getDecimalPart());
    }

Above, as expected assertEquals(-1, money.getIntegerPart()) passes.

@Test
    public void testWrongMoney() {
        Money money = new Money(new BigDecimal("-0.11"));
        System.out.println(money);
        assertEquals(0, money.getIntegerPart());
        assertEquals(11, money.getDecimalPart());
    }

Above, as expected assertEquals(0, money.getIntegerPart()) passes, but I need to be able to create a Money(-0.11).

Any advice?
Thanks.

Output of uname -a or ver

Ubuntu 22.04.3 Linux 6.2.0-33-generic x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7) OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.2.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 8.1.1

Additional information

No response

@ghubstan ghubstan added the kind/bug Something isn't working label Sep 25, 2023
@ghubstan ghubstan changed the title PG Reactive Client: new Money(new BigDecimal("-0.11")) creates positive Money(0,11) PG Reactive Client: Cannot create Money value in Range (-1.00, 0.00) Sep 25, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 26, 2023

/cc @tsegismont (reactive-sql-clients), @vietj (reactive-sql-clients)

@tsegismont
Copy link
Contributor

Thanks for reporting @ghubstan

I've filed eclipse-vertx/vertx-sql-client#1360 upstream

@ghubstan
Copy link
Author

Thanks. I'll report upstream, in the proper place next time.

@cescoffier cescoffier added the triage/upstream Used for issues which are caused by issues in upstream projects/dependency label Oct 2, 2023
@quarkus-bot quarkus-bot bot added this to the 3.6 - main milestone Oct 19, 2023
@gsmet gsmet modified the milestones: 3.6 - main, 3.5.1 Oct 26, 2023
@aloubyansky aloubyansky modified the milestones: 3.5.1, 3.2.8.Final Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/reactive-sql-clients kind/bug Something isn't working triage/upstream Used for issues which are caused by issues in upstream projects/dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants