Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

As reported in #3603 and #2149, when you apply a display format, the sort order starts to use the displayed text and no longer the internal column data. Ideally, the user should be able to select the behaviour, but that will require development effort, translations and possible bugs, so it won't happen for the next v3.13. It's easy, though, to just change the behaviour, so the internal data value is always used, via this simple change:

@@ -119,11 +119,11 @@ std::string Query::buildQuery(bool withRowid) const
     for(const auto& sorted_column : m_sort)
         order_by += sorted_column.toSql() + ",";
     if(order_by.size())
     {
         order_by.pop_back();
-        order_by = "ORDER BY " + order_by;
+        order_by = "ORDER BY " + m_table.toString() + "." + order_by;
     }
 
     return "SELECT " + selector + " FROM " + m_table.toString() + " " + where + " " + order_by;
 }

That means that we could include this change in 3.13 if it is considered the most general and expected behaviour for the majority of users.

Consequently, I'd appreciate it if many users vote for their preference, so we can decide what to do for the imminent v3.13.

How should behave DB4S v3.13 regarding the sorting order after applying a display format?
Keep it at it is in v3.12, sort by the displayed text
100%
Change the sort order, so it always sorts by the internal data value (as it was in v3.10)
0%
You must be logged in to vote

Replies: 3 comments · 3 replies

Comment options

What's a situation where sorting by the internal data value would be preferred?

I'm trying to think of one (quickly), but everything I'm coming up with (so far) would be better sorting by the result after formatting is applied.

You must be logged in to vote
0 replies
Comment options

Ahhh. Looking at the linked examples shows the problem:

Clicking on the header of the column should still use REAL to sort the column cells. It makes not really sense that just adding a precision of 2 to a REAL value destroy sorting of the values.

The problem seems to be our current approach is changing the underlying data type (eg number to string) when applying formatting. So what should (for example) be a simple format change to adjust the number of decimal places in numbered output changes the sort order completely.

Sounds like a bug we could potentially fix in a 3.13.1 follow up release. 😄

You must be logged in to vote
1 reply
@mgrojo
Comment options

mgrojo Jun 24, 2024
Maintainer Author

Sounds like a bug we could potentially fix in a 3.13.1 follow up release. 😄

In fact, there is a workaround for real numbers #3603 (just don't use a function that returns a string like printf, but a real, like round). I don't know if a similar workaround could be applied to dates as in #2149. In any case, priority is low, in my opinion.

Comment options

Let me throw a (potentially-related) rock in the pond... I think we are talking about the sort order of the rows viewed in the Browse Data tab. True?

My new idea is that I sometimes feel the urge to sort the rows of the Execute SQL tab as well. I would find this useful to get a sense of, "What fraction of rows have a value less than 5..." without constructing a whole new query. I have always figured that DB4S displays the rows sorted by the order by... clause, and thus "shouldn't be changed". I also note that, if DB4S did allow sorting of query results, there would be no way to "get back to the query result order..."

BUT... Perhaps we could address both questions with one mechanism. I'll throw out this idea (without much thought behind it), that basically would add a third choice to the options above:

  • You can currently sort rows by clicking column headings. Click once to sort lowest to highest; click again to reverse he sort.
  • What if you could click a third time to restore the "One True Sort Order"?
    • For the Browse Data tab, this would restore the order to EITHER the displayed value or the underlying order in the internal table value. (We would need to make a choice of which would be the default.)
    • For the Execute SQL tab, clicking the column heading would toggle between the three states: displayed order, reverse displayed order, original order.

This needs lots more thought (and thus shouldn't hold up 3.13), because as I was typing this, I came up more questions:

  • How do we indicate "display order" vs "natural/internal table order"? DB4S would need to tweak the "column sort" indicators (little up/down arrows in 3.13)
  • Do we need a fourth state to create "reversed internal value" order
  • Is this a dumb idea?

Thanks for listening.

You must be logged in to vote
2 replies
@chrisjlocke
Comment options

What if you could click a third time to restore the "One True Sort Order"?

This seems unusual logic, and as other programs don't do this, doesn't seem intuitive to the user. I prefer to keep things 'traditional' and 'expected', as it leads to less support issues. If the original order is required again, the user can simply rerun the query?

DB4S would need to tweak the "column sort" indicators

This is my point - so many apps use the up and down arrows, people know what they are .. if we start using double-arrows or blue arrows then green arrows (for example), they're not going to immediately know what these are for.

Do we need a fourth state to create

Obi-Wan: "I felt a great disturbance in the Force, as if millions of voices suddenly cried out in terror and were suddenly silenced. I fear something terrible has happened."
Eurgh no ... just .. no.

But this is only my opinion .. one vote out of many.

@richb-hanover
Comment options

... and that's why I included "Is this a dumb idea?" as an option for opinions. :-)

I just voted to retain the 3.12 behavior. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.