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,
|
text: sql,
|
||||||
values: values,
|
values: values,
|
||||||
rowMode: 'array',
|
rowMode: 'array',
|
||||||
}).catch(function(err) {
|
|
||||||
onError(err);
|
|
||||||
}).then(function(result) {
|
}).then(function(result) {
|
||||||
onSuccess(result.rows);
|
onSuccess(result.rows);
|
||||||
|
}).catch(function(err) {
|
||||||
|
onError(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
return function (cancelError, cancelerError, cancelerSuccess) {
|
return function (cancelError, cancelerError, cancelerSuccess) {
|
||||||
|
@ -10,6 +10,7 @@ import Data.Array (zip)
|
|||||||
import Data.Date (Date, canonicalDate)
|
import Data.Date (Date, canonicalDate)
|
||||||
import Data.DateTime.Instant (Instant, unInstant)
|
import Data.DateTime.Instant (Instant, unInstant)
|
||||||
import Data.Decimal as D
|
import Data.Decimal as D
|
||||||
|
import Data.Either (isLeft)
|
||||||
import Data.Enum (toEnum)
|
import Data.Enum (toEnum)
|
||||||
import Data.Foldable (all, length)
|
import Data.Foldable (all, length)
|
||||||
import Data.JSDate (JSDate, jsdate, toInstant)
|
import Data.JSDate (JSDate, jsdate, toInstant)
|
||||||
@ -169,6 +170,15 @@ main = void $ launchAff do
|
|||||||
""") Row0
|
""") Row0
|
||||||
liftEffect <<< assert $ sauerkrautPrice == [Row1 (D.fromString "3.30")]
|
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
|
test conn "handling date value" $ do
|
||||||
let
|
let
|
||||||
d1 = date 2010 2 31
|
d1 = date 2010 2 31
|
||||||
|
Loading…
Reference in New Issue
Block a user