当默认orderby列类型为date时,网格排序错误。还有其他人遇到这个问题吗?

时间:2019-04-04 22:37:03

标签: web2py

我有这个动作

@auth.requires(auth.has_membership(CHECKER_ROLE) or auth.has_membership(SUPERVISOR_ROLE))
def list_tags_to_issue():
    """List tags to issue.

    :return: Dict with grid.
    """

   query = ((db.wo.is_active == True)
            & (db.wo.tags_issued == False)
            & (db.wo.pies_verified == False)
            & (db.wo.equipment_id == db.equipment.id))

    grid = SQLFORM.grid(
        query,
        create=False,
        csv=False,
        deletable=False,
        details=False,
        editable=False,
        fields=[db.wo.est_finish,
                db.equipment.name,
                db.wo.sn,
                db.wo.opts,
                db.wo.finished,  # Necessary dummy entry.
                db.wo.canceled_on,  # Necessary dummy entry.
                db.wo.canceled_by,  # Necessary dummy entry.
                db.wo.cancel_approved_by,  # Necessary dummy entry.
        ],
        orderby=db.wo.est_finish,
    )

    return dict(grid=grid)

此视图

{{extend 'layout.html'}}

<h2>{{=T('List tags to issue')}}</h2>

{{=grid}}

{{if DEV:
=response.toolbar()
pass}}

如果我尝试更改默认orderby列(est_finish)中的排序,则不会发生。 URL从... orderby = do.wo.est_finish更改为... orderby =〜db.wo.est_finish,但网格未更改。 当我看到数据库统计信息时,SQL命令也没有更改。 SQL命令始终为

SELECT "wo"."est_finish", "equipment"."name", "wo"."sn", "wo"."opts", "wo"."finished", "wo"."canceled_on", "wo"."canceled_by", "wo"."cancel_approved_by", "wo"."id" 
FROM "wo", "equipment" 
WHERE (((("wo"."is_active" = 'T') AND ("wo"."tags_issued" = 'F')) AND ("wo"."pies_verified" = 'F')) AND ("wo"."equipment_id" = "equipment"."id")) 
ORDER BY "wo"."est_finish", "wo"."id" LIMIT 20 OFFSET 0;

无论URL从... orderby = do.wo.est_finish更改为... orderby =〜db.wo.est_finish。

这是显示此问题的3个不同视图(所有视图都有一个带日期列的orderby)之一。所有其他人都可以正常工作。

如果我从网格中删除orderby参数或将其更改为非日期参数,则一切正常,包括日期列的排序。

有什么想法吗?

谢谢

JM

1 个答案:

答案 0 :(得分:0)

在web2py组中报告此问题后,此问题已在2.18.5版中修复。