Description
While trying to set up the PayrollEngine Backend using the MySQL provider on a Linux environment (MySQL 8.0.46), the database initialization stage fails due to several T-SQL migration leftovers and strict type-casting rules in MySQL 8.0+.
Here are the specific issues found and fixed during the setup:
1. Invalid CAST(... AS INT) in MySql-Routines.merged.sql
MySQL does not support casting directly to INT. Instead, it requires SIGNED or UNSIGNED.
- Error thrown:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual... near 'INT) INTO v_collectorNameHash
- Affected Stored Procedures: *
GetCollectorCustomResults
GetCollectorResults
GetConsolidatedCollectorCustomResults
GetConsolidatedCollectorResults
- Fix: Change all occurrences of
CAST(jt.val AS INT) to CAST(jt.val AS SIGNED).
2. Missing USE PayrollEngine; and T-SQL Syntax in Update-Model.mysql.sql
The update script fails because no database context is selected, and it contains SQL Server-specific brackets ([PayrollEngine]).
- Error thrown:
ERROR 1046 (3D000): No database selected followed by ERROR 1049 (42000): Unknown database '[PayrollEngine]'
- Fix: Ensure
USE PayrollEngine; is specified at the top, and replace the brackets [PayrollEngine] with proper MySQL backticks `PayrollEngine` or remove them.
Steps to Reproduce
- Configure
DbProvider as MySql in appsettings.json.
- Deploy the MySQL container using the provided
docker-compose.yml.
- Let the
docker-entrypoint-initdb.d scripts execute automatically.
Environment
- OS: Linux (openSUSE Leap)
- MySQL Version: 8.0.46
- PayrollEngine Version: Latest Main branch
Description
While trying to set up the PayrollEngine Backend using the MySQL provider on a Linux environment (MySQL 8.0.46), the database initialization stage fails due to several T-SQL migration leftovers and strict type-casting rules in MySQL 8.0+.
Here are the specific issues found and fixed during the setup:
1. Invalid
CAST(... AS INT)inMySql-Routines.merged.sqlMySQL does not support casting directly to
INT. Instead, it requiresSIGNEDorUNSIGNED.ERROR 1064 (42000): You have an error in your SQL syntax; check the manual... near 'INT) INTO v_collectorNameHashGetCollectorCustomResultsGetCollectorResultsGetConsolidatedCollectorCustomResultsGetConsolidatedCollectorResultsCAST(jt.val AS INT)toCAST(jt.val AS SIGNED).2. Missing
USE PayrollEngine;and T-SQL Syntax inUpdate-Model.mysql.sqlThe update script fails because no database context is selected, and it contains SQL Server-specific brackets (
[PayrollEngine]).ERROR 1046 (3D000): No database selectedfollowed byERROR 1049 (42000): Unknown database '[PayrollEngine]'USE PayrollEngine;is specified at the top, and replace the brackets[PayrollEngine]with proper MySQL backticks `PayrollEngine` or remove them.Steps to Reproduce
DbProviderasMySqlinappsettings.json.docker-compose.yml.docker-entrypoint-initdb.dscripts execute automatically.Environment