pg-schema-0.9.0.0: ChangeLog.md
# Changelog for pg-schema
## 0.9.0.0
- Fix typos in some compile-time error messages
- Improve Haddock
- Remove the unused constructor `RFEmpty` of `RecField'`.
- `PgOid` is no longer exported from `PgSchema.DML`: it is used only to read
the system catalogs, and its `Eq` instance treats all values as equal.
Use `Int` for `oid` columns.
- `PgSchema.DML` exports the type `FldDef'` (used by `FdType` / `FdNullable`).
- Fix: tree DML (`insertJSON`, `upsertJSON`, `updateJSON` and their `_`
variants) stored `Nothing` for a nullable `json` / `jsonb` column as the JSON
value `null` instead of SQL `NULL`. Now `Nothing` gives SQL `NULL`. A JSON `null`
value (e.g. `Just Aeson.Null` in a `Maybe Value` field) can't be told apart
from `Nothing` in the JSON sent to PostgreSQL, so it is stored as SQL `NULL`
too; use `insertSch` / `updateByCond` to store the JSON value `null` itself.
- `named` (and type family `Named`): give field names once for a whole list of
plain rows instead of `"field" =: value` in every row.
- `rowsOf` / `plains`: rows from / to plain values with field names and types
taken from the row type.
- Aggregate fields (`Aggr` / `Aggr'`) are now type-checked against the SQL
result type of the aggregate function. Previously the check was not applied
at all.
- `qPath` / `qPathFromHere` / `qPathToHere` with an unknown relation name now
report `relation "..." is not defined` with the valid relations of the table
(previously `qPath` reported a misleading self-reference error).
- Fix `RETURNING` checks of `insertJSON` / `upsertJSON` / `updateJSON`
(`ReturningMatchesInsert` / `ReturningMatchesUpsert` / `ReturningMatchesUpdate`),
which were silently skipped in most cases.
Code that compiled only because of this may now fail to compile:
- `updateJSON`: child list elements must be `Maybe`;
- `insertJSON`: child list elements must not be `Maybe`;
- `upsertJSON`: a child list element must be `Maybe` iff the child in the
*input* row lacks mandatory columns (previously the *returning* columns
were used) or upsert uses `ON CONFLICT DO NOTHING` with parent FK columns
outside the conflict key; the root returning row must be `Maybe` if the
input root row lacks mandatory columns.
- `NeedsFkKeyOnlyMaybe` matched the opposite case (a child with plain columns
outside the conflict key, i.e. `ON CONFLICT … DO UPDATE`, which always
returns the row); now it matches `ON CONFLICT DO NOTHING` as documented.
- `upsertJSON`: a child upserted with `ON CONFLICT DO NOTHING` whose key
belongs to a row of another parent (parent FK outside the key) was returned
as an object of `null` columns (a JSON decoding error) or, when the returning
columns were all in the input, as if it were found under this parent; its own
children were still processed. Now such a child is returned as `null`
(`Nothing`) and its children are skipped, as for a row not found by `UPDATE`.
- Fix: `upsertByKey` with a record whose fields all belong to the key used
`ON CONFLICT DO NOTHING` and returned nothing for rows that already existed.
Now it uses a no-op `ON CONFLICT (key) DO UPDATE`: an existing row is left
as is and returned, so there is one returned row per input record.
`upsertByKey_` uses `ON CONFLICT (key) DO NOTHING` in this case; previously
the conflict target was missing, so a conflict on another unique key was
silently ignored, and now it is an error, as for other records.
## 0.8.1.1
- aeson upper version is changed
## 0.8.1.0
- upsertJSON: require `Maybe` on child returning when upsert uses
`ON CONFLICT DO NOTHING` with parent FK columns outside the conflict key
(`NeedsFkKeyOnlyMaybe` in `ReturningMatchesUpsert`)
## 0.8.0.1
- Build all with -Wall
- Small fixes in doc
## 0.8.0.0
- Fix SELECT path matching after renamer: promoted `PathElem'` (`peName`,
`peDbName`, `peKind`) replaces `(Text, PathKind)`; runtime `pathStepMatches`
supports point paths and broadcast by shared db fk name; independent filters
on aliased sibling fields (e.g. `mid1RootFk` vs `mid1_root_fk2`).
- Internal SELECT paths: `[PathElemK]` in `PathCtx` / `TabOnDPathRen`; removed
`EffPath` on renamer-only pairs; `TabOnDPath2` walks `peDbName`.
- Flat DML: `upsertByKey` / `upsertByKey_` and `updateByKey` / `updateByKey_`
(`upsertByKey` requires all mandatory columns and a full key — always
`INSERT … ON CONFLICT …`; `updateByKey` is key-only, never inserts, bare
returning type `r'`, result `IO ([Maybe r'], Text)`).
- Tree DML: `updateJSON` / `updateJSON_` (update-only); `InsertMode` for the
JSON pipeline.
- Tree returning: Maybe or Bare for `upsertJSON`.
- New constraints: `AllHasKeyTree`, `CheckHasKey`, `ReturningMatches{Insert,Upsert,Update}`,
`FromJSON` / `ToJSON` for `Maybe` rows and `null` in returning arrays.
- Rename `TreeSch` to `HasSchema`
## 0.7.1.2
- Fix bug with aggregates (Min/Max/Sum/Avg)
## 0.7.1.1
- Add upsertJSONText, upsertJSONText_
## 0.7.1.0
- Condition DSL: `(=??)` on nullable columns generates SQL
`IS NOT DISTINCT FROM` (same null-safe key equality as upsertJSON)
- Improve transaction behavior for insertJSON/upsertJSON
- Add tests for insertJSON/upsertJSON with transactions
- `upsertJSON` / `upsertJSON_`: optional `ON CONFLICT` targets include NOT NULL
unique keys (primary key still first), then nullable unique keys when the table
has no NOT NULL UK; `UPDATE` by key uses `IS NOT DISTINCT FROM` for key columns;
`IdentityCandidates` (compile-time) lists every PK/UK from the schema
- `insertJSON` / `insertJSON_`: insert-only (plain `INSERT`, no `ON CONFLICT` or
`UPDATE`; duplicate keys fail at the database)
- Rename `AllMandatoryOrHasPKTree` to `AllMandatoryOrHasKeyTree`
## 0.7.0.1
- Bug fixing (upsertJSON_ without change fields: on conflict do nothing)
## 0.7.0.0
- Bug fixing (updateText_ signature)
- Change signature for deleteByCond
- Add CondAnn & QueryParamsAnn
## 0.6.1.0
- Bug fixing (ins/upsertJSON for json db-fields)
## 0.6.0.0
- Using Renamer for QueryParams and Cond
- Improve error messaging
- Support for 'UnsafeCol'
- Check possibility of type conversions for select-list/insert/update (it was broken in 0.5.0)
- Check optional/mandatory for parent references is SELECT
- Added qPathFromHere/qPathToHere. Self-reference require explicit direction in qPathXXX
## 0.5.2.0
- Bug fixing (Problem with Self-references)
## 0.5.1.1
- Improve error messaging
## 0.5.1.0
- Bug fixing (TF stucks in some cases)
## 0.5.0.0
- First release on Hackage