Page 1 of 1
How to Disable inbult Sort?
Posted: 12.02.2017, 16:25
by ToodleDoo
Hi, I have just found that the Sort for my SQLite database ignores leading non-alpha characters. I tried setting "SortType" to "stIgnored" but it is not Ignored.
Is there some way to totally disable the Sort interference? Or am I missing an option somewhere? The SortType seems to get reinstated as soon as an IndexFieldName is set. I added 1-preceding blank to Zee thinking it would always move to the top as it did in my Delphi version NOT using ZEOS. Other characters are also ignored like "_" etc. As soon as I set the IndexFieldNames to "Name" it uses the Sort again instead of the Delphi-like IndexFieldNames behaviour where leading spaces are acknowledged.
Is it me or???
Code: Select all
// I DO want the subsequent Names to be Aplha-Sorted - Before sorting...
' Zee' <-- I want "Zee" to always be the first item
'Chuck'
'Billy'
// If I set "IndexFieldNames:='Name';" I get the following.
ZEOS DELPHI
'Billy' ' Zee'
'Chuck' 'Billy'
' Zee' 'Chuck'
// What want is
' Zee'
'Billy'
'Chuck'
Re: How to Disable inbult Sort?
Posted: 12.02.2017, 21:36
by marsupilami
Hello ToodleDoo,
just don't use the IndexFieldsProperty at all then. Also don't use the SortedFields property. If you don't use them, Strings will be in the order as delivered by the database.
With best regards,
Jan
Re: How to Disable inbult Sort?
Posted: 13.02.2017, 16:35
by ToodleDoo
marsupilami wrote:just don't use the IndexFieldsProperty at all then.
Thanks, but unless I use the IndexFieldNames, how do I get them Alpha-sorted in order? I have no way of knowing the order they are going to be entered in.
' Zee' <-- I want "Zee" to always be the first item
'Chuck'
'Jan'
'Billy'
'Harry"
'Allan'
Without one IndexFiledNames:= they are presented in the order they were entered.
{edit}
The Table has an autoinc field so it is sorted on that with no "IndexFiledNames".
Re: How to Disable inbult Sort?
Posted: 13.02.2017, 19:04
by marsupilami
Hello ToodleDoo,
hmm - I thought you were retrieving the data sorted from your database. It seems that what you found could be a bug in Zeos.
But if you want to have some values to be sorted before the other values, why don't you have a kinda presort column for that? Your dataset could look something like this:
Code: Select all
Name | Presort
-------+--------
'Chuck'| 2
'Jan' | 2
'Billy'| 2
'Harry'| 2
'Allan'| 2
'Zee' | 1
If you set SortedFields to 'Presort;Name', you will get what you want?
Zeos not respecting the space could be a bug nonetheless...
With best regards,
Jan
Re: How to Disable inbult Sort?
Posted: 14.02.2017, 19:52
by ToodleDoo
Thanks Jan,
I am currently doing kinda that. I have set " Zee" as "1 Zee" and that is forcing it to the top. I had thought about using the Sequence Column, but I have Sorting in a DBGrid TitleClick and it gets messy with the bangfauzan-Sort Options. That's why I'd like to be able to disable all of the bangfauzan-Sort-specific stuff.
It is too difficult to manage using combined IndexFieldNames and alternating sort order between indexed directions up/down.
The bangfauzan-Sort keeps adding in the "Asc/Desc". It gets very complicated when trying to use five or six FieldNames in the IndexedFieldNames as I have little control over what the user needs when they click a DBGrid.Title.
I'd rather have it the Delphi-BDE way where I can set what **I** want without things being interpreted by the bangfauzan-Sort stuff.
Having an option to REALLY ignore the bangfauzan-Sort would be good. It is a pain when I set it to "stIgnore" and it is adjusted as soon as I add a FieldName to the IndexFieldNames list, "stIgnore" gets changed to "stAscending" right away regardless of what I really want.
When I want to "ignore" something, I REALLY want it ignored for this application. I understand the bangfauzan-Sort is a nice feature for simple databases, but it often gets in the way by assuming way too much.
Re: How to Disable inbult Sort?
Posted: 15.02.2017, 08:42
by marsupilami
Hello ToodleDoo,
I had a look into the code. To me it seems that the bangfauzan additions are only about being able to sort more than one field. See
http://zeoslib.sourceforge.net/viewtopic.php?f=34&t=935 for more info.
I tried to check the code and it seems that Zeos basically uses inbuilt functions for comparing Strings, like WideCompareStr, CompareStringW, CompareStringA, AnsiStrComp. Maybe Windos is playing a trick on you here because to me it seems that Zeos prefers to use CompareStringA and CompareStringW for comparisons on Windows?
The calling path seems to be something like this for getting the compare functions: TZAbstractRODataset.InternalSort -> ResultSet.GetCompareFuncs -> TZAbstractCachedResultSet.GetCompareFuncs -> TZRowAccessor.GetCompareFuncs -> TZRowAccessor.GetCompareFunc
What do you think?
With best regards,
Jan
Re: How to Disable inbult Sort?
Posted: 15.02.2017, 18:50
by ToodleDoo
marsupilami wrote:What do you think?
Hi Jan, Hmmm, not sure, but I am using this with Ubuntu 14.04 if that makes any difference. But - this didn't happen when I used this almost exact same code in Windows. I have changed over to Ubuntu and Lazarus and re-compiling everything, but that section of code is predominantly unchanged and used to work as expected.
The "Sort" is more of a nuisance than anything. If you use multiple Fields it always starts by assigning "Asc" to the end of each Field. Often that is not what is needed. I may need the Primary index-Field based on "Desc" and the secondary on "Desc" When the user clicks a DBGrid.Title I need the primary to go "Asc" but the secondary to stay "Desc' and that makes for a lot of complicated "if then" stuff fighting with the bangfauzan Sort.
I tried stripping all the "bangfauzan" stuff out of the units but it seems that not all changes are flagged as "bangfauzan addition" as some seemingly unrelated dependencies will not compile.
I dislike software that applies it's rule without enough thought on what others might need. "stIgnore" should be honoured totally and not just until I add a Field to the IndexFieldNames.
Re: How to Disable inbult Sort?
Posted: 16.02.2017, 00:35
by marsupilami
Hello ToodleDoo,
ToodelDoo wrote:But - this didn't happen when I used this almost exact same code in Windows. I have changed over to Ubuntu and Lazarus and re-compiling everything, but that section of code is predominantly unchanged and used to work as expected.
Honestly I doubt that you have used Zeos on Windows because it behaves the same on Windows and Linux - well more or less.
Does your code conform to case C of Fauzan Badriawan's description?
Fauzan Badriawan wrote:C. if we want to sort Nation Descendingly, City Ascendingly and CustName Acendingly, the steps are:
- Setting SortType to be stIgnored
- Typing "Nation Desc;City Asc;CustName Asc" into SortedFields
or just enter "Nation Desc;City;CustName"
then IndexFieldNames would be the same with SortedFields
I have the impression, it doesn't because you describe that you try to manage IndexFieldNames which, according to his description, you don't need to manage.
If your code complies to his description and things don't work, please provide a full test case (Database and Project), so I don't need to do guesswork anymore.
With best regards,
Jan