anchorcms/anchor-cms

Bug: SQL database names containing hyphens not possible

Opened this issue · 3 comments

Summary

When installing Anchor from scratch, it is not able to get access to the server's database because of a SQL syntax error when the database's name has a particular format (containing hyphens)

Expected Behaviour

Settle up Anchor's database structure during installation.

Actual Behaviour

  1. Start installation of Anchor CMS
  2. When it comes to database setup, fill in the database's name. For me in particular it was starting with "ogv-hau.." (not showing full name here), which is the problem.
  3. When the installation routine tries to set up the database structure, it throws an error like:
    SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-hau...' at line 1

I tried the same setup but without the hyphen in the database's name --> works.
This means Anchor cannot deal with hyphens in SQL syntax.
I would say using brackets for those names would solve the issue, no?

--Edit:
After installing Anchor with a database without hyphens in its name and afterwards renaming the database to have hyphens in its name and editing the name in anchor/config/db.php manually actually works. The issue therefore is only installation-related.

Context details (if applicable)

  • Anchor version: 0.12.7
  • Server setup: PHP 7.2, MySQL 5.6
  • URL

@dhilleCZ

Thanks for spotting this one!

Made a pull request with a fix for the installer.

#1309

I assume this can be closed now? @CraigChilds94