gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: normalize postgres:// URI to postgresq


From: gnunet
Subject: [libeufin] branch master updated: normalize postgres:// URI to postgresql:// for JDBC
Date: Mon, 16 Oct 2023 12:14:18 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new db76884d normalize postgres:// URI to postgresql:// for JDBC
db76884d is described below

commit db76884dee5897197ef0f3a0d8f72c58ea7e7723
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Oct 16 12:14:15 2023 +0200

    normalize postgres:// URI to postgresql:// for JDBC
---
 util/src/main/kotlin/DB.kt | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/util/src/main/kotlin/DB.kt b/util/src/main/kotlin/DB.kt
index af26d3d3..6ff449a8 100644
--- a/util/src/main/kotlin/DB.kt
+++ b/util/src/main/kotlin/DB.kt
@@ -274,9 +274,6 @@ fun connectWithSchema(jdbcConn: String, schemaName: String? 
= null) {
  * supported natively by JDBC.
  */
 fun getJdbcConnectionFromPg(pgConn: String): String {
-    if (pgConn.startsWith("postgres://")) {
-        throw Exception("only the postgresql:// URI scheme is supported, not 
postgres://")
-    }
     // Pass through jdbc URIs.
     if (pgConn.startsWith("jdbc:")) {
         return pgConn
@@ -318,5 +315,11 @@ fun getJdbcConnectionFromPg(pgConn: String): String {
         return 
"jdbc:postgresql://localhost${parsed.path}?user=$pgUser&socketFactory=org.newsclub.net.unix."
 +
                 
"AFUNIXSocketFactory\$FactoryArg&socketFactoryArg=$socketLocation"
     }
+    if (pgConn.startsWith("postgres://")) {
+        // The JDBC driver doesn't like postgres://, only postgresql://.
+        // For consistency with other components, we normalize the postgres:// 
URI
+        // into one that the JDBC driver likes.
+        return "jdbc:postgresql://" + pgConn.removePrefix("postgres://")
+    }
     return "jdbc:$pgConn"
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]