Skip to content
Permalink
Browse files

fix: autosave being overwritten in BaseDataSource by setUrl (#1309)

  • Loading branch information...
davecramer committed Oct 10, 2018
1 parent d514ceb commit 10201f61727868bd6f64ce3ab6c197a11bee78f4
@@ -1110,7 +1110,9 @@ public void setUrl(String url) {
Properties p = org.postgresql.Driver.parseURL(url, null);

for (PGProperty property : PGProperty.values()) {
setProperty(property, property.get(p));
if (!this.properties.containsKey(property.getName())) {
setProperty(property, property.get(p));
}
}
}

@@ -9,12 +9,14 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import org.postgresql.Driver;
import org.postgresql.PGProperty;
import org.postgresql.ds.PGSimpleDataSource;
import org.postgresql.ds.common.BaseDataSource;
import org.postgresql.jdbc.AutoSave;
import org.postgresql.test.TestUtil;
import org.postgresql.util.URLCoder;

@@ -150,6 +152,18 @@ public void testDataSourceProperties() throws Exception {
}
}

/**
* Test to make sure that setURL doesn't overwrite autosave
* more should be put in but this scratches the current itch
*/
@Test
public void testOverWriteDSProperties() throws Exception {
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setAutosave(AutoSave.CONSERVATIVE);
dataSource.setURL("jdbc:postgresql://localhost:5432/postgres");
assertSame(dataSource.getAutosave(),AutoSave.CONSERVATIVE);
}

/**
* Test that {@link PGProperty#isPresent(Properties)} returns a correct result in all cases.
*/

0 comments on commit 10201f6

Please sign in to comment.
You can’t perform that action at this time.