MSSQL unit test failures

Open
#692 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php, sql
Domain
database, testing

Research direction

Start with admin/tool/objectfs/classes/task/populate_objects_filesize.php at the query used by the failing task and inspect the related tests in admin/tool/objectfs/tests/task/populate_objects_filesize_test.php. Reproduce the reported failure on SQL Server and check how the query’s selected columns relate to its GROUP BY clause. Done means both named tests pass on SQL Server and the task still handles orphaned objects and objects with errors as expected.

Written by the indexing model from the issue text.

Description

bug
291) tool_objectfs\task\populate_objects_filesize_test::test_orphaned_objects_are_not_updated
dml_read_exception: Error reading from database (SQLState: 42000<br>
Error Code: 8120<br>
Message: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Column 'phpu_tool_objectfs_objects.timeduplicated' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.<br>

SELECT o.id, o.contenthash, o.timeduplicated, o.location, f.filesize
                  FROM phpu_tool_objectfs_objects o
                  JOIN phpu_files f ON o.contenthash = f.contenthash
                 WHERE o.filesize IS NULL
                   AND o.location >= 0
              GROUP BY o.id,
                       o.contenthash,
                       f.filesize ORDER BY 1 OFFSET 0 ROWS  FETCH NEXT 100001 ROWS ONLY
[array (
)])

/var/www/site/lib/dml/moodle_database.php:497
/var/www/site/lib/dml/sqlsrv_native_moodle_database.php:331
/var/www/site/lib/dml/sqlsrv_native_moodle_database.php:438
/var/www/site/lib/dml/sqlsrv_native_moodle_database.php:909
/var/www/site/admin/tool/objectfs/classes/task/populate_objects_filesize.php:55
/var/www/site/admin/tool/objectfs/tests/task/populate_objects_filesize_test.php:191
/var/www/site/lib/phpunit/classes/advanced_testcase.php:76

292) tool_objectfs\task\populate_objects_filesize_test::test_objects_with_error_are_not_updated
dml_read_exception: Error reading from database (SQLState: 42000<br>
Error Code: 8120<br>
Message: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Column 'phpu_tool_objectfs_objects.timeduplicated' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.<br>

SELECT o.id, o.contenthash, o.timeduplicated, o.location, f.filesize
                  FROM phpu_tool_objectfs_objects o
                  JOIN phpu_files f ON o.contenthash = f.contenthash
                 WHERE o.filesize IS NULL
                   AND o.location >= 0
              GROUP BY o.id,
                       o.contenthash,
                       f.filesize ORDER BY 1 OFFSET 0 ROWS  FETCH NEXT 100001 ROWS ONLY
[array (
)])

/var/www/site/lib/dml/moodle_database.php:497
/var/www/site/lib/dml/sqlsrv_native_moodle_database.php:331
/var/www/site/lib/dml/sqlsrv_native_moodle_database.php:438
/var/www/site/lib/dml/sqlsrv_native_moodle_database.php:909
/var/www/site/admin/tool/objectfs/classes/task/populate_objects_filesize.php:55
/var/www/site/admin/tool/objectfs/tests/task/populate_objects_filesize_test.php:226
/var/www/site/lib/phpunit/classes/advanced_testcase.php:76
Dominant language
PHP
Stars
102
Forks
85
Avg merge
4d 21h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from catalyst/moodle-tool_objectfs

All issues in catalyst/moodle-tool_objectfs

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.