pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[pgjdbc/pgjdbc] issue #3761: BaseDataSource getProperty does not get all properties.
3+ messages / 1 participants
[nested] [flat]

* [pgjdbc/pgjdbc] issue #3761: BaseDataSource getProperty does not get all properties.
@ 2025-08-13 22:57  "simon-greatrix (@simon-greatrix)" <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

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

You can set properties that you cannot get.

I believe the following unit test should succeed:

```
  @ParameterizedTest
  @CsvSource({
      "PGHOST,'database1.test,database2.test",
      "PGPORT,'1234,5678'",
      "PGDNAME,my-postgresql",
      "user,the-test-user",
      "password,the-test-password",
      
      // And one working one to prove the test can be passed
      "ApplicationName,my-application"
  })
  void settableShouldBeReadable(String propertyName, String testValue) {
    PGProperty property = PGProperty.forName(propertyName);
    assertNotNull(property);

    PGSimpleDataSource dataSource = new PGSimpleDataSource();
    dataSource.setProperty(property, testValue);
    assertEquals(testValue, dataSource.getProperty(property));
  }
```

**Describe the issue**
The five properties referenced in the unit test above can be set, but cannot be read. This is because the getProperty method only references the internal properties object, but the setting handles these five properties specially.

**Driver Version?** 
42.7.7

**Java Version?**
Not applicable

**OS Version?**
Not applicable

**PostgreSQL Version?**
Not applicable

**To Reproduce**
Run JUnit test above.

**Expected behaviour**
If a property has been set using setProperty or a direct setter, then the value should be retrievable using getProperty.

**Logs**
Not applicable

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

* Re: [pgjdbc/pgjdbc] issue #3761: BaseDataSource getProperty does not get all properties.
@ 2025-08-18 11:26  "simon-greatrix (@simon-greatrix)" <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: simon-greatrix (@simon-greatrix) @ 2025-08-18 11:26 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] 3+ messages in thread

* Re: [pgjdbc/pgjdbc] issue #3761: BaseDataSource getProperty does not get all properties.
@ 2025-08-27 07:03  "simon-greatrix (@simon-greatrix)" <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

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

Is there anything blocking the merge request for this?

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


end of thread, other threads:[~2025-08-27 07:03 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-08-13 22:57 [pgjdbc/pgjdbc] issue #3761: BaseDataSource getProperty does not get all properties. "simon-greatrix (@simon-greatrix)" <[email protected]>
2025-08-18 11:26 ` "simon-greatrix (@simon-greatrix)" <[email protected]>
2025-08-27 07:03 ` "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