Mailing List webobjects-dev@wocommunity.org Message #300
From: D Tim Cummings <webobjects-dev@wocommunity.org>
Subject: Re: [WO-DEV] Re: Postgresql jdbc driver upgrade not recommended
Date: Fri, 29 Oct 2021 20:00:29 +1000
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
Signed Data (PGP )
I have built a small app which demonstrates this behaviour.

https://github.com/timcu/wopg4230

It is a very simple app with a database with one table with one record with one field (other than the primary key). The app has one WOComponent with one form with one text field and one save button.

It is a maven app but that makes it easy to swap between jdbc driver versions.

I would be interested if other people see the same behaviour. You will need to set up a postgresql database but I have put instructions on the github README.md on how to do that.

Tim

On 27/10/21 20:06, D Tim Cummings wrote:
Postgresql data type : Numeric(38,4) allows null

Java data type: BigDecimal

EOModel using prototype: currencyAmount

When number is first retrieved from database it has precision 10 scale 4 eg 150000.0000

I click the edit button which puts the number in a textfield which has numberformat "$#,##0; ($#,##0)" and it displays as $150,000

I click save button. Number in EO is now 150000 with precision 6 and scale 0

I run ec().saveChanges() where ec() is my editingContext.

Number in EO is still 150000 with precision 6 and scale 0

I repeat the procedure "edit / save" several times and randomly the number in EO eventually becomes 15 with precision 2 and scale 0. If it happens before the saveChanges() then the new number gets saved to the database. However it can happen after the save in which case my app sees the small number but it doesn't get saved to database if I shutdown the app at that point and start it up again.

It looks like a problem with my app except that it only started happening with the new JDBC driver and reverting the JDBC driver removes the problem.


Tim


On 27/10/21 18:48, Hugi Thordarson wrote:
Hi Tim,
out of curiosity, what's the data type of the number that's getting truncated? (both the DB and java/model side)

- hugi


On 27 Oct 2021, at 04:53, D Tim Cummings <webobjects-dev@wocommunity.org> wrote:

I just upgraded my postgresql jdbc driver from 42.2.23 to 42.3.0 and suddenly any number returned from the database that ended in four zeros was having the zeros trimmed.

For example

150000 became 15

This did not affect numbers ending in three zeros

151000 stayed as 151000

I am still looking for the cause but rolling back to 42.2.23 fixed the problem. Problem was reproducible on Postgresql 10.18 on Ubuntu and Postgresql 13.3 on Mac.

I am using Wonder 7.2 with Postgresql plugin. My project is defined using the maven structure. I was using the postgresql jdbc driver in my pom.xml with

<dependency>
     <groupId>org.postgresql</groupId>
     <artifactId>postgresql</artifactId>
     <version>42.2.23</version>
</dependency>

Hope this helps

Tim


<OpenPGP_0x7EF42CC581B85618.asc>

#############################################################
This message is sent to you because you are subscribed to
   the mailing list <webobjects-dev@wocommunity.org>.
To unsubscribe, E-mail to: <webobjects-dev-off@wocommunity.org>
To switch to the DIGEST mode, E-mail to <webobjects-dev-digest@wocommunity.org>
To switch to the INDEX mode, E-mail to <webobjects-dev-index@wocommunity.org>
Send administrative queries to <webobjects-dev-request@wocommunity.org>


#############################################################
This message is sent to you because you are subscribed to
 the mailing list <webobjects-dev@wocommunity.org>.
To unsubscribe, E-mail to: <webobjects-dev-off@wocommunity.org>
To switch to the DIGEST mode, E-mail to <webobjects-dev-digest@wocommunity.org>
To switch to the INDEX mode, E-mail to <webobjects-dev-index@wocommunity.org>
Send administrative queries to <webobjects-dev-request@wocommunity.org>

Content cannot be verified (probably it has been altered)
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster