accept null values for input values, closes #252 (#266)

This commit is contained in:
Rakesh Emmadi 2018-08-07 16:13:42 +05:30 committed by Vamshi Surabhi
parent 887b7ca835
commit 8ecb80d2da
5 changed files with 35 additions and 1 deletions

View File

@ -65,7 +65,8 @@ convertRowObj
-> m [(PGCol, S.SQLExp)]
convertRowObj val =
flip withObject val $ \_ obj -> forM (Map.toList obj) $ \(k, v) -> do
prepExp <- asPGColVal v >>= prepare
prepExpM <- asPGColValM v >>= mapM prepare
let prepExp = fromMaybe (S.SEUnsafe "NULL") prepExpM
return (PGCol $ G.unName k, prepExp)
mkConflictClause

View File

@ -51,6 +51,7 @@ gqlSpecFiles =
, "insert_mutation/article_on_conflict_error_03.yaml"
, "insert_mutation/person.yaml"
, "insert_mutation/person_array.yaml"
, "insert_mutation/order.yaml"
, "nested_select_query_article.yaml"
, "select_query_article_limit_offset.yaml"
, "select_query_article_limit_offset_error_01.yaml"

View File

@ -50,3 +50,11 @@ query:
city TEXT NOT NULL,
resident_id INTEGER REFERENCES resident(id)
)
- type: run_sql
args:
sql: |
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
placed TIMESTAMPTZ NOT NULL,
shipped TIMESTAMPTZ
)

View File

@ -0,0 +1,20 @@
description: Insert into order table with a null value
url: /v1alpha1/graphql
status: 200
query:
query: |
mutation insert_orders{
insert_orders(
objects: [
{
placed: "2017-08-19 14:22:11.802755+02",
shipped: null
}
]
) {
returning {
id
}
affected_rows
}
}

View File

@ -24,4 +24,8 @@ query:
args:
schema: public
name: address
- type: track_table
args:
schema: public
name: orders