Skip to content

Commit

Permalink
Merge branch 'master' into persistent-sqlite-conn-pool-config
Browse files Browse the repository at this point in the history
  • Loading branch information
parsonsmatt authored Dec 7, 2023
2 parents ce366c4 + d0d2bec commit 043d38a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ jobs:
- "8.8.4"
- "8.10.7"
- "9.0.2"
- "9.2.4"
- "9.4.1"
- "9.6.1"
- "9.2.7"
- "9.4.5"
include:
- ghc: "9.6.1"
cabal: "3.10"

env:
CONFIG: "--enable-tests --enable-benchmarks"
Expand Down
5 changes: 5 additions & 0 deletions persistent-mysql/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog for persistent-mysql

## 2.13.1.5

* [#1526](https://github.com/yesodweb/persistent/pull/1526)
* Parse `tinyint` column as `SqlOther "tinyint"` rather than `SqlBool`, fixing breakage in legitimate non-Boolean uses of `tinyint` on MySQL 8.0

## 2.13.1.4

* [#1459](https://github.com/yesodweb/persistent/pull/1459)
Expand Down
14 changes: 7 additions & 7 deletions persistent-mysql/Database/Persist/MySQL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -827,14 +827,16 @@ data ColumnInfo = ColumnInfo
-- @INFORMATION_SCHEMA@ tables.
parseColumnType :: Text -> ColumnInfo -> ExceptT String IO (SqlType, Maybe Integer)
-- Ints
-- The display width is deprecated and being removed in MySQL 8.X. To be
-- consistent with earlier versions, which do report it, accept either
-- The display width is deprecated and being removed in MySQL 8.X
-- with [an exception of tinyint(1) which is used for boolean values](https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html#mysqld-8-0-19-deprecation-removal).
-- To be consistent with earlier versions, which do report it, accept either
-- the bare type in `ciColumnType ci`, or the type adorned with the expected
-- value for the display width (ie the defaults for int and bigint, or the
-- value explicitly set in `showSqlType` for SqlBool).
--
parseColumnType "tinyint" ci
| ciColumnType ci == "tinyint" || ciColumnType ci == "tinyint(1)" = return (SqlBool, Nothing)
| ciColumnType ci == "tinyint(1)" = return (SqlBool, Nothing)
| otherwise = return (SqlOther "tinyint", Nothing)
parseColumnType "int" ci
| ciColumnType ci == "int" || ciColumnType ci == "int(11)" = return (SqlInt32, Nothing)
parseColumnType "bigint" ci
Expand Down Expand Up @@ -1023,10 +1025,8 @@ showSqlType :: SqlType
-> String
showSqlType SqlBlob Nothing _ = "BLOB"
showSqlType SqlBlob (Just i) _ = "VARBINARY(" ++ show i ++ ")"
-- "tinyint(1)" has been used historically here. In MySQL 8, the display width
-- is deprecated, and in the future it may need to be removed here. However,
-- "(1)" is not the default in older MySQL versions, so for them omitting it
-- would alter the exact form of the column type in the information_schema.
-- While integer widths are deprecated in MySQL 8.0, "tinyint(1)" remains as an exception.
-- cf. https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html#mysqld-8-0-19-deprecation-removal
showSqlType SqlBool _ _ = "TINYINT(1)"
showSqlType SqlDay _ _ = "DATE"
showSqlType SqlDayTime _ _ = "DATETIME"
Expand Down
2 changes: 1 addition & 1 deletion persistent-mysql/persistent-mysql.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: persistent-mysql
version: 2.13.1.4
version: 2.13.1.5
license: MIT
license-file: LICENSE
author: Felipe Lessa <[email protected]>, Michael Snoyman
Expand Down
2 changes: 1 addition & 1 deletion persistent-mysql/test/MyInit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ runConn f = do
}
_ <- if not travis
then withMySQLPool baseConnectInfo
{ connectHost = "localhost"
{ connectHost = "127.0.0.1"
, connectUser = "test"
, connectPassword = "test"
, connectDatabase = "test"
Expand Down
8 changes: 7 additions & 1 deletion persistent-mysql/test/main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import MyInit

import qualified Data.ByteString as BS
import Data.Fixed
import Data.Int (Int8)
import Data.IntMap (IntMap)
import qualified Data.Text as T
import Data.Time (Day, TimeOfDay, UTCTime(..), timeOfDayToTime, timeToTimeOfDay)
Expand Down Expand Up @@ -90,6 +91,8 @@ DataTypeTable no-json
-- off for older servers by defining OLD_MYSQL.
timeFrac TimeOfDay sqltype=TIME(6)
utcFrac UTCTime sqltype=DATETIME(6)
tinyint Int8 sqltype=TINYINT
tinyint4 Int8 sqltype=TINYINT(4)
|]

instance Arbitrary (DataTypeTableGeneric backend) where
Expand All @@ -110,7 +113,8 @@ instance Arbitrary (DataTypeTableGeneric backend) where
<*> (truncateUTCTime =<< arbitrary) -- utc
<*> (truncateTimeOfDay =<< arbitrary) -- timeFrac
<*> (truncateUTCTime =<< arbitrary) -- utcFrac

<*> arbitrary -- tinyint
<*> choose (-8, 7) -- tinyint4
setup :: (HasCallStack, MonadUnliftIO m) => Migration -> ReaderT SqlBackend m ()
setup migration = do
printMigration migration
Expand Down Expand Up @@ -169,6 +173,8 @@ main = do
, TestFn "utc" (roundUTCTime . dataTypeTableUtc)
, TestFn "timeFrac" (dataTypeTableTimeFrac)
, TestFn "utcFrac" (dataTypeTableUtcFrac)
, TestFn "tinyint" dataTypeTableTinyint
, TestFn "tinyint4" dataTypeTableTinyint4
]
[ ("pico", dataTypeTablePico) ]
dataTypeTableDouble
Expand Down
5 changes: 1 addition & 4 deletions persistent-sqlite/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Changelog for persistent-sqlite

## 2.13.4.0
## 2.13.3.0 (unreleased)

* [#1524](https://github.com/yesodweb/persistent/pull/1524)
* Add Database.Persist.Sqlite.createSqlitePoolWithConfig to create a SQLite
connection pool with a connection string and ConnectionPoolConfig.
Using ConnectionPoolConfig, it is possible to set the connection idle timeout.

## 2.13.3.0

* [#1486](https://github.com/yesodweb/persistent/pull/1486)
* Add Database.Sqlite.open' which takes a ByteString

Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: nightly-2022-12-16
resolver: nightly-2023-05-03 # GHC 9.4.5

packages:
- ./persistent
Expand Down

0 comments on commit 043d38a

Please sign in to comment.