delphi – TFDTable中的降序排序导致重复的行

在LDW模式下使用TFDTable时,降序字段会导致重复的行.例如:

TFDTable.TableName is set to a VIEW name (not a tablename)

TFDTable.UpdateOptions.KeyFields is set to the primary key in the VIEW base table.

TFDTable.IndexFieldNames is set to 'PERS_NAME:A'.

显示正确的结果集,没有任何重复.如果我将IndexFieldnames更改为“PERS_NAME:D”,则视图返回的每条记录都会显示两次或树次.

如何避免这些重复?只有在按降序排序表时才会发生这种情况,无论我使用哪个字段进行排序.

更新:
您可以找到一个示例项目来重现github上的问题:https://github.com/cytrinox/firedac-sort-issue或通过https://github.com/cytrinox/firedac-sort-issue/archive/master.zip下载项目

最佳答案 这个问题将持续存在,直到我们在LDW模式下获得处理TFDTable的其他方法.

Definition of LDW – XE6

使用LDW和基于数字之外的任何索引(即整数)将使您遇到各种问题 – 如果您不遵守规则.

我也花了好几个小时试图让LDW使用索引的VARCHAR字段 – 但让我的SQL语句使用COLLATE(或直接整理字段的字符集)会使我的应用程序无用.意味着它会因您描述的相同错误而崩溃.

以下是我从FireDAC的作者那里获得的信息.

There are 1001 way to make LDW failing due to concept. There is no sense and no ability to make client side sorting to be synchronized
with server side sorting collation in all cases. IOW, when you are
sorting TFDTable on a string field, it may fail in more cases when
anyone can imagine. Two ways:

  
  
  >您正在理解为什么会发生这种情况并尝试调整FireDAC客户端排序,如上所述.我不能提供所有选择 –
  太多.
  >你不理解 – 那么最好不要在字符串列上排序TFDTable,甚至不要使用TFDTable.
  
  
  你上面的段落
  当你被允许使用TFDTable和时,可以考虑作为合同
  什么时候不.

Personaly我很乐意看到LDW在不需要内部排序的情况下运行.
如果我们可以禁用排序并让它处理数据分页 – 这将是很好的.

编辑:

想一想 – 尝试使用TFDQuery而不是TFDTable. TFDQuery不支持LDW,那么你应该好好去.

希望这对你有所帮助.

点赞