Confusing sort interface

Aberta
#1,442 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@lovasoa já está trabalhando nisso.

Desde 11/9/2026.

  • #1445 de @lovasoa — aberto

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
20/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
postgresql, rust, sql
Domínio
database, frontend

Direção de pesquisa

Start with the table component’s sorting behavior and discussion #778, which is cited as related context. The issue gives a SQL example with pagination but names no source files or tests; trace how sort column and direction are handled and how they could reach the backend query. Done means sorting applies to the full result set across pages; an open pull request (#1445) already exists.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug
Introduction

Any table which has more rows than the page size can deliver wrong results if sorted by the column headers in the table component. This is significant if you have a table lots of rows that is paginated by the pagination component.

To Reproduce

The issue is very simple, just select a table with more tuples then your pagination (say a pagination of 100 for a total records of 500), sort it by the table header and then advance to the following page.

SELECT 'table' AS component, true AS sort,
    '/atti/edit.sql?id_soc={id}' AS edit_url,
    '/atti/delete.sql?id_soc={id}' AS delete_url;

SELECT
    t.id_atto::text AS _sqlpage_id,
    COALESCE(t.notaio::text, '—') AS "Notaio",
    COALESCE(t.filza::text, '—') AS "Filza",
    COALESCE(t.documento_n::text, '—') AS "Documento n.",
    to_char(t.data_stipula, 'DD/MM/YYYY') AS "Data Stipula",
    COALESCE(t.tipo_atto::text, '—') AS "Tipo Atto",
    COALESCE(t.regesto::text, '—') AS "Regesto"
FROM atti AS t
ORDER BY t.id_atto
LIMIT 100 OFFSET COALESCE(CAST(NULLIF($offset, '') AS INTEGER), 0);

SELECT 'pagination' AS component;
SELECT
    (g.i / 100 + 1) AS contents,
    sqlpage.link(sqlpage.path(), jsonb_strip_nulls(jsonb_build_object('offset', g.i, 'notaio', NULLIF($notaio, ''), 'filza', NULLIF($filza, ''), 'documento_n', NULLIF($documento_n, ''), 'sort', COALESCE(NULLIF($sort, ''), 'id_atto'), 'dir', NULLIF($dir, '')))) AS link,
    (g.i = COALESCE(CAST(NULLIF($offset, '') AS INTEGER), 0)) AS active
FROM generate_series(0, GREATEST((SELECT count(*) FROM atti AS t WHERE (NULLIF($notaio, '') IS NULL OR t.notaio::text ILIKE '%' || $notaio || '%') AND (NULLIF($filza, '') IS NULL OR t.filza::text ILIKE '%' || $filza || '%') AND (NULLIF($documento_n, '') IS NULL OR t.documento_n::text ILIKE '%' || $documento_n || '%')) - 1, 0), 100) AS g(i);
Actual behavior

The order is valid only for the current page (and selection!). If I understand well, there is no way to forward it towards the database.
There is an open discussion "Table filtering, sorting, pagination." by jeneizs-74 here:
https://github.com/sqlpage/SQLPage/discussions/778
It has no answer since Jan 15, 2025.

This may lead to errors and Is anyway confusing for the user who may think sorting shows the proper records, while he will get only the result of sorting the page records.

Expected behavior

I think sorting should happen on the entire table. At least there should be some way of getting sorting column(s) and direction so to force a new select on the backend.

Linguagem predominante
Rust
Estrelas
2.6k
Forks
175
Merge médio
14h 16min
PRs com merge (30d)
43

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de sqlpage/SQLPage

Todas as issues de sqlpage/SQLPage

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.