Hello community,

here is the log from the commit of package ghc-persistent-sqlite for 
openSUSE:Factory checked in at 2019-08-24 18:44:26
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-persistent-sqlite (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-persistent-sqlite.new.7948 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-persistent-sqlite"

Sat Aug 24 18:44:26 2019 rev:17 rq:725522 version:2.10.5

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/ghc-persistent-sqlite/ghc-persistent-sqlite.changes  
    2019-08-13 13:15:17.569505304 +0200
+++ 
/work/SRC/openSUSE:Factory/.ghc-persistent-sqlite.new.7948/ghc-persistent-sqlite.changes
    2019-08-24 18:44:27.577768571 +0200
@@ -1,0 +2,8 @@
+Wed Aug 21 02:02:45 UTC 2019 - [email protected]
+
+- Update persistent-sqlite to version 2.10.5.
+  ## 2.10.5
+
+  * Foreign keys table constraints are correctly generated 
[#945](https://github.com/yesodweb/persistent/pull/945) @kderme
+
+-------------------------------------------------------------------

Old:
----
  persistent-sqlite-2.10.4.tar.gz

New:
----
  persistent-sqlite-2.10.5.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-persistent-sqlite.spec ++++++
--- /var/tmp/diff_new_pack.Eosc39/_old  2019-08-24 18:44:28.221768509 +0200
+++ /var/tmp/diff_new_pack.Eosc39/_new  2019-08-24 18:44:28.225768509 +0200
@@ -19,7 +19,7 @@
 %global pkg_name persistent-sqlite
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        2.10.4
+Version:        2.10.5
 Release:        0
 Summary:        Backend for the persistent library using sqlite3
 License:        MIT

++++++ persistent-sqlite-2.10.4.tar.gz -> persistent-sqlite-2.10.5.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/persistent-sqlite-2.10.4/ChangeLog.md 
new/persistent-sqlite-2.10.5/ChangeLog.md
--- old/persistent-sqlite-2.10.4/ChangeLog.md   2019-07-24 17:02:54.000000000 
+0200
+++ new/persistent-sqlite-2.10.5/ChangeLog.md   2019-08-20 23:10:17.000000000 
+0200
@@ -1,5 +1,9 @@
 # Changelog for persistent-sqlite
 
+## 2.10.5
+
+* Foreign keys table constraints are correctly generated 
[#945](https://github.com/yesodweb/persistent/pull/945) @kderme
+
 ## 2.10.4
 
 * Fix bug with 2.10.3 and 2.10.2 that caused the `RawSqlite` loop. 
[#934](https://github.com/yesodweb/persistent/pull/934) @merijn
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/persistent-sqlite-2.10.4/Database/Persist/Sqlite.hs 
new/persistent-sqlite-2.10.5/Database/Persist/Sqlite.hs
--- old/persistent-sqlite-2.10.4/Database/Persist/Sqlite.hs     2019-07-24 
16:59:20.000000000 +0200
+++ new/persistent-sqlite-2.10.5/Database/Persist/Sqlite.hs     2019-08-20 
23:10:17.000000000 +0200
@@ -391,8 +391,8 @@
          -> EntityDef
          -> IO (Either [Text] [(Bool, Text)])
 migrate' allDefs getter val = do
-    let (cols, uniqs, _) = mkColumns allDefs val
-    let newSql = mkCreateTable False def (filter (not . safeToRemove val . 
cName) cols, uniqs)
+    let (cols, uniqs, fdefs) = mkColumns allDefs val
+    let newSql = mkCreateTable False def (filter (not . safeToRemove val . 
cName) cols, uniqs, fdefs)
     stmt <- getter "SELECT sql FROM sqlite_master WHERE type='table' AND 
name=?"
     oldSql' <- with (stmtQuery stmt [PersistText $ unDBName table])
       (\src -> runConduit $ src .| go)
@@ -496,10 +496,10 @@
             Just y -> error $ "Invalid result from PRAGMA table_info: " ++ 
show y
     table = entityDB def
     tableTmp = DBName $ unDBName table <> "_backup"
-    (cols, uniqs, _) = mkColumns allDefs def
+    (cols, uniqs, fdef) = mkColumns allDefs def
     cols' = filter (not . safeToRemove def . cName) cols
-    newSql = mkCreateTable False def (cols', uniqs)
-    tmpSql = mkCreateTable True def { entityDB = tableTmp } (cols', uniqs)
+    newSql = mkCreateTable False def (cols', uniqs, fdef)
+    tmpSql = mkCreateTable True def { entityDB = tableTmp } (cols', uniqs, [])
     dropTmp = "DROP TABLE " <> escape tableTmp
     dropOld = "DROP TABLE " <> escape table
     copyToTemp common = T.concat
@@ -521,8 +521,8 @@
         , escape tableTmp
         ]
 
-mkCreateTable :: Bool -> EntityDef -> ([Column], [UniqueDef]) -> Text
-mkCreateTable isTemp entity (cols, uniqs) =
+mkCreateTable :: Bool -> EntityDef -> ([Column], [UniqueDef], [ForeignDef]) -> 
Text
+mkCreateTable isTemp entity (cols, uniqs, fdefs) =
   case entityPrimary entity of
     Just pdef ->
        T.concat
@@ -537,6 +537,7 @@
         , T.intercalate "," $ map (escape . fieldDB) $ compositeFields pdef
         , ")"
         , T.concat $ map sqlUnique uniqs
+        , T.concat $ map sqlForeign fdefs
         , ")"
         ]
     Nothing -> T.concat
@@ -552,6 +553,7 @@
         , mayDefault $ defaultAttribute $ fieldAttrs $ entityId entity
         , T.concat $ map (sqlColumn isTemp) cols
         , T.concat $ map sqlUnique uniqs
+        , T.concat $ map sqlForeign fdefs
         , ")"
         ]
 
@@ -573,6 +575,19 @@
         Just (table, _) -> if noRef then "" else " REFERENCES " <> escape table
     ]
 
+sqlForeign :: ForeignDef -> Text
+sqlForeign fdef = T.concat
+    [ ", CONSTRAINT "
+    , escape $ foreignConstraintNameDBName fdef
+    , " FOREIGN KEY("
+    , T.intercalate "," $ map (escape . snd. fst) $ foreignFields fdef
+    , ") REFERENCES "
+    , escape $ foreignRefTableDBName fdef
+    , "("
+    , T.intercalate "," $ map (escape . snd . snd) $ foreignFields fdef
+    , ")"
+    ]
+
 sqlUnique :: UniqueDef -> Text
 sqlUnique (UniqueDef _ cname cols _) = T.concat
     [ ",CONSTRAINT "
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/persistent-sqlite-2.10.4/persistent-sqlite.cabal 
new/persistent-sqlite-2.10.5/persistent-sqlite.cabal
--- old/persistent-sqlite-2.10.4/persistent-sqlite.cabal        2019-07-24 
17:02:59.000000000 +0200
+++ new/persistent-sqlite-2.10.5/persistent-sqlite.cabal        2019-08-20 
23:10:17.000000000 +0200
@@ -1,5 +1,5 @@
 name:            persistent-sqlite
-version:         2.10.4
+version:         2.10.5
 license:         MIT
 license-file:    LICENSE
 author:          Michael Snoyman <[email protected]>


Reply via email to