Postgres text field returns wrong data

I am having an interesting problem. I have a Postgres database with a
table containing a text field. In the text field is stored data that in
some cases has a ‘*’ and a newline return as the first line first few
characters followed by several other lines.

The strange part is when a record is written the data looks correct,
however, when the record is read all line feed and carriage returns are
stripped in the response data.

I am using the GEM postgres-pr driver 0.4.0 on rails 2.0.2

Is there any reason this would occur? If I have other records without
the ‘*’ as described above the data read is correct (all new lines and
returns remain).

Sample Text data written as a string, when read no line feeds or
carriage returns:
*

  • THIS JOB SEND A FILE

[ADMIN]
VERSION = 1
DESC = job 1
USERID = admin

Any help is appreciated. I wouldn’t mind digging through the driver to
debug this issue, however I’m not sure where to start. Any guidance or
comments are appreciated.

Rick

Rick F. wrote:

I am having an interesting problem. I have a Postgres database with a
table containing a text field. In the text field is stored data that in
some cases has a ‘*’ and a newline return as the first line first few
characters followed by several other lines.

The strange part is when a record is written the data looks correct,
however, when the record is read all line feed and carriage returns are
stripped in the response data.

I am using the GEM postgres-pr driver 0.4.0 on rails 2.0.2

Just to isolate the problem, could you try using the binary postgres
driver? If you’re on Windows you could try using a precompiled driver
from http://www.vandomburg.net.


Roderick van Domburg

Hi Roderick,

I will do what you suggest when I get a moment. Here is what I have
found so far:

In the ActiveRecord-2.0.2 gem file ‘base.rb’ the ‘find_every(options)’
method returns the data (records) correctly formatted (all the new lines
in tact). Somewhere after this call the data as described above is
stripped of the line feeds and carriage returns due to the ‘*’.

I am adding in some tracing so I can determine the code flow and isolate
where the sanitizing or whatever takes place.

Thanks for you response, I’ll let you know regarding the binary driver.

Thanks,
Rick