Page 1 of 1

dollar-quoted and json data = error

Posted: Fri 07 Aug 2015 08:55
by dgriessinger
Hi,

I have some trouble with json data and pgquery,
I use the latest version: PgDAC 4.5.17 XE8 under Windows 8.1 pro

Code: Select all

-- Postgresql 9.3
CREATE TABLE t_test(
  idtest serial NOT NULL,
  thedata text,
  thejson json,
  CONSTRAINT t_test_pkey PRIMARY KEY (idtest)
);
Here are my test and results

Code: Select all

  PgQuery1.ParamCheck:=false;

  json:='{"key":"yes","param1":"toto"}';

  // quotedstr
  PgQuery1.SQL.Text:='INSERT INTO t_test(thedata) VALUES ('+quotedstr(json)+');';
  PgQuery1.ExecSQL;   // works: {"key":"yes","param1":"toto"}

  PgQuery1.SQL.Text:='INSERT INTO t_test(thedata) VALUES ('+quotedstr(json)+');';
  PgQuery1.ExecSQL;   // works: {"key":"yes","param1":"toto"}


  // dollar-quoted
  PgQuery1.SQL.Text:='INSERT INTO t_test(thedata) VALUES ($$'+json+'$$);';
  PgQuery1.ExecSQL;   // no exception, but data stored on server are wrong: {"key"$1,"param1"$2}

  PgQuery1.SQL.Text:='INSERT INTO t_test(thejson) VALUES ($$'+json+'$$);';
  PgQuery1.ExecSQL;  // exception, EPGError, invalid entry for json type, normally it's works
Is it possible to fix it ?
Thanks

Re: dollar-quoted and json data = error

Posted: Tue 11 Aug 2015 07:35
by azyk
Thank you for the information. We have reproduced this problem and are investigating it. We will notify you about the results as any are available.

Re: dollar-quoted and json data = error

Posted: Fri 21 Aug 2015 05:01
by azyk
We have fixed this problem. This fix will be included in the next PgDAC build.