Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating admin course #2536

Closed
miralgj opened this issue Aug 21, 2024 · 6 comments
Closed

Error creating admin course #2536

miralgj opened this issue Aug 21, 2024 · 6 comments

Comments

@miralgj
Copy link

miralgj commented Aug 21, 2024

On a fresh new install of 2.19 using MySQL Community Server v8.4, when attempting to create the admin course using the command $WEBWORK_ROOT/bin/addcourse admin --db-layout=sql_single --users=$APP_ROOT/courses/adminClasslist.lst --professors=admin I am getting the following error:

DBD::mysql::db do failed: BLOB, TEXT, GEOMETRY or JSON column 'session' can't have a default value at /opt/webwork/webwork2/lib/WeBWorK/DB/Schema/NewSQL/Std.pm line 930.

I knew the installation instructions for 2.19 state that MariaDB is recommended but it also states that MySQL is ok to use. Is this error due to an incompatible database?

@drgrice1
Copy link
Member

What version of MySQL is that? Also, are you using the DBD::mysql or DBD::MariaDB perl database driver module?

I believe that recent versions of MySQL do support default values for TEXT columns, but may be mistaken. However, the DBD::mysql driver may not. You could try the DBD:MariaDB driver instead.

If MySQL still does not support default values for TEXT columns, then perhaps it is time to say that we stop supporting use of MySQL.

@dlglin
Copy link
Member

dlglin commented Aug 21, 2024

From the MySQL docs (https://dev.mysql.com/doc/refman/8.4/en/data-type-defaults.html):
The BLOB, TEXT, GEOMETRY, and JSON data types can be assigned a default value only if the value is written as an expression, even if the expression value is a literal:

This is permitted (literal default specified as expression):

CREATE TABLE t2 (b BLOB DEFAULT ('abc'));

This produces an error (literal default not specified as expression):

CREATE TABLE t2 (b BLOB DEFAULT 'abc');

@miralgj
Copy link
Author

miralgj commented Aug 21, 2024

I am using MySQL Community Server 8.4.2 LTS and my database driver is DBD::mysql.

@drgrice1
Copy link
Member

@dlgin: I saw that too. That is why I suggested switching to the DBD::MariaDB perl database driver module. It may take care of that, and the DBD::mysql module may not be updated to handle that. Another possibility is to try changing line 33 of lib/WeBWorK/DB/Record/Key.pm to session => { type => "TEXT NOT NULL DEFAULT ('{}')" }. So @miralgj, could you try that and see if that resolves the issue? If it does, then I will make a pull request with that change.

@miralgj
Copy link
Author

miralgj commented Aug 21, 2024

@dlgin: I saw that too. That is why I suggested switching to the DBD::MariaDB perl database driver module. It may take care of that, and the DBD::mysql module may not be updated to handle that. Another possibility is to try changing line 33 of lib/WeBWorK/DB/Record/Key.pm to session => { type => "TEXT NOT NULL DEFAULT ('{}')" }. So @miralgj, could you try that and see if that resolves the issue? If it does, then I will make a pull request with that change.

That does indeed resolve the issue. Thanks!

drgrice1 added a commit to drgrice1/webwork2 that referenced this issue Aug 22, 2024
…ey` table.

MySQL requires that the default value for a `TEXT` column be written as
an expression.  See https://dev.mysql.com/doc/refman/8.4/en/data-type-defaults.html.
MariaDB apparently works fine without this, but works fine with it as
well.

This fixes issue openwebwork#2536.
drgrice1 added a commit to drgrice1/webwork2 that referenced this issue Aug 22, 2024
…ey` table.

MySQL requires that the default value for a `TEXT` column be written as
an expression.  See https://dev.mysql.com/doc/refman/8.4/en/data-type-defaults.html.
MariaDB apparently works fine without this, but works fine with it as
well.

This fixes issue openwebwork#2536.
@somiaj
Copy link
Contributor

somiaj commented Aug 27, 2024

The fix has been merged, so closing.

@somiaj somiaj closed this as completed Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants