Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-09

TMemoField saving empty strings as '' (double quote)

19 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

I'm trying to save an empty string in a TMemoField, but it always saves a double quote ('') instead.

Attached a small example to reproduce the error.

My environment:

PostgreSQL 8.4;
Lazarus 1.0.10 r41613 FPC 2.6.2 i386-win32-win32/win64 (Windows 8 - 64bit);

Thank you!

Silvio Clécio My public projects - github.com/silvioprog
Reinier Olislagers
to silvioprog
silvioprog wrote
I'm trying to save an empty string in a TMemoField, but it always saves a double quote ('') instead. Attached a small example to reproduce the error.

It seems you're trying to clear the field (which IMO should give NULL). Shouldn't you use .AsString to assign an empty string value to it?

Show quoted text 5 lines
My environment: PostgreSQL 8.4; Lazarus 1.0.10 r41613 FPC 2.6.2 i386-win32-win32/win64 (Windows 8 - 64bit);
LacaK

Hi Silvio,
I cann't reproduce your error in 2.7.1 (trunk)
Fix in rev.25411 closes also problem you mentioned. (but before this rev. problem existed)
But now I get another error, which says that there is "no insert query specified" because all fields in posted row are empty (null) (which is okay from point of application view, but this situation is not handled when ApplyingUpdates)
-Laco.

Show quoted text 24 lines
Hello, I'm trying to save an empty string in a TMemoField, but it always saves a double quote ('') instead. Attached a small example to reproduce the error. My environment: PostgreSQL 8.4; Lazarus 1.0.10 r41613 FPC 2.6.2 i386-win32-win32/win64 (Windows 8 - 64bit); Thank you! -- Silvio Clécio My public projects - github.com/silvioprog <http://github.com/silvioprog> ------------------------------------------------------------------------ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
silvioprog
to Reinier Olislagers: It seems you're trying to clear the field (which IMO should give NULL). Shouldn't you use…

2013/9/10 Reinier Olislagers

Show quoted text 7 lines
On 09/09/2013 22:27, silvioprog wrote: > I'm trying to save an empty string in a TMemoField, but it always saves > a double quote ('') instead. > > Attached a small example to reproduce the error. It seems you're trying to clear the field (which IMO should give NULL). Shouldn't you use .AsString to assign an empty string value to it?

Even passing AsString = '' it saves a double quote in database.

Silvio Clécio My public projects - github.com/silvioprog
silvioprog
to LacaK: I cann't reproduce your error in 2.7.1 (trunk) Fix in rev.25411 closes also problem you…

2013/9/10 LacaK

Show quoted text 11 lines
** Hi Silvio, I cann't reproduce your error in 2.7.1 (trunk) Fix in rev.25411 closes also problem you mentioned. (but before this rev. problem existed) But now I get another error, which says that there is "no insert query specified" because all fields in posted row are empty (null) (which is okay from point of application view, but this situation is not handled when ApplyingUpdates) -Laco.

Is there any place where I can download a FPC stable with this fix? I don't feel comfortable using a unstable FPC to compile a project to use in production.

Silvio Clécio My public projects - github.com/silvioprog
Sven Barth
to silvioprog
silvioprog wrote 16 lines
2013/9/10 LacaK < > Hi Silvio, I cann't reproduce your error in 2.7.1 (trunk) Fix in rev.25411 closes also problem you mentioned. (but before this rev. problem existed) But now I get another error, which says that there is "no insert query specified" because all fields in posted row are empty (null) (which is okay from point of application view, but this situation is not handled when ApplyingUpdates) -Laco. Is there any place where I can download a FPC stable with this fix? I don't feel comfortable using a unstable FPC to compile a project to use in production.

There is no stable, because there is currently no release of 2.8 planned. Maybe it will merged to 2.6.3 then you could get it once 2.6.4 is released.

You should nevertheless test using a development version snapshot whether this fix does indeed fix your problem though.

Regards,
Sven

silvioprog
to Sven Barth

2013/9/10 Sven Barth

Show quoted text 22 lines
Am 10.09.2013 13:47, schrieb silvioprog: 2013/9/10 LacaK > Hi Silvio, > I cann't reproduce your error in 2.7.1 (trunk) > Fix in rev.25411 closes also problem you mentioned. (but before this rev. > problem existed) > But now I get another error, which says that there is "no insert query > specified" because all fields in posted row are empty (null) > (which is okay from point of application view, but this situation is not > handled when ApplyingUpdates) > -Laco. > Is there any place where I can download a FPC stable with this fix? I don't feel comfortable using a unstable FPC to compile a project to use in production. There is no stable, because there is currently no release of 2.8 planned. Maybe it will merged to 2.6.3 then you could get it once 2.6.4 is released.

Hm... Now I really don't know what to do. :/

Show quoted text 6 lines
You should nevertheless test using a development version snapshot whether this fix does indeed fix your problem though. Regards, Sven

I downloaded a snapshot now. I'll test it and send the result here ...

Silvio Clécio My public projects - github.com/silvioprog
silvioprog
to silvioprog

2013/9/10 silvioprog

Show quoted text 37 lines
2013/9/10 Sven Barth > Am 10.09.2013 13:47, schrieb silvioprog: > > 2013/9/10 LacaK > >> Hi Silvio, >> I cann't reproduce your error in 2.7.1 (trunk) >> Fix in rev.25411 closes also problem you mentioned. (but before this >> rev. problem existed) >> But now I get another error, which says that there is "no insert query >> specified" because all fields in posted row are empty (null) >> (which is okay from point of application view, but this situation is not >> handled when ApplyingUpdates) >> -Laco. >> > > Is there any place where I can download a FPC stable with this fix? I > don't feel comfortable using a unstable FPC to compile a project to use in > production. > > There is no stable, because there is currently no release of 2.8 planned. > Maybe it will merged to 2.6.3 then you could get it once 2.6.4 is released. > Hm... Now I really don't know what to do. :/ > You should nevertheless test using a development version snapshot > whether this fix does indeed fix your problem though. > > Regards, > Sven > I downloaded a snapshot now. I'll test it and send the result here ...

Same problem in FPC 2.7.1 (my environment: Lazarus 1.1 r42538 FPC 2.7.1 i386-win32-win32/win64).

The pgAdmin screenshot:

http://imagebin.org/270446

Silvio Clécio My public projects - github.com/silvioprog
Sven Barth
to silvioprog
silvioprog wrote 42 lines
2013/9/10 silvioprog < > 2013/9/10 Sven Barth < > Am 10.09.2013 13:47, schrieb silvioprog: > 2013/9/10 LacaK < > > > Hi Silvio, > I cann't reproduce your error in 2.7.1 (trunk) > Fix in rev.25411 closes also problem you mentioned. (but > before this rev. problem existed) > But now I get another error, which says that there is "no > insert query specified" because all fields in posted row > are empty (null) > (which is okay from point of application view, but this > situation is not handled when ApplyingUpdates) > -Laco. > > > Is there any place where I can download a FPC stable with > this fix? I don't feel comfortable using a unstable FPC to > compile a project to use in production. There is no stable, because there is currently no release of 2.8 planned. Maybe it will merged to 2.6.3 then you could get it once 2.6.4 is released. Hm... Now I really don't know what to do. :/ You should nevertheless test using a development version snapshot whether this fix does indeed fix your problem though. Regards, Sven I downloaded a snapshot now. I'll test it and send the result here ... Same problem in FPC 2.7.1 (my environment: Lazarus 1.1 r42538 FPC 2.7.1 i386-win32-win32/win64).

So it seems to be a different problem anyway...

Regards,
Sven

LacaK
to silvioprog: 2013/9/10 silvioprog Same problem in FPC 2.7.1 (my environment: Lazarus 1.1 r42538 FPC…

silvioprog wrote / napísal(a):

Show quoted text 48 lines
2013/9/10 silvioprog < > 2013/9/10 Sven Barth < > Am 10.09.2013 13:47, schrieb silvioprog: > 2013/9/10 LacaK < > > > Hi Silvio, > I cann't reproduce your error in 2.7.1 (trunk) > Fix in rev.25411 closes also problem you mentioned. (but > before this rev. problem existed) > But now I get another error, which says that there is "no > insert query specified" because all fields in posted row > are empty (null) > (which is okay from point of application view, but this > situation is not handled when ApplyingUpdates) > -Laco. > > > Is there any place where I can download a FPC stable with > this fix? I don't feel comfortable using a unstable FPC to > compile a project to use in production. There is no stable, because there is currently no release of 2.8 planned. Maybe it will merged to 2.6.3 then you could get it once 2.6.4 is released. Hm... Now I really don't know what to do. :/ You should nevertheless test using a development version snapshot whether this fix does indeed fix your problem though. Regards, Sven I downloaded a snapshot now. I'll test it and send the result here ... Same problem in FPC 2.7.1 (my environment: Lazarus 1.1 r42538 FPC 2.7.1 i386-win32-win32/win64). The pgAdmin screenshot: http://imagebin.org/270446

Strange ;-)
Can you please attach and send your bufdataset.pas ? -Laco.

LacaK
to silvioprog: 2013/9/10 silvioprog Same problem in FPC 2.7.1 (my environment: Lazarus 1.1 r42538 FPC…

silvioprog wrote / napísal(a):

Show quoted text 48 lines
2013/9/10 silvioprog < > 2013/9/10 Sven Barth < > Am 10.09.2013 13:47, schrieb silvioprog: > 2013/9/10 LacaK < > > > Hi Silvio, > I cann't reproduce your error in 2.7.1 (trunk) > Fix in rev.25411 closes also problem you mentioned. (but > before this rev. problem existed) > But now I get another error, which says that there is "no > insert query specified" because all fields in posted row > are empty (null) > (which is okay from point of application view, but this > situation is not handled when ApplyingUpdates) > -Laco. > > > Is there any place where I can download a FPC stable with > this fix? I don't feel comfortable using a unstable FPC to > compile a project to use in production. There is no stable, because there is currently no release of 2.8 planned. Maybe it will merged to 2.6.3 then you could get it once 2.6.4 is released. Hm... Now I really don't know what to do. :/ You should nevertheless test using a development version snapshot whether this fix does indeed fix your problem though. Regards, Sven I downloaded a snapshot now. I'll test it and send the result here ... Same problem in FPC 2.7.1 (my environment: Lazarus 1.1 r42538 FPC 2.7.1 i386-win32-win32/win64). The pgAdmin screenshot: http://imagebin.org/270446

Now doing more tests. I see, that in pgAdmin when I use right click on table and use "View Data" then '' (two single quotes) are shown in TEXT column, but when I use SQL and type:
select * from <table name> then empty fields are shown ... so it seems to me, that bug is in pgAdmin, does not ?
-Laco.

silvioprog
to LacaK: silvioprog wrote / napísal(a): Now doing more tests. I see, that in pgAdmin when I use…

2013/9/11 LacaK

Show quoted text 8 lines
** silvioprog wrote / napísal(a): Now doing more tests. I see, that in pgAdmin when I use right click on table and use "View Data" then '' (two single quotes) are shown in TEXT column, but when I use SQL and type: select * from <table name> then empty fields are shown ... so it seems to me, that bug is in pgAdmin, does not ? -Laco.

The bug is in FCL. Please see the steps in my comparison:

1. first I inserted a record via pgAdmin: insert into test (id, fieldtext)
values (1, null);
2. after, I executed this demo: http://pastebin.com/HS8DZkDV;
3. finally, I made this selection in pgAdmin:
  select * from test
  where fieldtext is null;

And the result is:

id | fieldtext
-----------------
1 |

But, when I select so:

select * from test
where fieldtext = ''

The result is:

id | fieldtext
-----------------
2 |

Then SQLdb is saving an empty string instead of null. :o

I tried it:

q.FieldByName('fieldtext').Value := Null;

Instead of:

q.FieldByName('fieldtext').Clear;

Same result, it is saving an empty string instead of null.

Silvio Clécio My public projects - github.com/silvioprog
LacaK
to silvioprog: 2013/9/11 LacaK The bug is in FCL. Please see the steps in my comparison: 1. first I…

silvioprog wrote / napísal(a):

Show quoted text 15 lines
2013/9/11 LacaK < > silvioprog wrote / napísal(a): Now doing more tests. I see, that in pgAdmin when I use right click on table and use "View Data" then '' (two single quotes) are shown in TEXT column, but when I use SQL and type: select * from <table name> then empty fields are shown ... so it seems to me, that bug is in pgAdmin, does not ? -Laco. The bug is in FCL. Please see the steps in my comparison: 1. first I inserted a record via pgAdmin: insert into test (id, fieldtext) values (1, null);

Try in pgAdmin do:
insert into test (id, fieldtext) values (1, '');
Then use "View Data" and you will see two single quotes instead of empty cell.

Show quoted text 24 lines
2. after, I executed this demo: http://pastebin.com/HS8DZkDV; 3. finally, I made this selection in pgAdmin: select * from test where fieldtext is null; And the result is: id | fieldtext ----------------- 1 | But, when I select so: select * from test where fieldtext = '' The result is: id | fieldtext ----------------- 2 | Then SQLdb is saving an empty string instead of null. :o

Yes it is true for your version of bufdataset.pas, but it is fixed in trunk.

L.

silvioprog
to LacaK

2013/9/11 LacaK

Show quoted text 5 lines
Yes it is true for your version of bufdataset.pas, but it is fixed in trunk. L.

I'm searching a FTP with an update FPC to test it again. I'm using it:

ftp://freepascal.dfmk.hu/pub/lazarus/snapshots

But the latest FPC in this FTP is of 2013-09-01.

Silvio Clécio My public projects - github.com/silvioprog
silvioprog
to silvioprog

2013/9/11 silvioprog

Show quoted text 14 lines
2013/9/11 LacaK > Yes it is true for your version of bufdataset.pas, but it is fixed in > trunk. > > L. > I'm searching a FTP with an update FPC to test it again. I'm using it: ftp://freepascal.dfmk.hu/pub/lazarus/snapshots But the latest FPC in this FTP is of 2013-09-01.

Tested on Linux and worked fine.

Thank you very much friends! (y)

Silvio Clécio My public projects - github.com/silvioprog
Unknown author
LacaK wrote
Now doing more tests. I see, that in pgAdmin when I use right click ontable and use "View Data" then '' (two single quotes) are shown in TEXTcolumn, but when I use SQL and type: select * from <table name> then empty fields are shown ... so itseems to me, that bug is in pgAdmin, does not ?

maybe not a bug... i regularly display strings with quotes around them... especially if they are empty... that way i can actually see that they are empty...

silvioprog
to Unknown author

2013/9/11

Show quoted text 12 lines
On Wednesday, September 11, 2013 5:56 AM, LacaK wrote: >Now doing more tests. I see, that in pgAdmin when I use right click on table and use "View Data" then '' (two single quotes) are shown in TEXT column, but when I use SQL and type: > select * from <table name> then empty fields are shown ... so it seems to me, that bug is in pgAdmin, does not ? maybe not a bug... i regularly display strings with quotes around them... especially if they are empty... that way i can actually see that they are empty...

Seems better if pgAdmin use <EMPTY> instead of '', because the user can use double quote.

Silvio Clécio My public projects - github.com/silvioprog