Page 1 of 1

Escape string

PostPosted: Sun Mar 13, 2011 11:23 pm
by ruddy32
Hi,
Is necessary to escape '\' character before insert or update data using trigger? Does Qt or QxOrm do it automatically? Is it necessary to use special classes?
Thanks

Re: Escape string

PostPosted: Mon Mar 14, 2011 8:22 am
by QxOrm admin
Hi,

You don't have to escape any character (using trigger or not using trigger).
What is exactly your problem ? Can you give a sample of code please ?

Re: Escape string

PostPosted: Mon Mar 14, 2011 9:00 am
by ruddy32
I'm saving a regular expression using a QString object, and I get the following message:
Code: Select all
HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.

Re: Escape string

PostPosted: Mon Mar 14, 2011 9:11 am
by ruddy32
I setup the object using this code :
Code: Select all
namespace qx {

template<>
void register_class(QxClass<sdbs::ifs::MyObjEntity> & t) {
   IxDataMember * pData = NULL;

   t.setName("myobj");
   pData = t.id(&sdbs::ifs::MyObjEntity::m_id, "myobj_id", 1);
   pData->setAutoIncrement(false);
   pData = t.data(&sdbs::ifs::MyObjEntity::m_status, "myobj_status", 1);
   pData = t.data(&sdbs::ifs::MyObjEntity::m_content,  "myobj_content", 1);
}
}

The "myobj_content" column is a regular expression and sometimes it's content include '\' character.

Re: Escape string

PostPosted: Mon Mar 14, 2011 10:41 am
by QxOrm admin
What is your database type : Postgres, MySql, SQLite, other ?
What is your column type in the database to map the property 'sdbs::ifs::MyObjEntity::m_content' ?

I think this is a specific case with your database or your column definition.
First, you can try to modify your column definition in the database : try the BLOB type if exists (???) or other...

Re: Escape string

PostPosted: Mon Mar 14, 2011 12:07 pm
by ruddy32
I'm using postgres 8.4. The current field type is 'text'. Would it be better to use a 'bytea' ?

Re: Escape string

PostPosted: Mon Mar 14, 2011 1:21 pm
by QxOrm admin
It seems this is a warning from postgres database (you can search it on google) :
http://dbaspot.com/forums/postgresql/25 ... acter.html

Here a solution from the website below :

* Edit postgresql.conf
* Set :
standard_conforming_strings = on
and restart the server.

Or you can also set (but it seems this is not recommended) :
escape_string_warning = off