Open
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
When using equalTo
on an Array of Strings with a PostgreSQL DB, an error gets thrown.
Might be related to #6403
Seems to be an encoding issue for Postegres queries.
Steps to reproduce
- Set up Parse with PostgreSQL
- Add a new Class with an
Array
Field and add strings (it's stored asjsonb
on the db) - Try to access it via
equalTo
Using parse/node
"use strict";
const Parse = require("parse/node");
Parse.initialize("appId");
Parse.serverURL = "http://localhost:1337/parse/";
Parse.Config.get()
.then((config) => {
console.debug(`Parse API Connection established.`);
})
.catch(console.error)
.then(() => new Parse.Query("testClass"))
.then((qry) => qry.get("bPWn1BIwN3"))
.then((res) => console.log("actual data:", res.get("stringArray")))
.then(() => new Parse.Query("testClass"))
.then((qry) => {
qry.equalTo("stringArray", "stringOne");
return qry.find();
})
.then(() => console.log("will not be triggered"))
.catch((err) => console.error("we fail with:", err));
$ npm run start
> [email protected] start
> node ./index.js
Parse API Connection established.
actual data: [ 'stringOne', 'stringTwo' ]
we fail with: [ParseError: [object Object]
at handleError (/home/bastian/datenhalde/pgTest/node_modules/parse/lib/node/RESTController.js:426:17)
at processTicksAndRejections (node:internal/process/task_queues:94:5)] {
code: 1
}
on the Parse Dashboard:
const qry = new Parse.Query("test")
qry.equalTo("stringArray", "stringOne");
console.log(await qry.find());
Output:
{
"message": {
"length": 165,
"name": "error",
"severity": "ERROR",
"code": "22P02",
"detail": "Token \"stringOne\" is invalid.",
"position": "44",
"where": "JSON data, line 1: stringOne",
"file": "jsonfuncs.c",
"line": "617",
"routine": "json_ereport_error"
},
"name": "Error",
"stack": "s@http://0.0.0.0:4040/bundles/dashboard.bundle.js:75:630545\nt@http://0.0.0.0:4040/bundles/dashboard.bundle.js:75:624686\nd</n<@http://0.0.0.0:4040/bundles/dashboard.bundle.js:16:97361\nr@http://0.0.0.0:4040/bundles/dashboard.bundle.js:16:97493\nhandleError@http://0.0.0.0:4040/bundles/dashboard.bundle.js:75:674336\n"
}
using
Server
- Parse Server version:
4.5.0
- Operating system:
5.10.23-1-MANJARO (localhost)
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
localhost
Database
- System (MongoDB or Postgres):
Postgres
- Database version:
13
- Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
localhost
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
parse/node / parse dashboard
- SDK version:
3.1 / 2.1.0
Logs
Parse Server Logs:
verbose: REQUEST for [GET] /parse/classes/test: {
"where": {
"stringArray": "stringOne"
}
} {"method":"GET","url":"/parse/classes/test","headers":{"user-agent":"node-XMLHttpRequest, Parse/js3.1.0 (NodeJS 15.11.0)","accept":"*/*","content-type":"text/plain","host":"localhost:1337","content-length":"197","connection":"close"},"body":{"where":{"stringArray":"stringOne"}}}
error: Parse error: error: invalid input syntax for type json {"code":1,"stack":"Error: error: invalid input syntax for type json\n at /path/to/local/parse/node_modules/parse-server/lib/Controllers/DatabaseController.js:1170:21\n at processTicksAndRejections (node:internal/process/task_queues:94:5)"}