It seems that when a text field with a format string of something like U*********, when saved the text is padded on the right with spaces to the length of the format string. To find these fields in find mode, it requires an ‘%’ to be used, which of course will include data that doesn’t match exactly. This doesn’t seem appropriate. If the user types “Jones” into a lastname search field, they expect to find all the “Jones” matches, they don’t care about the spaces.
Our problem is we store the format strings in metadata and allow our clients to change them. So if they have a field with no format, then add a format later, only the earlier data will be found without the ‘%’, looking like they are missing data. Is padding the field the intended behavior? Is there a format string that will force the first character to uppercase without padding? We are using version 5.0.1 and Sybase 11, and the fields in question are of character type.
Because I want the user to be able to change this themselves. Perhaps some want only all uppercase, or maybe they only want to allow a certain number of characters to be entered. We do this by changing the format property of the field when showing the form, based on metadata. We do this for all fields throughout the application. To hard code the formatting would be inflexible.
I was talking of a filtering script triggered after data is altered and which re-calcs the string according to your specs.
Display format does not alter real data as you know.
problem with this format: U*********
that it is a mask, and a mask is something that it expects to exactly be that.
so the above tells me that the first char should be uppercase and then you have to have 9 chars that can be anything.
The above format also dont allow you to type a name longer then 10 chars…
what happens if you had something like this:
U
what do you expect then what the text should be if the user starts with one or 2 spaces then a char and then another 1 or 2 spaces??
Should we just trim on both sides?
not for me. though trimming is wanted most of the time. I would say using a special character to mean “trim” in the mask could be an idea, or a flag on this field (auto-trim?). you can’t make it standard as there will always be a situation where a trailing space is needed.
if you set a mask + cleaning method triggered by data change, which one is executed first?
OK, this is not really a data issue or even a Servoy issue. As it turns out, the default when creating a Sybase database sets “ignore trailing blanks” OFF. I don’t believe this is the ANSI standard implementation. You can set it “ON”, in which case the “=” operator in the where clause ignores trailing spaces, but you can only set this when you create the database. I created a new database with it set ON, and unloaded the old one into it. Now, find works as expected. I just hope this does not cause other problems to arise.