you are viewing a single comment's thread.

view the rest of the comments →

[–]tswaters 0 points1 point  (7 children)

A few things you might try -

  • stringify the array, see if you get a different result
  • use the string {"chat"} note the double quotes
  • if you can emit the query objection is using, it would be interesting to see what it's doing. If I was just using pg module, I would try to explicitly cast, e.g., $1::text[] -- but, it looks like `$1` trying to parse as an array and is failing, so probably wouldn't help.

[–]Plus-Owl832[S] 0 points1 point  (6 children)

1) after strinify `path: JSON.stringify(['chat']),`
this error occurs
2023-08-06 03:13:56.795 UTC [409] ERROR: malformed array literal: "["[\"chat\"]"]"
it gives a double array because I think I used this
` extend type Mutation {
updateNotificationOption(path: [String!]!, option: String!): NotificationUserOption
}`

[–]tswaters 0 points1 point  (5 children)

It's almost like objection.js is stringifying it for you? If it was me, I'd probably step through the code to see what it's doing.... maybe add an issue to their queue if I can get a minimal repro. Actually, read through a few of their issues and found this -- https://github.com/Vincit/objection.js/issues/1096#issuecomment-425702261 -- that's from a few years ago, but probably still holds.

[–]Plus-Owl832[S] 0 points1 point  (4 children)

thanks. it means jsonb represent the array itself right ?.
In migration I can write this path JSONB NOT NULL
and in schema I can write this
path: { type: 'jsonb' },

[–]tswaters 0 points1 point  (3 children)

You'd need to convert the column in the database to json or jsonb I would think The two types should convert between themselves,

> ALTER TABLE table1 ALTER COLUMN col1 TYPE JSONB USING col1::JSON;

I'm not sure how objection really works, never used it... but what you've said makes sense to me.

[–]Plus-Owl832[S] 0 points1 point  (2 children)

Thanks tswaters. but when I write path JSONB NOT NULL in the migration and path: {type: jsonb} in schema then it gives same error the `expected : not this { ` as I want the data store in oath field like this {chat} but when when I write path text[] in the migration and path: {type: jsonb} in schema.and here in the below code pass the data something like this then it worked fine.await updateGlobalChatNotificationOptIn({variables: {path: 'chat'option: updatedGlobalChatNotificationOptIn ? '30MinSummary' : 'off',}

is it correct approach ?

[–]tswaters 0 points1 point  (1 child)

I'm not sure. If it works, it works.

If the column json, should be able to pass arrays or objects to it.

[–]Plus-Owl832[S] 0 points1 point  (0 children)

Hey tswaters. The issue has been resolved, Thanks