summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphadej <>2018-03-20 20:04:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-03-20 20:04:00 (GMT)
commita40708d443769915cec1e917857bbdb220ff159d (patch)
tree976f55fb9b43a028540fe0c4a419fb052ad19083
parent27a440ce40680d540fb2f03974a621977bf40864 (diff)
version 0.2.1.0HEAD0.2.1.0master
-rw-r--r--CHANGELOG.md8
-rw-r--r--postgresql-simple-url.cabal31
-rw-r--r--src/Database/PostgreSQL/Simple/URL.hs13
3 files changed, 37 insertions, 15 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52a04f9..e7c8023 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,8 @@
+# 0.2.1.0
+
+- Accept `postgresql` schema (not only `postgres`)
+
# 0.2.0.0
-Allow empty host, i.e. don't use default provided by `postgresql-simple`.
-Empty host is required to use unix domain sockets.
+- Allow empty host, i.e. don't use default provided by `postgresql-simple`.
+ Empty host is required to use unix domain sockets.
diff --git a/postgresql-simple-url.cabal b/postgresql-simple-url.cabal
index 6593985..ac61327 100644
--- a/postgresql-simple-url.cabal
+++ b/postgresql-simple-url.cabal
@@ -1,20 +1,33 @@
name: postgresql-simple-url
-version: 0.2.0.0
+version: 0.2.1.0
synopsis: Parse postgres:// url into ConnectInfo
description:
The 'Database.PostgreSQL.Simple.URL' module in this package exports
- two helper functions 'parseDatabaseUrl' and 'urlToConnectInfo'.
+ two helper functions 'parseDatabaseUrl' and 'urlToConnectInfo' to
+ construct 'ConnectInfo' from URI (or string).
+ .
+ @
+ >>> parseDatabaseUrl "postgres://foo:bar@example.com:2345/database"
+ Just (ConnectInfo "example.com" 2345 "foo" "bar" "database")
+ @
homepage: https://github.com/futurice/postgresql-simple-url
license: MIT
license-file: LICENSE
author: Oleg Grenrus
maintainer: Oleg Grenrus <oleg.grenrus@iki.fi>
-copyright: Copyright © 2014 Futurice OY, Oleg Grenrus
+copyright: Copyright © 2014-2018 Futurice OY, Oleg Grenrus
stability: experimental
-category: Game
+category: Database
build-type: Simple
extra-source-files: README.md, CHANGELOG.md
cabal-version: >=1.10
+tested-with:
+ GHC==7.6.3,
+ GHC==7.8.4,
+ GHC==7.10.3,
+ GHC==8.0.2,
+ GHC==8.2.2,
+ GHC==8.4.1
source-repository head
type: git
@@ -22,7 +35,7 @@ source-repository head
library
exposed-modules: Database.PostgreSQL.Simple.URL
- build-depends: base >=4.6 && <4.10,
+ build-depends: base >=4.6 && <4.12,
split >=0.2 && <0.3,
network-uri >=2.6 && <2.7,
postgresql-simple >=0.4 && <0.6
@@ -36,8 +49,8 @@ test-suite test
hs-source-dirs: tests
main-is: Tests.hs
ghc-options: -Wall
- build-depends: base >=4.6 && <4.10,
- tasty >=0.10 && <0.12,
- tasty-quickcheck >=0.8 && <0.9,
- postgresql-simple >=0.4 && <0.6,
+ build-depends: base,
+ postgresql-simple,
+ tasty >=0.10 && <1.1,
+ tasty-quickcheck >=0.8 && <0.11,
postgresql-simple-url
diff --git a/src/Database/PostgreSQL/Simple/URL.hs b/src/Database/PostgreSQL/Simple/URL.hs
index 55f6e69..dc86991 100644
--- a/src/Database/PostgreSQL/Simple/URL.hs
+++ b/src/Database/PostgreSQL/Simple/URL.hs
@@ -1,7 +1,7 @@
-----------------------------------------------------------------------------
-- |
-- Module : Database.PostgreSQL.Simple.URL
--- Copyright : 2014, 2015 © Futurice OY, Oleg Grenrus
+-- Copyright : 2014-2018 © Futurice OY, Oleg Grenrus
-- License : MIT (see the file LICENSE)
--
-- Maintainer : Oleg Grenrus <oleg.grenrus@iki.fi>
@@ -17,14 +17,19 @@ import Prelude
-- | Parse string url into `ConnectInfo`.
--
--- > parseDatabaseURL "postgres://foo:bar@example.com:2345/database" == ConnectInfo "example.com" 2345 "foo" "bar" "database"
+-- >>> parseDatabaseUrl "postgres://foo:bar@example.com:2345/database"
+-- Just (ConnectInfo {connectHost = "example.com", connectPort = 2345, connectUser = "foo", connectPassword = "bar", connectDatabase = "database"})
+--
+-- >>> parseDatabaseUrl "postgresql://foo:bar@example.com:2345/database"
+-- Just (ConnectInfo {connectHost = "example.com", connectPort = 2345, connectUser = "foo", connectPassword = "bar", connectDatabase = "database"})
+--
parseDatabaseUrl :: String -> Maybe ConnectInfo
parseDatabaseUrl databaseUrl = parseURI databaseUrl >>= uriToConnectInfo
uriToConnectInfo :: URI -> Maybe ConnectInfo
uriToConnectInfo uri
- | uriScheme uri /= "postgres:" = Nothing
- | otherwise = ($ defaultConnectInfo) <$> mkConnectInfo uri
+ | uriScheme uri /= "postgres:" && uriScheme uri /= "postgresql:" = Nothing
+ | otherwise = ($ defaultConnectInfo) <$> mkConnectInfo uri
type ConnectInfoChange = ConnectInfo -> ConnectInfo