error/invalidmssqlnativetype

I wrote a plugin for a client that worked perfectly on my localhost LAMP installation, but failed when running on their production site that uses MSSQL as the database.

automation_error_1.jpg

The error occurred when setting the status of a column in the database to ‘1’. Viewing the insert does not reveal to much, so at first glance the problem and solution are not immediately obvious.

automation_error_2.jpg

In looking for a solution I come across this tracker post, which helped my identify the problem, and ultimately the solution

The problem was that I was using TINYINT as a DataType in my flag DB column. Perfectly fine for MySQL, but not for MSSQL.

I discovered this by looking more carefully at the error from the cron log, and then checking the available DataTypes in lib/dml/mssql_native_moodle_database.php.

automation_error_3.jpg

The fix was simply to change the DataType to INT. I could have, as the solution in the tracker suggested added TINYINT to the php file. But, that’s a change to core, and the better solution is to fix your own code, not Moodle.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s