packages feed

relational-record-examples 0.5.0.0 → 0.5.1.0

raw patch · 3 files changed

+39/−53 lines, 3 filesdep ~relational-queryPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: relational-query

API changes (from Hackage documentation)

- Transaction: instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Types.Int -> Data.Time.LocalTime.LocalTime.LocalTime -> GHC.Types.Int -> GHC.Base.String -> GHC.Types.Double -> GHC.Base.Maybe GHC.Types.Int -> GHC.Base.Maybe GHC.Types.Int -> GHC.Base.Maybe Data.Time.LocalTime.LocalTime.LocalTime -> Transaction.Transaction0)
- Transaction: instance Database.Relational.OverloadedProjection.HasProjection "fundsAvailDate" Transaction.Transaction0 (GHC.Base.Maybe Data.Time.LocalTime.LocalTime.LocalTime)
- Transaction: instance Database.Relational.OverloadedProjection.HasProjection "txnDate" Transaction.Transaction0 Data.Time.LocalTime.LocalTime.LocalTime
+ Account: instance Database.Relational.OverloadedProjection.HasProjection "primary" Account.Account GHC.Types.Int
+ Branch: instance Database.Relational.OverloadedProjection.HasProjection "primary" Branch.Branch GHC.Types.Int
+ Business: instance Database.Relational.OverloadedProjection.HasProjection "primary" Business.Business GHC.Types.Int
+ Customer: instance Database.Relational.OverloadedProjection.HasProjection "primary" Customer.Customer GHC.Types.Int
+ Department: instance Database.Relational.OverloadedProjection.HasProjection "primary" Department.Department GHC.Types.Int
+ Employee: instance Database.Relational.OverloadedProjection.HasProjection "primary" Employee.Employee GHC.Types.Int
+ Individual: instance Database.Relational.OverloadedProjection.HasProjection "primary" Individual.Individual GHC.Types.Int
+ Officer: instance Database.Relational.OverloadedProjection.HasProjection "primary" Officer.Officer GHC.Types.Int
+ Product: instance Database.Relational.OverloadedProjection.HasProjection "primary" Product.Product GHC.Base.String
+ ProductType: instance Database.Relational.OverloadedProjection.HasProjection "primary" ProductType.ProductType GHC.Base.String
+ Transaction: instance Data.Functor.ProductIsomorphic.Unsafe.ProductConstructor (GHC.Types.Int -> Data.Time.LocalTime.Internal.LocalTime.LocalTime -> GHC.Types.Int -> GHC.Base.String -> GHC.Types.Double -> GHC.Base.Maybe GHC.Types.Int -> GHC.Base.Maybe GHC.Types.Int -> GHC.Base.Maybe Data.Time.LocalTime.Internal.LocalTime.LocalTime -> Transaction.Transaction0)
+ Transaction: instance Database.Relational.OverloadedProjection.HasProjection "fundsAvailDate" Transaction.Transaction0 (GHC.Base.Maybe Data.Time.LocalTime.Internal.LocalTime.LocalTime)
+ Transaction: instance Database.Relational.OverloadedProjection.HasProjection "primary" Transaction.Transaction0 GHC.Types.Int
+ Transaction: instance Database.Relational.OverloadedProjection.HasProjection "txnDate" Transaction.Transaction0 Data.Time.LocalTime.Internal.LocalTime.LocalTime
- Account: insertQueryAccount :: forall p_avd4. Relation p_avd4 Account -> InsertQuery p_avd4
+ Account: insertQueryAccount :: forall p_alJf. Relation p_alJf Account -> InsertQuery p_alJf
- Branch: insertQueryBranch :: forall p_ateH. Relation p_ateH Branch -> InsertQuery p_ateH
+ Branch: insertQueryBranch :: forall p_ajSj. Relation p_ajSj Branch -> InsertQuery p_ajSj
- Business: insertQueryBusiness :: forall p_arK8. Relation p_arK8 Business -> InsertQuery p_arK8
+ Business: insertQueryBusiness :: forall p_aiq5. Relation p_aiq5 Business -> InsertQuery p_aiq5
- Customer: insertQueryCustomer :: forall p_apwx. Relation p_apwx Customer -> InsertQuery p_apwx
+ Customer: insertQueryCustomer :: forall p_a9Gr. Relation p_a9Gr Customer -> InsertQuery p_a9Gr
- Department: insertQueryDepartment :: forall p_a9RH. Relation p_a9RH Department -> InsertQuery p_a9RH
+ Department: insertQueryDepartment :: forall p_apm0. Relation p_apm0 Department -> InsertQuery p_apm0
- Employee: insertQueryEmployee :: forall p_adxC. Relation p_adxC Employee -> InsertQuery p_adxC
+ Employee: insertQueryEmployee :: forall p_aqgF. Relation p_aqgF Employee -> InsertQuery p_aqgF
- Individual: insertQueryIndividual :: forall p_agtZ. Relation p_agtZ Individual -> InsertQuery p_agtZ
+ Individual: insertQueryIndividual :: forall p_asYp. Relation p_asYp Individual -> InsertQuery p_asYp
- Officer: insertQueryOfficer :: forall p_ahYy. Relation p_ahYy Officer -> InsertQuery p_ahYy
+ Officer: insertQueryOfficer :: forall p_auon. Relation p_auon Officer -> InsertQuery p_auon
- Product: insertQueryProduct :: forall p_akj8. Relation p_akj8 Product -> InsertQuery p_akj8
+ Product: insertQueryProduct :: forall p_awzY. Relation p_awzY Product -> InsertQuery p_awzY
- ProductType: insertQueryProductType :: forall p_am07. Relation p_am07 ProductType -> InsertQuery p_am07
+ ProductType: insertQueryProductType :: forall p_ayba. Relation p_ayba ProductType -> InsertQuery p_ayba
- Transaction: insertQueryTransaction0 :: forall p_amUD. Relation p_amUD Transaction0 -> InsertQuery p_amUD
+ Transaction: insertQueryTransaction0 :: forall p_az3H. Relation p_az3H Transaction0 -> InsertQuery p_az3H

Files

relational-record-examples.cabal view
@@ -1,5 +1,5 @@ name:                relational-record-examples-version:             0.5.0.0+version:             0.5.1.0 synopsis:            Examples of Haskell Relationa Record description:         Provides examples of Haskell Relational Record license:             BSD3@@ -58,7 +58,7 @@                      , HDBC-session                      , HDBC-sqlite3                      , persistable-record >= 0.6-                     , relational-query >= 0.11+                     , relational-query >= 0.11.2                      , relational-query-HDBC >= 0.6.5                      , template-haskell                      -- not link directly but query type map@@ -71,7 +71,7 @@   ghc-options:         -Wall  executable examples-  if flag(binary)+  if impl(ghc >= 8.0) && flag(binary)     buildable:         True   else     buildable:         False
src/examples.hs view
@@ -29,7 +29,7 @@ import Product (product) --import qualified ProductType --import ProductType (ProductType, productType)-import Transaction (transaction)+import qualified Transaction import Employee (Employee, employee)  allAccount :: Relation () Account@@ -832,13 +832,12 @@ -- @ -- insertBranch_s1 :: Insert ()-insertBranch_s1 = derivedInsertValue $ do+insertBranch_s1 = insertValueNoPH $ do   Branch.name'     <-#  value "Headquarters"   #address  <-#  value (Just "3882 Main St.")   #city     <-#  value (Just "Waltham")   #state    <-#  value (Just "MA")   #zip      <-#  value (Just "02451")-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -849,7 +848,7 @@ -- @ -- insertBranch_s1P :: Insert Branch1-insertBranch_s1P = derivedInsert piBranch1+insertBranch_s1P = insert piBranch1  piBranch1 :: Pi Branch Branch1 piBranch1 = Branch1 |$| #name@@ -889,7 +888,7 @@ -- Above SQL is the same to the monadic building version. -- insertBranch_s1R :: Insert ()-insertBranch_s1R = derivedInsertValue $ do+insertBranch_s1R = insertValueNoPH $ do   piBranch1   <-#  value Branch1                          { b1Name = "Headquarters"                          , b1Address = Just "3882 Main St."@@ -897,7 +896,6 @@                          , b1State = Just "MA"                          , b1Zip = Just "02451"                          }-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -911,7 +909,7 @@ -- Above SQL is the same to ad-hoc defined record version. -- insertBranch_s1PT :: Insert (String, Maybe String, Maybe String, Maybe String, Maybe String)-insertBranch_s1PT = derivedInsert piBranchTuple+insertBranch_s1PT = insert piBranchTuple  piBranchTuple :: Pi Branch (String, Maybe String, Maybe String, Maybe String, Maybe String) piBranchTuple = (,,,,)@@ -958,7 +956,7 @@ -- The name column of branch table is the same. -- insertEmployee_s2 :: InsertQuery ()-insertEmployee_s2 = derivedInsertQuery piEmployee3 . relation $ do+insertEmployee_s2 = insertQuery piEmployee3 . relation $ do   d <- query department   b <- query branch   wheres $ #name d .=. value "Administration"@@ -1007,7 +1005,7 @@ -- @ -- insertEmployee_s2U :: InsertQuery ()-insertEmployee_s2U = derivedInsertQuery piEmployee3 . relation $ do+insertEmployee_s2U = insertQuery piEmployee3 . relation $ do   d <- queryScalar . unsafeUnique . relation $ do     d' <- query department     wheres $ #name d' .=. value "Administration"@@ -1046,7 +1044,7 @@ -- @ -- insertEmployee_s2P :: InsertQuery Employee4-insertEmployee_s2P = derivedInsertQuery piEmployee3 . relation' $ do+insertEmployee_s2P = insertQuery piEmployee3 . relation' $ do   d <- query department   b <- query branch   wheres $ #name d .=. value "Administration"@@ -1087,11 +1085,10 @@ -- @ -- updateEmployee_o3 :: Update ()-updateEmployee_o3 = derivedUpdate $ \proj -> do+updateEmployee_o3 = updateNoPH $ \proj -> do   #lname  <-# value "Bush"   #deptId <-# just (value 3)   wheres $ #empId (proj :: Record Flat Employee) .=. value 10-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -1112,7 +1109,7 @@ -- @ -- updateEmployee_o3P :: Update (String, Int, Int)-updateEmployee_o3P = derivedUpdate $ \proj -> do+updateEmployee_o3P = update $ \proj -> do   (phLname,()) <- placeholder (\ph -> #lname <-# ph)   (phDeptId,()) <- placeholder (\ph -> #deptId <-# just ph)   (phEmpId,()) <- placeholder (\ph -> wheres $ #empId (proj :: Record Flat Employee) .=. ph)@@ -1145,19 +1142,18 @@ -- @ -- updateAccount_9_4_2 :: Update ()-updateAccount_9_4_2 = derivedUpdate $ \proj -> do+updateAccount_9_4_2 = updateNoPH $ \proj -> do   ts <- queryScalar $ aggregatedUnique (relation $ do-    t <- query transaction+    t <- query Transaction.transaction     wheres $ #accountId t .=. #accountId proj     return (#txnDate t)     ) id' max'   tl <- queryList $ relation $ do-    t <- query transaction+    t <- query Transaction.transaction     wheres $ #accountId t .=. #accountId proj     return (value (1 :: Int64))   Account.lastActivityDate' <-# (toDay $ flattenMaybe ts)   wheres $ exists $ tl-  return unitPlaceHolder  toDay :: SqlContext c => Record c (Maybe LocalTime) -> Record c (Maybe Day) toDay dt = unsafeProjectSql $ "date(" ++ unsafeShowSql dt ++ ")"@@ -1179,9 +1175,8 @@ -- @ -- deleteAccount_o1 :: Delete ()-deleteAccount_o1 = derivedDelete $ \proj -> do+deleteAccount_o1 = deleteNoPH $ \proj -> do   wheres $ proj ! Account.accountId' .=. value 2-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -1199,7 +1194,7 @@ -- @ -- deleteAccount_o1P :: Delete Int-deleteAccount_o1P = derivedDelete $ \proj -> do+deleteAccount_o1P = delete $ \proj -> do   fmap fst $ placeholder (\ph -> wheres $ proj ! Account.accountId' .=. ph)  -- |@@ -1220,11 +1215,10 @@ -- @ -- deleteAccount_o2 :: Delete ()-deleteAccount_o2 = derivedDelete $ \proj' -> do+deleteAccount_o2 = deleteNoPH $ \proj' -> do   let proj = proj' :: Record Flat Account   wheres $ #accountId proj .>=. value 10   wheres $ #accountId proj .<=. value 20-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -1235,7 +1229,7 @@ -- @ -- deleteAccount_o2P :: Delete (Int, Int)-deleteAccount_o2P = derivedDelete $ \proj' -> do+deleteAccount_o2P = delete $ \proj' -> do   let proj = proj' :: Record Flat Account   (phMin,()) <- placeholder (\ph -> wheres $ #accountId proj .>=. ph)   (phMax,()) <- placeholder (\ph -> wheres $ #accountId proj .<=. ph)@@ -1261,13 +1255,12 @@ -- @ -- deleteEmployee_9_4_2 :: Delete ()-deleteEmployee_9_4_2 = derivedDelete $ \proj -> do+deleteEmployee_9_4_2 = deleteNoPH $ \proj -> do   el <- queryList $ relation $ do     e <- query employee     wheres $ #deptId e .=. just (#deptId (proj :: Record Flat Department))     return (value (1 :: Int64))   wheres $ not' . exists $ el-  return unitPlaceHolder  -- -- run and print sql
src/specializedExamples.hs view
@@ -33,7 +33,7 @@ --import qualified ProductType --import ProductType (ProductType, productType) import qualified Transaction-import Transaction (transaction)+-- import Transaction (transaction) import qualified Employee import Employee (Employee, employee) @@ -837,13 +837,12 @@ -- @ -- insertBranch_s1 :: Insert ()-insertBranch_s1 = derivedInsertValue $ do+insertBranch_s1 = insertValueNoPH $ do   Branch.name'     <-#  value "Headquarters"   Branch.address'  <-#  value (Just "3882 Main St.")   Branch.city'     <-#  value (Just "Waltham")   Branch.state'    <-#  value (Just "MA")   Branch.zip'      <-#  value (Just "02451")-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -854,7 +853,7 @@ -- @ -- insertBranch_s1P :: Insert Branch1-insertBranch_s1P = derivedInsert piBranch1+insertBranch_s1P = insert piBranch1  piBranch1 :: Pi Branch Branch1 piBranch1 = Branch1 |$| Branch.name'@@ -894,7 +893,7 @@ -- Above SQL is the same to the monadic building version. -- insertBranch_s1R :: Insert ()-insertBranch_s1R = derivedInsertValue $ do+insertBranch_s1R = insertValueNoPH $ do   piBranch1   <-#  value Branch1                          { b1Name = "Headquarters"                          , b1Address = Just "3882 Main St."@@ -902,7 +901,6 @@                          , b1State = Just "MA"                          , b1Zip = Just "02451"                          }-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -916,7 +914,7 @@ -- Above SQL is the same to ad-hoc defined record version. -- insertBranch_s1PT :: Insert (String, Maybe String, Maybe String, Maybe String, Maybe String)-insertBranch_s1PT = derivedInsert piBranchTuple+insertBranch_s1PT = insert piBranchTuple  piBranchTuple :: Pi Branch (String, Maybe String, Maybe String, Maybe String, Maybe String) piBranchTuple = (,,,,)@@ -963,7 +961,7 @@ -- The name column of branch table is the same. -- insertEmployee_s2 :: InsertQuery ()-insertEmployee_s2 = derivedInsertQuery piEmployee3 . relation $ do+insertEmployee_s2 = insertQuery piEmployee3 . relation $ do   d <- query department   b <- query branch   wheres $ d ! Department.name' .=. value "Administration"@@ -1012,7 +1010,7 @@ -- @ -- insertEmployee_s2U :: InsertQuery ()-insertEmployee_s2U = derivedInsertQuery piEmployee3 . relation $ do+insertEmployee_s2U = insertQuery piEmployee3 . relation $ do   d <- queryScalar . unsafeUnique . relation $ do     d' <- query department     wheres $ d' ! Department.name' .=. value "Administration"@@ -1051,7 +1049,7 @@ -- @ -- insertEmployee_s2P :: InsertQuery Employee4-insertEmployee_s2P = derivedInsertQuery piEmployee3 . relation' $ do+insertEmployee_s2P = insertQuery piEmployee3 . relation' $ do   d <- query department   b <- query branch   wheres $ d ! Department.name' .=. value "Administration"@@ -1092,11 +1090,10 @@ -- @ -- updateEmployee_o3 :: Update ()-updateEmployee_o3 = derivedUpdate $ \proj -> do+updateEmployee_o3 = updateNoPH $ \proj -> do   Employee.lname' <-# value "Bush"   Employee.deptId' <-# just (value 3)   wheres $ proj ! Employee.empId' .=. value 10-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -1117,7 +1114,7 @@ -- @ -- updateEmployee_o3P :: Update (String, Int, Int)-updateEmployee_o3P = derivedUpdate $ \proj -> do+updateEmployee_o3P = update $ \proj -> do   (phLname,()) <- placeholder (\ph -> Employee.lname' <-# ph)   (phDeptId,()) <- placeholder (\ph -> Employee.deptId' <-# just ph)   (phEmpId,()) <- placeholder (\ph -> wheres $ proj ! Employee.empId' .=. ph)@@ -1150,19 +1147,18 @@ -- @ -- updateAccount_9_4_2 :: Update ()-updateAccount_9_4_2 = derivedUpdate $ \proj -> do+updateAccount_9_4_2 = updateNoPH $ \proj -> do   ts <- queryScalar $ aggregatedUnique (relation $ do-    t <- query transaction+    t <- query Transaction.transaction     wheres $ t ! Transaction.accountId' .=. proj ! Account.accountId'     return (t ! Transaction.txnDate')     ) id' max'   tl <- queryList $ relation $ do-    t <- query transaction+    t <- query Transaction.transaction     wheres $ t ! Transaction.accountId' .=. proj ! Account.accountId'     return (value (1 :: Int64))   Account.lastActivityDate' <-# (toDay $ flattenMaybe ts)   wheres $ exists $ tl-  return unitPlaceHolder  toDay :: SqlContext c => Record c (Maybe LocalTime) -> Record c (Maybe Day) toDay dt = unsafeProjectSql $ "date(" ++ unsafeShowSql dt ++ ")"@@ -1184,9 +1180,8 @@ -- @ -- deleteAccount_o1 :: Delete ()-deleteAccount_o1 = derivedDelete $ \proj -> do+deleteAccount_o1 = deleteNoPH $ \proj -> do   wheres $ proj ! Account.accountId' .=. value 2-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -1204,7 +1199,7 @@ -- @ -- deleteAccount_o1P :: Delete Int-deleteAccount_o1P = derivedDelete $ \proj -> do+deleteAccount_o1P = delete $ \proj -> do   fmap fst $ placeholder (\ph -> wheres $ proj ! Account.accountId' .=. ph)  -- |@@ -1225,10 +1220,9 @@ -- @ -- deleteAccount_o2 :: Delete ()-deleteAccount_o2 = derivedDelete $ \proj -> do+deleteAccount_o2 = deleteNoPH $ \proj -> do   wheres $ proj ! Account.accountId' .>=. value 10   wheres $ proj ! Account.accountId' .<=. value 20-  return unitPlaceHolder  -- | -- Placeholder version of Generated SQL:@@ -1239,7 +1233,7 @@ -- @ -- deleteAccount_o2P :: Delete (Int, Int)-deleteAccount_o2P = derivedDelete $ \proj -> do+deleteAccount_o2P = delete $ \proj -> do   (phMin,()) <- placeholder (\ph -> wheres $ proj ! Account.accountId' .>=. ph)   (phMax,()) <- placeholder (\ph -> wheres $ proj ! Account.accountId' .<=. ph)   return (phMin >< phMax)@@ -1264,13 +1258,12 @@ -- @ -- deleteEmployee_9_4_2 :: Delete ()-deleteEmployee_9_4_2 = derivedDelete $ \proj -> do+deleteEmployee_9_4_2 = deleteNoPH $ \proj -> do   el <- queryList $ relation $ do     e <- query employee     wheres $ e ! Employee.deptId' .=. just (proj ! Department.deptId')     return (value (1 :: Int64))   wheres $ not' . exists $ el-  return unitPlaceHolder  -- -- run and print sql