Servoy 3.5.1 databaseManager.getSQL(foundset) oddity

Consider the following code

var query = "SELECT booksid FROM books WHERE ti ILIKE 'co%' ORDER BY ti";
controller.loadRecords(query,null);
application.output(query);
application.output(databaseManager.getSQL(foundset));

Loads the records fine, in the correct order, but my log shows:

SELECT booksid FROM books WHERE ti ILIKE 'co%' ORDER BY ti
select booksid from books  where booksid in (SELECT booksid FROM books WHERE ti ILIKE 'co%' ) order by booksid asc

The records are shown on screen sorted by ti, but databaseManager.getSQL(foundset) has lost my ORDER BY clause and added its own. Which means you can’t use it restore records in the correct order. The form does not have an initial sort.

Also

select booksid from books where booksid in (SELECT booksid FROM …

Looks inefficient and unnecessary to me.

PostgreSQL 8.2.4 And Servoy 3.5.1 on Mac OS X.

Christian,

We use the custom query as a subselect as shown in your example.
We need that to be able to modify the foundset dynamically.

The user may use it to do a find or we may have to add filter parameters.

Unfortunately, this looses the sorting.

Rob

OK.

I suppose I can record the sort_order myself. But what about adding

databaseManager.getSQLSortOrder(foundset)

?

Then the fact that you loose the sort order becomes more obvious…