On Wed, Jun 05, 2013 at 08:54:20AM +0200, Thomas Siemion <d...@affective.de> 
wrote:
> Hey folks,
> 
> I was wondering why the sqlrepr from converters.py is escaping 
> linebreaks and other chars for postgres.
> 
> I'm talking about this piece of code:
> 
> sqlStringReplace = [
>      ("'", "''"),
>      ('\\', '\\\\'),
>      ('\000', '\\0'),
>      ('\b', '\\b'),
>      ('\n', '\\n'),
>      ('\r', '\\r'),
>     ('\t', '\\t'),
> ]
> 
> This causes for e.g. \ to multiply. when I comment out everything but 
> the escaping of the single quote everything works as aspected. I don't 
> see the reason why this is done in the first place.
> 
> Could anyone please explain this to me and why this is done when saving 

   See
http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS

   "PostgreSQL also accepts "escape" string constants, which are an
extension to the SQL standard. An escape string constant is specified by
writing the letter E (upper or lower case) just before the opening
single quote, e.g., E'foo'. (When continuing an escape string constant
across lines, write E only before the first opening quote.) Within an
escape string, a backslash character (\) begins a C-like backslash
escape sequence, in which the combination of backslash and following
character(s) represent a special byte value, as shown in Table 4-1."

   Also see https://dev.mysql.com/doc/refman/5.0/en/string-literals.html

> but not undone when loaing?

   Because there is no need to "undone" anything. The backend doesn't
store escaped values -- it stores normal values that it sends back on
SELECTing.

> Regards
> Thomas

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            p...@phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to