dollar-quoted and json data = error

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dgriessinger
Posts: 4
Joined: Wed 25 Jan 2012 15:13

dollar-quoted and json data = error

Post by dgriessinger » Fri 07 Aug 2015 08:55

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

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: dollar-quoted and json data = error

Post by azyk » Tue 11 Aug 2015 07:35

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.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: dollar-quoted and json data = error

Post by azyk » Fri 21 Aug 2015 05:01

We have fixed this problem. This fix will be included in the next PgDAC build.

Post Reply