hi all, thank you for this channel. when i try to ...
# orm-help
n
hi all, thank you for this channel. when i try to use the
filterJson
preview feature to query where a path is
undefined
, i get
A JSON path cannot be set without a scalar filter.
at runtime, despite the
InputJsonValue
type allowing undefined. the json field is nullable, and has a default set to
{}
in prisma. am i doing something wrong? or is support still limited? thank you. 🙂
r
Hey @Nic Luciano 👋 Could you provide a snippet so that I can check?
n
@Ryan yes thank you! for the record, i lied, the json field is not nullable. https://gist.github.com/kn0ll/9405ba633872ff1b80498029fce833c2 i hope this contains all the information you need
👍 1
it looks like there are other ways
not
does not behave as i'd expect. say i have three states:
{key:true}
{key:false}
{key:undefined} aka {}
{ path: ['key'], not: true }
will return record 2
{ path: ['key'], not: false }
will return record 1 in both cases i'd expect record 3 to be included, as undefined is
not
true or false
finally, i will add that the original error in my gist also happens when i try
{ path: ['key'], equals: undefined }
(so, it's not exclusive to
not
)
r
I don’t think so as you’re checking for
key
but
key
doesn’t exist, so it shouldn’t be included. There should be a way to check for if a path exists
undefined
cannot be used here as
undefined
in TypeScript is equivalent to you omitting the value which is why this will not work. There should be a way of checking if a path exists and then I can get back to you as that suits your use case.
n
yep ok, i mostly follow. yes, checking that the path doesn't exist serves my purpose just fine! 🙂
💯 1
r
Unfortunately we do not have a filter to check if a path exists or not. It would be great if you could open one here so that we can look into this 🙂
n
wait, you mean you didn't just make it this morning...? jk, happy to, thank you for your help!
💯 1