Tighten DbViewer paging — int constant and matching SQL parameter name
Audit findings M-1 and M-2. Two small consistency issues in the
upstream DbViewer paging path that we now own as a fork:
- RowPerPage is a row count and should be an int. The upstream
declaration was 1000.0f, which forced an implicit float divide
in Math.Ceiling and an implicit float-to-integer conversion when
SQLite bound the LIMIT parameter. Switching the constant to int
and casting Count to double right at the division keeps the
ceiling math intact while making the type story honest.
- GetPagedDateRange's SQL uses the placeholder $OffsetCount, but
the matching AddWithValue call passed the unprefixed name
"OffsetCount". Microsoft.Data.Sqlite tolerates this today, so
paging still worked; another provider or a stricter future
version would not. Re-aligned the parameter name with the SQL.
No behavioural change for users — paging continues to return 1000
rows per page. The fixes are kept on the fork rather than offered
upstream because the project's recent triage history makes a
non-trivial PR turnaround unlikely.
This commit is contained in:
@@ -22,7 +22,7 @@ namespace ChatTwo.Ui;
|
||||
|
||||
public class DbViewer : Window
|
||||
{
|
||||
public const float RowPerPage = 1000.0f;
|
||||
public const int RowPerPage = 1000;
|
||||
|
||||
private readonly Plugin Plugin;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class DbViewer : Window
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
var totalPages = (int)Math.Ceiling(Count / RowPerPage);
|
||||
var totalPages = (int)Math.Ceiling((double)Count / RowPerPage);
|
||||
if (totalPages < 1)
|
||||
totalPages = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user