MDL-39572: Fix sql_order_by_text() to use length argument correctly