dollar-quoted and json data = error
Posted: 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
Here are my test and results
Is it possible to fix it ?
Thanks
			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)
);
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
Thanks