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

Ron_1st ronstk at ...124...
Tue Nov 24 20:37:49 CET 2009


On Tuesday 24 November 2009, Benoît Minisini wrote:
> > On Tuesday 24 November 2009 17:51:12 Ron_1st wrote:
> > > On Monday 23 November 2009, Benoît Minisini wrote:
> > > > > 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.
> > >
> > > The problem is not the database but the collection object.
> > > He is using a collection where the index name is the field name in the
> > >  database. Setting the his_collection(db_field') = "" removes the item
> > > from the collection instead of having his_collection('db_field') = ""
> > >
> > > This is what I understand here.
> > 
> > ah, at last someone who understands the problem, ?any solution?
> > 
> > Regards
> > 
> > Richard
> > 
> 
> I don't see any problem at all.
> 
> MyCollection!my_value = "" will remove the my_value from the collection. So 
> MyCollection!my_value will return NULL (which is the same thing as ""), and so 
> you can store it into the database record without special code.
> 
> Again: why do you want/need to make a difference between NULL and ""?
> 

It's not the question the are equal or not.
Its looks to be the problem the object in the collection is distroyed.
Again, that is how I understand Richards problem !!!.

Sometimes it can be nice to remove empty but it's logical IMHO.

Suppose a street with house. Let us remove Benou from the fifth house 
numbered as 'Vila Minisini'. How do you feel your when house is destructed
and you comming back to reenter your live.
You can say add a new house 'Vila Minisini' but it is not between your old
neighbours you did like so much.

Its now destructing your wel designed structure of the collection. :)


from me previous answer to Richard
> He is using a collection where the *_INDEX_* name is the *_FIELD_* name in the database.
> Setting the MyCollection!my_value = "" removes the item 
> from the collection instead of having MyCollection!my_value = ""

So if he set MyCollection!my_value = "" and it is removed then how 
do you change the database if the field name is unknown.

A street with 10 houses hat 10 houses, with people living in or not.
Houses.remove('Vila Minisini') is used to demolish the house.


Best regards,

Ron_1st

-- 





More information about the Devel mailing list