avatar fredhob
fredhob
7 Jan 2022

Steps to reproduce the issue

Install an extension with an install sql file contain the command "CREATE TABLE IF NOT EXISTS"

Expected result

No alert on Joomla administration

Actual result

Alert in SQL alerts => "Table 'IF' does not exist. (From file 1.0.0.sql.)

System information (as much as possible)

Joomla 4.0.5

Additional comments

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
3.00

avatar fredhob fredhob - open - 7 Jan 2022
avatar brianteeman
brianteeman - comment - 7 Jan 2022
avatar HLeithner HLeithner - change - 7 Jan 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-01-07 09:09:47
Closed_By HLeithner
Labels Removed: ?
avatar HLeithner HLeithner - close - 7 Jan 2022
avatar HLeithner
HLeithner - comment - 7 Jan 2022

The SQL file is shipped with the extension and the error message is generated by the SQL server. The extension dev has to fix the SQL query.

I'm closing this since not a core issue.

avatar richard67
richard67 - comment - 7 Jan 2022

@HLeithner I think you misunderstood. The error is from the database checker, I think, and the SQL script is a schema update of a 3rd party extension, as you can see by the script name. The database checker does not understand the optional IF NOT EXISTS keywords in a CREATE TABLE statement before the table name, but it is valid SQL for both MySQL and MariaDB. It’s just the database checker (MySQL change item) which currently doesn’t understand that. I am working on a PR to change that, but it might take a bit time. Nevertheless right. Ow it is expected (but undocumented) behavior.

avatar richard67
richard67 - comment - 7 Jan 2022

@brianteeman As you can see in the docs you have linked and could see in the equivalent docs for MariaDB, the optional keywords IF NOT EXISTS before the table name are valid SQL for these databases (as well as PostgreSQL). The author of the issue just hasn’t posted the complete statement. He has omitted the table name.

avatar richard67
richard67 - comment - 7 Jan 2022

We should never have made the db checker check also 3rd party extensions in J4. Just my 5 ct.

avatar brianteeman
brianteeman - comment - 7 Jan 2022

The author of the issue just hasn’t posted the complete statement. He has omitted the table name.

Your ability to read invisible ink is obviously better than mine :)

avatar HLeithner HLeithner - change - 7 Jan 2022
Status Closed New
Closed_Date 2022-01-07 09:09:47
Closed_By HLeithner
avatar HLeithner HLeithner - reopen - 7 Jan 2022
avatar HLeithner
HLeithner - comment - 7 Jan 2022

ok in this case please fix it ;-)

avatar richard67
richard67 - comment - 7 Jan 2022

Hmm, I might have to correct myself. The MySQL change item handles that, too: https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Schema/ChangeItem/MysqlChangeItem.php#L213-L227

So it seems the SQL statement in the SQL script really is incomplete.

avatar richard67
richard67 - comment - 7 Jan 2022

@fredhob Could you post here the complete SQL statement from that file 1.0.0.sql so we can see what the error is? Thanks in advance.

avatar richard67
richard67 - comment - 7 Jan 2022

I was maybe confused by a similar recent issue with other optional keyword which was really not supported by the checker.

avatar HLeithner HLeithner - change - 7 Jan 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-01-07 21:36:48
Closed_By HLeithner
avatar HLeithner
HLeithner - comment - 7 Jan 2022

ok no problem thanks for rechecking, in this case I close it until @fredhob provides a complete sql script so we can reproduce the error.

avatar HLeithner HLeithner - close - 7 Jan 2022
avatar fredhob
fredhob - comment - 10 Jan 2022

Ok i understand the "problem" in my sql script, no space between EXISTS and the table name:

CREATE TABLE IF NOT EXISTS#__table

And Joomla 4 don't like it


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36595.

avatar richard67
richard67 - comment - 10 Jan 2022

Ok i understand the "problem" in my sql script, no space between EXISTS and the table name:

CREATE TABLE IF NOT EXISTS#__table

And Joomla 4 don't like it

Thanks for reporting back. Joomla is right at this point, without the space it's not valid syntax. The database may be tolerant with that and not throw an SQL error, depending on server settings, but we should not try to adapt our database checker to such tolerance of invalid SQL.

Add a Comment

Login with GitHub to post a comment