Hi @calebmer. I'm challenging problem. How I can set value to NULL?

One possible solution is to add boolean fields into Input shape for each nullable column,
like newImageFeatured for setting value
and imageFeaturedSetNull or nullImageFeatured for database NULL.
This definitely looks like a bug. I'll investigate š
@calebmer Can you point out some relevant pieces of code for me? I can prepare PR for this, but I feel there will be more discussion about this... So, any ideas? I really want this feature :smiling_imp:
For sure :blush:
This statement will be what you want to look at. Also, here where setClauses gets defined.
Also a quick crash-course on SQLBuilder (it was a quick and dirty solution, thereās a much cleaner SQL builder in the next branch :wink:). Counting up (think $1, $2, $3, etc.) like in normal prepared statements is hard to keep track of and very difficult to compose. So SQLBuilder allows you to just use $ and pass the array of ordered values like you normally would. Then SQLBuilder will compose those $ to have the correct index.
The bug may be here or it may be as easy a fix as changing this to:
if (value === null) {
setClauses.push(`"${column.name}" = null`)
}
else {
setClauses.push(`"${column.name}" = $`)
setValues.push(value)
}
(pg may not like nulls :blush:)
Let me know how it goes :+1: :tada:
Thanks! Will look. Btw do you like way I'm using template strings in my pg-async library?
It depends, how much do you support? :wink: I didnāt see any documentation when I looked quickly.
I really donāt like SQLBuilder (it was the best I could do at the timeā¦), so Iām going to talk more about the PostGraphQL 2 SQL builder.
Some requirements for a SQL builder used by PostGraphQL is:
"forum_example"."person"."id" can be added as so sql.query${sql.identifier('forum_example', 'person', 'id')} = 1``.column = ${sql.value(1)} or column = ${sql.placeholder('num')} and then inject a value for num later. In both cases though we still need to use PostgreSQL placeholders with auto-incrementing ānamesā ($1, $2, $3, etc).The implementation I landed on is also pretty fast. At the end of the days itās just some string concatenation. Under the hood everything is an object though, it takes the strings and turns it into an array, so a query like:
sql.query`where ${sql.identifier('a', 'b', 'c')} = ${sql.value(value)}`
Turns into:
[{ type: 'RAW', text: 'where ' }, { type: 'IDENTIFIER', names: ['a', 'b', 'c'] }, { type: 'RAW', text: ' = ' }, { type: 'VALUE', value: value }]
I really like the API/implementation I ended up with, but Iām always open to new ideas :blush:
After some more research, I remembered that there is no idea of ānullā for inputs in GraphQL. See this issue https://github.com/graphql/graphql-js/issues/133 and this RFC pull request https://github.com/facebook/graphql/pull/83
For now if you want to continue with your proposal (imageFeaturedSetNull etc) go for it, just know it will probably be deprecated when we get support for the null literal in GraphQL :+1:
Another option is we could add a removedColumns array, but I like the idea of imageFeaturedSetNull better more personally.
Hi. I just finished new PR https://github.com/graphql/graphql-js/pull/544 extending GraphQL with null literal in GraphQL language itself so RFC will be fulfilled soon I hope :-)
But it looks that null values are supported already in graphql-js@master.
What is state of this issue? Are explicit nulls still unhandled?
Iāve been watching the progress, great job :blush:
Iāll have to check and see if null values are supported, but Iāll definitely make sure everything works as expected when https://github.com/graphql/graphql-js/pull/544 lands :+1:
Looks like https://github.com/graphql/graphql-js/pull/544 just got merged!
:tada: now just waiting for it to get released in 0.8.0 then Iāll test to make sure everything works as expected.
@calebmer what is the status of this?
@ferdinandsalis I can confirm this works, just make sure you have a version of GraphQL above 0.8.0 :+1:
Submit a PR to add tests and prevent regression, once that gets merged we can close this issue: https://github.com/calebmer/postgraphql/pull/255
Most helpful comment
This definitely looks like a bug. I'll investigate š