Skip to content

Commit

Permalink
OleDbSqlServerTableFunction doesn't support sorting with table limits #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Grauenwolf committed Jul 5, 2022
1 parent f34007d commit 9c445c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Tortuga.Chain/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The fix is to default to sorting with primary key when using WithLimits. If ther

This change also affects table-valued functions. Except these cannot infer the sort order as they do not have a primary key.

For reflection-based scenarios, the method `TableOrViewMetadata<TObjectName, TDbType>.GetDefaultSortOrder(int)` can be used to get a table's default sort order.

### Features

[#459 Add TimeSpan support for Access and OleDB](https://github.com/TortugaResearch/Tortuga.Chain/issues/459)
Expand Down Expand Up @@ -41,6 +43,12 @@ This was done to improve support for lookup tables with small keys.

The OleDB version of SQL Server was truncating fractional seconds when the parameter type is `time(n)` and `n>0`. To fix this, we have to force it to use `DateTime/DBTimeStamp` instead of `TimeSpan/DBTime`.

[#465 OleDbSqlServerTableFunction doesn't support sorting with table limits](https://github.com/TortugaResearch/Tortuga.Chain/issues/465)


Using either works, but there is an error if both are used.


### Performance Enhancements

[#439 Use `SqlCommand.EnableOptimizedParameterBinding` in SQL Server MDS.](https://github.com/TortugaResearch/Chain/issues/439)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ public override CommandExecutionToken<OleDbCommand, OleDbParameter> Prepare(Mate

if (m_SortExpressions.Any())
{
sql.Append(" OFFSET @offset_row_count_expression ROWS ");
sql.Append(" OFFSET ? ROWS ");
parameters.Add(new OleDbParameter("@offset_row_count_expression", m_Skip ?? 0));

if (m_Take.HasValue)
{
sql.Append(" FETCH NEXT @fetch_row_count_expression ROWS ONLY");
sql.Append(" FETCH NEXT ? ROWS ONLY");
parameters.Add(new OleDbParameter("@fetch_row_count_expression", m_Take));
}
}
Expand Down Expand Up @@ -316,4 +316,4 @@ protected override TableDbCommandBuilder<OleDbCommand, OleDbParameter, SqlServer
m_SortExpressions = sortExpressions;
return this;
}
}
}

0 comments on commit 9c445c6

Please sign in to comment.