Skip to content

Error while trying to insert an json array #1016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eriknyk opened this issue May 12, 2016 · 4 comments
Closed

Error while trying to insert an json array #1016

eriknyk opened this issue May 12, 2016 · 4 comments

Comments

@eriknyk
Copy link

eriknyk commented May 12, 2016

Hi, this issue #442 should be reopened, since in postgres shell is possible to execute without problems:

INSERT INTO public.my_table (userId, personId, books) VALUES (1, 1, '[1,2,3]');

however when trying to insert the same array using pg module I'm getting the error:

"error": {
    "cause": {
      "message": "invalid input syntax for type json",
      "code": "22P02",
      "detail": "Expected \":\", but found \",\".",
      "length": 148,
      "severity": "ERROR",
      "where": "JSON data, line 1: {\"1\",...",
      "file": "json.c",
      "line": "1198",
      "routine": "report_parse_error"
    },
    "isOperational": true,
    "code": "22P02",
    "detail": "Expected \":\", but found \",\".",
    "length": 148,
    "severity": "ERROR",
    "where": "JSON data, line 1: {\"1\",...",
    "file": "json.c",
    "line": "1198",
    "routine": "report_parse_error"
  }

Best Regards

@joskuijpers
Copy link
Contributor

Could you give your Table layout so we could try to reproduce this error?

@brianc
Copy link
Owner

brianc commented Jun 21, 2016

This looks like a syntax error with your query & not a bug with node-postgres. Particularly in the case of a plain text query without parameters the query is passed 100% unaltered to the backend server.

@brianc brianc closed this as completed Jun 21, 2016
@dcworldwide
Copy link

dcworldwide commented Jan 14, 2017

@brianc Just to confirm, is what the OP asked supported? I.e. inserting an array (not a object) into a JSON/B column?

I'm having an issue inserting an array into a JSON column with typeorm. It's a library that depends on this library for postgres integration. I want to know if it's a bug in that library, or a limitation of this library. Thanks

typeorm/typeorm#183

@charmander
Copy link
Collaborator

@dcworldwide See #1143.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants