pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty.
8+ messages / 2 participants
[nested] [flat]

* [pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty.
@ 2025-08-13 23:00 "simon-greatrix (@simon-greatrix)" <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: simon-greatrix (@simon-greatrix) @ 2025-08-13 23:00 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

The setProperty method of BaseDataSource allows all properties to be set. The getProperty method does not allow the retrieval of: PG_HOST, PG_PORT, PG_DBNAME, USER, and PASSWORD. All properties that can be set should also be readable.

Fixes: https://github.com/pgjdbc/pgjdbc/issues/3761




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty.
@ 2025-08-18 11:27 ` "simon-greatrix (@simon-greatrix)" <[email protected]>
  6 siblings, 0 replies; 8+ messages in thread

From: simon-greatrix (@simon-greatrix) @ 2025-08-18 11:27 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

In writing a unit test I have discovered a related issue:

PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setLoadBalanceHosts(false);
assertFalse( dataSource.getLoadBalanceHosts() );
The getLoadBalanceHosts() method returns true if any value is set, even if the value is false.

Should we create a new issue for this or expand the scope of this one to cover it?

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty.
@ 2025-08-18 11:31 ` "davecramer (@davecramer)" <[email protected]>
  6 siblings, 0 replies; 8+ messages in thread

From: davecramer (@davecramer) @ 2025-08-18 11:31 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Just fix it here

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty.
@ 2025-08-18 14:45 ` "simon-greatrix (@simon-greatrix)" <[email protected]>
  6 siblings, 0 replies; 8+ messages in thread

From: simon-greatrix (@simon-greatrix) @ 2025-08-18 14:45 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

I've been pondering how `setService(String)` interacts with `getUrl()` and `setUrl(String)`. 

After setting a service the URL looks like this:

`jdbc:postgresql://localhost/?service=test-service1`

If you call `setUrl` with this value it sets all the properties values from the service including defaults. Something like this:

`jdbc:postgresql://localhost:5432/test_dbname?adaptiveFetch=false&...&useSpnego=false&xmlFactoryFactory=`

Everything is set *except* for `service`.

Is the correct and expected behaviour:

1) Just like this - this is perfect

2) Calling `setService(String)` should set all the property values for the service, so the first URL should have them all set.

3) Calling getUrl() should never include a "service=" element as it is non-portable.

4) Calling setUrl() should preserve the service property.

Personally, I would like `setService` to load the service defaults, and the non-portable "service=" value in the URL to be removed.

PS: I've pushed the unit tests and additional fix. The unit tests include this case and hence currently fail as I'm not sure what the correct behaviour is.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty.
@ 2025-08-18 16:31 ` "simon-greatrix (@simon-greatrix)" <[email protected]>
  6 siblings, 0 replies; 8+ messages in thread

From: simon-greatrix (@simon-greatrix) @ 2025-08-18 16:31 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

By the way, I've noticed that with Java 21.0.7 the `TimestampTest` is failing. This is due to a Java quirk. The test is initialising a value as `1950-02-07 15:00:00 PST` and parsing it with SimpleDateFormat.

Whilst we expect PST to match Pacific Standard Time, it also matches Philippine Standard Time. I do not know what determines which matches 'PST' first. My locale is Europe/London which might affect things, but I would still expect PST to be Pacific Standard Time rather than Philippine Standard Time.

Would you mind if I fixed this too? All I want to do is to change the "PST" to "Pacific Standard Time" in the test case :)

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty.
@ 2025-08-18 18:58 ` "davecramer (@davecramer)" <[email protected]>
  6 siblings, 0 replies; 8+ messages in thread

From: davecramer (@davecramer) @ 2025-08-18 18:58 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

> By the way, I've noticed that with Java 21.0.7 the `TimestampTest` is failing. This is due to a Java quirk. The test is initialising a value as `1950-02-07 15:00:00 PST` and parsing it with SimpleDateFormat.
> 
> Whilst we expect PST to match Pacific Standard Time, it also matches Philippine Standard Time. I do not know what determines which matches 'PST' first. My locale is Europe/London which might affect things, but I would still expect PST to be Pacific Standard Time rather than Philippine Standard Time.
> 
> Would you mind if I fixed this too? All I want to do is to change the "PST" to "Pacific Standard Time" in the test case :)

Can you do this in another PR. It will be small and we can just merge it quickly

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty.
@ 2025-08-18 19:07 ` "davecramer (@davecramer)" <[email protected]>
  6 siblings, 0 replies; 8+ messages in thread

From: davecramer (@davecramer) @ 2025-08-18 19:07 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

> I've been pondering how `setService(String)` interacts with `getUrl()` and `setUrl(String)`.
> 
> After setting a service the URL looks like this:
> 
> `jdbc:postgresql://localhost/?service=test-service1`
> 
> If you call `setUrl` with this value it sets all the properties values from the service including defaults. Something like this:
> 
> `jdbc:postgresql://localhost:5432/test_dbname?adaptiveFetch=false&...&useSpnego=false&xmlFactoryFactory=`
> 
> Everything is set _except_ for `service`.
> 
> Is the correct and expected behaviour:
> 
> 1. Just like this - this is perfect
> 2. Calling `setService(String)` should set all the property values for the service, so the first URL should have them all set.
> 3. Calling getUrl() should never include a "service=" element as it is non-portable.
> 4. Calling setUrl() should preserve the service property.
> 
> Personally, I would like `setService` to load the service defaults, and the non-portable "service=" value in the URL to be removed.

I guess there is no reason not to load the settings when setService is called. If however someone calls setUrl with a different service we should honour the settings for that service.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty.
@ 2025-08-19 14:30 ` "simon-greatrix (@simon-greatrix)" <[email protected]>
  6 siblings, 0 replies; 8+ messages in thread

From: simon-greatrix (@simon-greatrix) @ 2025-08-19 14:30 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Accidentally closed as I messed up my git repo. I should never have been merging from main! 

Re-opened using a fix branch on https://github.com/pgjdbc/pgjdbc/pull/3776

^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2025-08-19 14:30 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-08-13 23:00 [pgjdbc/pgjdbc] PR #3762: Fix: BaseDataSource.getProperty mirrors BaseDataSource.setProperty. "simon-greatrix (@simon-greatrix)" <[email protected]>
2025-08-18 11:27 ` "simon-greatrix (@simon-greatrix)" <[email protected]>
2025-08-18 11:31 ` "davecramer (@davecramer)" <[email protected]>
2025-08-18 14:45 ` "simon-greatrix (@simon-greatrix)" <[email protected]>
2025-08-18 16:31 ` "simon-greatrix (@simon-greatrix)" <[email protected]>
2025-08-18 18:58 ` "davecramer (@davecramer)" <[email protected]>
2025-08-18 19:07 ` "davecramer (@davecramer)" <[email protected]>
2025-08-19 14:30 ` "simon-greatrix (@simon-greatrix)" <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox