find/search removes leading whitespace

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

find/search removes leading whitespace

Postby Zuke » Wed Feb 29, 2012 5:58 pm

Hi All

When performing a find/search, on fields with data that has leading whitespace, Servoy seems to be trimming the whitespace which is resulting in 0 records found which is incorrect as we know the records are present in the db.

For example

Code: Select all
foundset.find()
foundset.fc_main1 = '  BAA-3"-FHS-0460093-B8'
foundset.search()


Running this code gives me a foundset size of 0 records which is wrong.

To check what was going on I grabbed the sql params from databaseManager.getSqlParameters() and got the following

Code: Select all
[BAA-3"-FHS-0460093-B8]


So its missing the leading whitespace.

Is this correct behaviour or am I missing something?
McCourt Cordingley (Zuke)
(Version: 6.0.6 - Windows 7 - SQL Server 2008 R2 - Backbox Linux)
Zuke
 
Posts: 153
Joined: Wed Jun 03, 2009 4:48 pm
Location: Newcastle Upon Tyne, UK

Re: find/search removes leading whitespace

Postby Kahuna » Thu Mar 01, 2012 12:41 pm

Any feedback on this - looks like over enthusiastic 'trimming' by Servoy in the find?

Can find actually work with spaces?

Ian
(Servoy Version: 6.0.7 Win XP / 7 - SQL Server 2008 R2)
Ian Cordingley (Kahuna)
Kahuna
 
Posts: 1235
Joined: Thu Oct 26, 2006 1:39 am
Location: 1/2 NE UK 1/2 Olvera Spain

Re: find/search removes leading whitespace

Postby westly » Fri Mar 02, 2012 12:46 am

Can you do something like:

Code: Select all
var cString = String.fromCharCode(32)
foundset.find()
foundset.fc_main1 = cString + 'BAA-3"-FHS-0460093-B8'
foundset.search()
Version: 6.0.5 - build 1230
westly
 
Posts: 15
Joined: Thu Feb 02, 2012 6:06 pm

Re: find/search removes leading whitespace

Postby Zuke » Fri Mar 02, 2012 11:27 am

Hi

I was just using the above as an example, in actuality, we are just using a normal find/search, with values populated valuelists.

This was really just an example to see what was actually being searched on when leading whitespace was present in a field.

Regards
McCourt Cordingley (Zuke)
(Version: 6.0.6 - Windows 7 - SQL Server 2008 R2 - Backbox Linux)
Zuke
 
Posts: 153
Joined: Wed Jun 03, 2009 4:48 pm
Location: Newcastle Upon Tyne, UK

Re: find/search removes leading whitespace

Postby Kahuna » Mon Mar 19, 2012 4:40 pm

Has this been resolved - will a fix be in 6.0.6???
(Servoy Version: 6.0.7 Win XP / 7 - SQL Server 2008 R2)
Ian Cordingley (Kahuna)
Kahuna
 
Posts: 1235
Joined: Thu Oct 26, 2006 1:39 am
Location: 1/2 NE UK 1/2 Olvera Spain

Re: find/search removes leading whitespace

Postby Harjo » Mon Mar 19, 2012 4:58 pm

did you filed it as a bug?
Harjo Kompagnie
Direct ICT / Servoy Hosting / ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
User avatar
Harjo
 
Posts: 4277
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: find/search removes leading whitespace

Postby Zuke » Mon Mar 19, 2012 5:04 pm

We have been waiting on feedback to the post Harjo, not sure if it is a bug or not???
McCourt Cordingley (Zuke)
(Version: 6.0.6 - Windows 7 - SQL Server 2008 R2 - Backbox Linux)
Zuke
 
Posts: 153
Joined: Wed Jun 03, 2009 4:48 pm
Location: Newcastle Upon Tyne, UK

Re: find/search removes leading whitespace

Postby ROCLASI » Mon Mar 19, 2012 6:39 pm

Hi McCourt,

I suggest you actually file this in the support system.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5244
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: find/search removes leading whitespace

Postby jd2p » Fri Aug 03, 2012 1:13 am

I filed this in the support system as SVY-2803 since we've have that same issue extensively.
jd2p
 
Posts: 95
Joined: Thu Dec 08, 2011 1:08 am

Re: find/search removes leading whitespace

Postby omar » Fri Aug 03, 2012 11:35 am

See this thread:

https://www.servoy.com/forum/viewtopic.php?f=22&t=18572

Could be the same problem (varchar fields)?

Cheers,
Intrasoft / JBS Group, Partner
Omar van Galen
Servoy Developer
omar
 
Posts: 316
Joined: Sat Feb 12, 2011 4:51 pm
Location: Intrasoft, The Netherlands

Re: find/search removes leading whitespace

Postby rgansevles » Fri Dec 04, 2015 11:38 am

I have added a section in the wiki on using find mode icw spaces and trimming.

https://wiki.servoy.com/display/DOCS/Find+Mode

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1849
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: find/search removes leading whitespace

Postby kwpsd » Thu Dec 10, 2015 2:32 am

@Rob: Thank you for updating the Wiki with a workaround!

Rob did this in response to a bug report I posted: SVY-9194. At the time of the bug report, I was unaware that Servoy trimmed leading spaces from character-based arguments used in the find/search mode, and I wanted to elaborate here for other unsuspecting developers (In case you are wondering, I did not find this problem, my customers did). Here is what Rob said:

Find mode was designed for fields being entered by the user. That is the reason Servoy trims the value, in case a user typed a space by accident.


What this means is that in find/search mode:

Code: Select all
fs.label_text = '     Hello Servoy';


and

Code: Select all
fs.label_text = 'Hello Servoy';


will return the same record(s) which can cause problems when validating arguments with leading spaces.

So, if you did not encapsulate your character-based arguments in a single element arrays as the Wiki now states, you need to read the Wiki and re-evaluate your find/search code.

I hope this helps!
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 591
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA


Return to Programming with Servoy

Who is online

Users browsing this forum: andre1506345542, Bing [Bot] and 2 guests

cron