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

Ron_1st ronstk at ...124...
Tue Nov 24 18:21:49 CET 2009


On Tuesday 24 November 2009, richard terry 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 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
> > 
> > ----8<----
> > 
> > > 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,
> > 
> > Best regards,
> > 
> > Ron_1st
> > 

IMHO its a bug to remove the collection object if the value is
set to null or empty string as ""
Why do we have the .add and .remove?

For now you could store a leading or trailing space and this
result in at least one space for the value.
Also a predefinied dummy value as i.e. "@@@@" for empty entries
and if with .Replace('@@@@','') clean for the form display.



Best regards,

Ron_1st

-- 

111.111111 x 111.111111 = 12345.678987654321

-- 
 A: Delete the text you reply on.
 Q: What to do to get my post on top?
---
 A: Because it messes up the order in which people normally read text. 
 Q: Why is top-posting such a bad thing? 
---
 A: Top-posting. 
 Q: What is the most annoying thing in e-mail? 
 




More information about the Devel mailing list