pg-schema 0.7.1.1 → 0.7.1.2
raw patch · 5 files changed
+34/−6 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +3/−0
- pg-schema.cabal +1/−1
- src/PgSchema/Ann.hs +4/−0
- test-pgs/Main.hs +5/−0
- test-pgs/Tests/Aggregates.hs +21/−5
ChangeLog.md view
@@ -1,5 +1,8 @@ # Changelog for pg-schema +## 0.7.1.2+- Fix bug with aggregates (Min/Max/Sum/Avg)+ ## 0.7.1.1 - Add upsertJSONText, upsertJSONText_
pg-schema.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.12 name: pg-schema-version: 0.7.1.1+version: 0.7.1.2 category: Database author: Dmitry Olshansky maintainer: olshanskydr@gmail.com
src/PgSchema/Ann.hs view
@@ -165,6 +165,10 @@ (ApplyRenamer ren fld) ('RFToHere fromTab refs) ] ColFI ann fld ('RFSelfRef tab refs) [t] = ColFI ann fld ('RFToHere tab refs) [t] ColFI ann fld ('RFSelfRef tab refs) t = ColFI ann fld ('RFFromHere tab refs) t+ ColFI ('Ann ren sch d tab) fld ('RFPlain fd) (Aggr af t) =+ '[ 'ColInfo '(fld, 0) (Aggr af t) (ApplyRenamer ren fld) ('RFAggr fd af 'True) ]+ ColFI ('Ann ren sch d tab) fld ('RFPlain fd) (Aggr' af t) =+ '[ 'ColInfo '(fld, 0) (Aggr' af t) (ApplyRenamer ren fld) ('RFAggr fd af 'False) ] ColFI ('Ann ren sch d _) fld fd t = '[ 'ColInfo '(fld, 0) t (ApplyRenamer ren fld) fd ] -------------------------------------------------------------------------------- -- GCols (closed TF: Generic Rep)
test-pgs/Main.hs view
@@ -13,6 +13,7 @@ import Tests.InsertJSONTransaction import Tests.UpsertUniqueKey import Tests.Conditions+import Tests.Aggregates prop_not_implemented :: Property prop_not_implemented = property $ fail "not implemented"@@ -60,6 +61,10 @@ , testGroup "Query (test_dml)" [ testProperty "'Simple' queries" $ prop_cond_query pool , testProperty "Conditions by duplicated path" $ prop_cond_by_dup_path pool+ ]+ , testGroup "Aggregates (test_dml)"+ [ testProperty "Aggr' on plain column is not in GROUP BY" $+ prop_selectText_aggr_plain_not_in_group_by pool ] -- , testProperty "Cond: Child / Parent exists" prop_not_implemented -- , testProperty "Conditions by path (root vs nested path)" prop_not_implemented
test-pgs/Tests/Aggregates.hs view
@@ -1,11 +1,27 @@+{-# LANGUAGE BlockArguments #-} module Tests.Aggregates where import Data.Pool as Pool-import Database.PostgreSQL.Simple+import Data.Text as T+import Database.PostgreSQL.Simple (Connection)+import GHC.Int import Hedgehog+import PgSchema.DML+import Utils -prop_aggr_multiple_max_min :: Pool Connection -> Property-prop_aggr_multiple_max_min _pool = property success -prop_aggr_duplicate_names_nested :: Pool Connection -> Property-prop_aggr_duplicate_names_nested _pool = property success+type RootGroupSel =+ "grp" := Int32+ :. "cnt" := Aggr' ACount Int64+ :. "name" := Aggr' AMin Text+++-- | 'Aggr'' on a plain column must become SQL aggregate, not GROUP BY key.+prop_selectText_aggr_plain_not_in_group_by :: Pool Connection -> Property+prop_selectText_aggr_plain_not_in_group_by _pool =+ property do+ let (sql, _) = selectText (AnnSch "root") @RootGroupSel qpEmpty+ T.isInfixOf "count(*)" sql === True+ T.isInfixOf "min(t0.name)" sql === True+ T.isInfixOf "group by grp" sql === True+ T.isInfixOf ",name" sql === False