Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# http://editorconfig.org
root = true

[Makefile]
indent_style = tabs
indent_size = 8
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{hs,md}]
indent_style = space
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Before submitting your PR, check that you've:

- [ ] Documented new APIs with [Haddock markup](https://www.haskell.org/haddock/doc/html/index.html)
- [ ] Added [`@since` declarations](http://haskell-haddock.readthedocs.io/en/latest/markup.html#since) to the Haddock
- [ ] Ran `stylish-haskell` on any changed files.
- [ ] Adhered to the code style (see the `.editorconfig` file for details)

After submitting your PR:

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ jobs:
- run: cabal v2-build all --disable-optimization $CONFIG
- run: cabal v2-test all --disable-optimization $CONFIG
- run: cabal v2-haddock all $CONFIG
continue-on-error: true
- run: cabal v2-sdist all
39 changes: 39 additions & 0 deletions .stylish-haskell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
steps:
- imports:
align: none
list_align: with_module_name
pad_module_names: false
long_list_align: new_line_multiline
empty_list_align: inherit
list_padding: 7 # length "import "
separate_lists: false
space_surround: false
- language_pragmas:
style: vertical
align: false
remove_redundant: true
- simple_align:
cases: false
top_level_patterns: false
records: false
- trailing_whitespace: {}
indent: 4
columns: 80
newline: native
language_extensions:
- BlockArguments
- DataKinds
- DeriveGeneric
- DerivingStrategies
- DerivingVia
- ExplicitForAll
- FlexibleContexts
- MultiParamTypeClasses
- NamedFieldPuns
- OverloadedStrings
- QuantifiedConstraints
- RecordWildCards
- ScopedTypeVariables
- TemplateHaskell
- TypeApplications
- ViewPatterns
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ Clone the repo and run `stack build` to build all targets. Persistent
supports many backends. If you have only some of these installed the
[development doc](development.md) shows how to build against a subset of
targets.

## Development

For more information on how to hack ont he `persistent` set of libraries, see
the [`development.md`](development.md) file.
27 changes: 26 additions & 1 deletion development.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# Style Guide

## `stylish-haskell`

This repository uses
[`stylish-haskell`](https://hackage.haskell.org/package/stylish-haskell) as an
autoformatter. `stylish-haskell` is inherently limited, so it won't handle
everything, but it will format import lists, extension lists, etc.

## `editorconfig`

This repository has an `.editorconfig` file for use with the
[`EditorConfig`](https://editorconfig.org/) tool. It's recommended to install
the tool so that the editor style is picked up automatically.

## General Style Guide

Prefer 4 space indentation. If the line gets too long, refactor the code - pull
out named terms into `let` or `where` bindings (or top-level functions).

Prefer `case` expressions over combinators. Prefer `do` notation over combinators.
It's easier, simpler, and faster to read and modify these forms than more
concise versions, even where the more concise version is faster to write at
first.

# Building with Backends

With all required backends installed, `stack build` can build all packages
Expand All @@ -17,7 +42,7 @@ will fail as will builds for packages for those backends alone:
Process exited with code: ExitFailure 1
Configuring mysql-0.1.4...
setup: The program 'mysql_config' is required but it could not be found

> stack build persistent-postgresql
...
Process exited with code: ExitFailure 1
Expand Down
4 changes: 2 additions & 2 deletions persistent-mysql/Database/Persist/MySQL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ getGetter field = go (MySQLBase.fieldType field)
-- Controversial conversions
go MySQLBase.Set _ _ = convertPV PersistText
go MySQLBase.Enum _ _ = convertPV PersistText
-- Conversion using PersistDbSpecific
-- Conversion using PersistLiteral
go MySQLBase.Geometry _ _ = \_ m ->
case m of
Just g -> PersistLiteral g
Expand Down Expand Up @@ -1428,7 +1428,7 @@ copyField = CopyField
-- []
-- @
--
-- Once we run that code on the datahase, the new data set looks like this:
-- Once we run that code on the database, the new data set looks like this:
--
-- > items:
-- > +------+-------------+-------+----------+
Expand Down
3 changes: 3 additions & 0 deletions persistent-mysql/test/InsertDuplicateUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ specs = describe "DuplicateKeyUpdate" $ do
dbItems <- map entityVal <$> selectList [] []
sort dbItems @== sort (newItem : items)
it "updates existing records" $ db $ do
let postUpdate = map (\i -> i { itemQuantity = fmap (+1) (itemQuantity i) }) items
deleteWhere ([] :: [Filter Item])
insertMany_ items
insertManyOnDuplicateKeyUpdate
items
[]
[ItemQuantity +=. Just 1]
dbItems <- sort . fmap entityVal <$> selectList [] []
dbItems @== sort postUpdate
it "only copies passing values" $ db $ do
deleteWhere ([] :: [Filter Item])
insertMany_ items
Expand Down
4 changes: 4 additions & 0 deletions persistent-postgresql/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for persistent-postgresql

## 2.12.1.0

* Added `upsertWhere` and `upsertManyWhere` to `persistent-postgresql`. [#1222](https://github.com/yesodweb/persistent/pull/1222).

## 2.12.0.0

* Decomposed `HaskellName` into `ConstraintNameHS`, `EntityNameHS`, `FieldNameHS`. Decomposed `DBName` into `ConstraintNameDB`, `EntityNameDB`, `FieldNameDB` respectively. [#1174](https://github.com/yesodweb/persistent/pull/1174)
Expand Down
Loading