generated from tpl/purs
Avoid UnhandledPromiseRejectionWarning
on integrity errors
This commit is contained in:
parent
13eb0ef583
commit
9eb66e7068
@ -37,10 +37,10 @@ exports.ffiUnsafeQuery = function(client) {
|
||||
text: sql,
|
||||
values: values,
|
||||
rowMode: 'array',
|
||||
}).catch(function(err) {
|
||||
onError(err);
|
||||
}).then(function(result) {
|
||||
onSuccess(result.rows);
|
||||
}).catch(function(err) {
|
||||
onError(err);
|
||||
});
|
||||
|
||||
return function (cancelError, cancelerError, cancelerSuccess) {
|
||||
|
@ -10,6 +10,7 @@ import Data.Array (zip)
|
||||
import Data.Date (Date, canonicalDate)
|
||||
import Data.DateTime.Instant (Instant, unInstant)
|
||||
import Data.Decimal as D
|
||||
import Data.Either (isLeft)
|
||||
import Data.Enum (toEnum)
|
||||
import Data.Foldable (all, length)
|
||||
import Data.JSDate (JSDate, jsdate, toInstant)
|
||||
@ -169,6 +170,15 @@ main = void $ launchAff do
|
||||
""") Row0
|
||||
liftEffect <<< assert $ sauerkrautPrice == [Row1 (D.fromString "3.30")]
|
||||
|
||||
test conn "constraint failure" $ do
|
||||
withTransaction conn $ do
|
||||
result <- try $ execute conn (Query """
|
||||
INSERT INTO foods (name)
|
||||
VALUES ($1)
|
||||
""") (Row1 "pork")
|
||||
liftEffect <<< assert $ isLeft result
|
||||
testCount 0
|
||||
|
||||
test conn "handling date value" $ do
|
||||
let
|
||||
d1 = date 2010 2 31
|
||||
|
Loading…
Reference in New Issue
Block a user