[Gambas-devel] Empty string sets controls and collections members to null Question

Benoît Minisini gambas at ...1...
Mon Nov 23 12:17:53 CET 2009


> On Monday 23 November 2009 21:49:56 you wrote:
> > > On Thursday 27 August 2009 19:55:01 you wrote:
> > >
> > > I asked this before (text below) and to my recollection (maybe faulty)
> > >  Benoit said that the behaviour causing me problems was normal, however
> > > I really need to find a solution.
> > >
> > > In a nutshell again it is this:
> > >
> > > I use collections to transfer data to-from my database to add/update
> > >  records (don't use the gambas datacontrol).
> > >
> > > If an existing collection has a member containing text eg
> > >
> > > MyCollection!my_value = "a dog", and I'm updating the record, lets say
> > > I've deleted the text in the input field, and the value in the backend
> > > for that field in a table now has to be  an empty sting or null, if I
> > > do this:
> > >
> > > MyCollectioni!my_value = "", effectively removes the 'my_value' key
> > > from the collection, dosn't set its string to null.
> > >
> > > I would have thought that "" = empty string, not null, but I think
> > > Benoit said that this was equivalent in gambas. I can't think how to
> > > get around this and wondered if anyone could think of a solution.
> > >
> > > Regards
> > >
> > > Richard
> >
> > I've never seen any need to make a difference between an empty string and
> > a null string. Why do you make this difference?
> 
> Maybe its because of the way I'm updating data.
> 
> lets say I have this table.
> 
> Create table test
> (pk serial primary key,
>  type text,
>  name text
> );
> 
> I'm using collections of data, so say I have a collection I called animals
> animal!type = "dog"
> animal!name = "blackie"
> 
> I then put data into it and the row ends up say 1,"dog", "blackie"
> 
> I then want to change this and delete the name, but this time I have a
>  primary key, so the collection when retreived prior to the change looks
>  like this: animal("pk") = 1
> animal ("type")="dog"
> animal("name:) ="blackie"
> 
> in the textbox fields, the user removes the name "blackie", so I need to
>  re- save the data, so now
> animal!pk= 1
> animal!type = "dog"
> animal!name = ""
> 
> An hey presto , I've removed animal!name from the collection, whereas I
>  want animal!name = '"" to remain, so that the database field is set to an
>  empty string.
> 
> Now, there may be a different way to do this, for example, if I knew how to
> set animal!name to null, maybe that would work, but as gb.null = 15, it
>  dosn't seem to work.
> 
> Maybe I've confused you?
> 
> Regards
> 
> Richard
> 

I don't see the problem : the Gambas database component makes no difference 
between NULL and an empty string too.

And you should better post on the user mailing-list for that.

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list