Error converting psql DB to mariadb: QuoteHelper.php line 62: Only strings, Literals and Parameters are allowed
Nextcloud version (eg, 20.0.5): 21.0
Operating system and version (eg, Ubuntu 20.04): MacOS Big Sur
Apache or nginx version (eg, Apache 2.4.25): 2.4.46
PHP version (eg, 7.4): 7.4.15
When I convert DB (in this case: from Postgresql to MariaDB) I get error message
In QuoteHelper.php line 62: Only strings, Literals and Parameters are allowed
Steps to replicate it:
php occ db:convert-type --clear-schema mysql <myuser> 127.0.0.1 <mydb>
What is the database password?
Clearing schema in new database
Creating schema in new database
The following tables will not be converted:
oc_audioplayer_genre
...
oc_retention
oc_users_external
Please note that tables belonging to available but currently not installed apps
can be included by specifying the --all-apps option.
Continue with the conversion (y/n)? [n] y
oc_accounts
0/2 [>---------------------------] 0%
In QuoteHelper.php line 62:
Only strings, Literals and Parameters are allowed
Stack trace shows that instance of Doctrine\DBAL\Schema\Column is passed to quoteColumnName($string).
As quick workaround I added to QuoteHelper.php (line 57):
if ($string instanceof \Doctrine\DBAL\Schema\Column) {
return $string->getName();
}
(first reported in community forum)
@MorrisJobke I don't know who's the DB guy, but my best shot was you. :)
I also noticed this during a conversion using NC 21.
Nextcloud version (eg, 20.0.5): nextcloud:production (20.0.8) Operating system and version (eg, Ubuntu 20.04): Docker on Ubuntu 20.04 Apache or nginx version (eg, Apache 2.4.25): 2.4.38 PHP version (eg, 7.4): 7.4.16
Same problem here the other way around: Migrating MariaDB to PostgreSQL. But the workaround did the job also.
This issue affected me when attempting to convert the standard sqlite database to MySQL format.
Nextcloud version: 21.0.0 Operating system: Gentoo Linux. Nginx version: 1.19.8 PHP version: 8.0.3.
Inserted the below into line 57 of QuoteHelper.php as well, and the conversion was successful.
if ($string instanceof \Doctrine\DBAL\Schema\Column) {
return $string->getName();
}
Same problem converting from sqlite to mysql on mariadb
Nextcloud version (eg, 20.0.5): 21.0
Operating system and version (eg, Ubuntu 20.04): Ubuntu 18.04
Apache or nginx version (eg, Apache 2.4.25): 1.19.3
Solved by @maffblaster and @wivaku solution
Please fix this issue as this is not uncommon
Mind to share the complete stack trace?
I don't have the logs any more
@kesselb if it's still useful, this is the full stack trace I received with this same error. Adding the workaround mentioned above also worked for me too, although it feels a bit ... kludgy.
Edit: Converting from mariadb 10 --> pgsql 13 Nextcloud: 21.0 OS: Ubuntu 20.04 Web: Apache 2.4.4, PHP 7.4.3
# php occ db:convert-type -vvv --port=5432 --password=<password> --clear-schema --all-apps pgsql ncadmin 127.0.0.1 nextcloud
Clearing schema in new database
Creating schema in new database
The following tables will not be converted:
oc_audioplayer_albums
...
oc_weather_config
Continue with the conversion (y/n)? [n] y
oc_files_trash
0/222 [>---------------------------] 0% < 1 sec/< 1 sec 44.5 MiB
In QuoteHelper.php line 62:
[InvalidArgumentException]
Only strings, Literals and Parameters are allowed
Exception trace:
at /srv/www/nextcloud/lib/private/DB/QueryBuilder/QuoteHelper.php:62
OC\DB\QueryBuilder\QuoteHelper->quoteColumnName() at /srv/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php:1072
OC\DB\QueryBuilder\QueryBuilder->addOrderBy() at /srv/www/nextcloud/core/Command/Db/ConvertType.php:350
OC\Core\Command\Db\ConvertType->copyTable() at /srv/www/nextcloud/core/Command/Db/ConvertType.php:418
OC\Core\Command\Db\ConvertType->convertDB() at /srv/www/nextcloud/core/Command/Db/ConvertType.php:232
OC\Core\Command\Db\ConvertType->execute() at /srv/www/nextcloud/3rdparty/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /srv/www/nextcloud/3rdparty/symfony/console/Application.php:1009
Symfony\Component\Console\Application->doRunCommand() at /srv/www/nextcloud/3rdparty/symfony/console/Application.php:273
Symfony\Component\Console\Application->doRun() at /srv/www/nextcloud/3rdparty/symfony/console/Application.php:149
Symfony\Component\Console\Application->run() at /srv/www/nextcloud/lib/private/Console/Application.php:215
OC\Console\Application->run() at /srv/www/nextcloud/console.php:100
require_once() at /srv/www/nextcloud/occ:11
db:convert-type [--port PORT] [--password PASSWORD] [--clear-schema] [--all-apps] [--chunk-size CHUNK-SIZE] [--] <type> <username> <hostname> <database>
OP's workaround worked for me. Submitted pull request.
As maffblaster, this issue affected me when attempting to convert the standard sqlite database to mariadb 10.5. However different environment:
Nextcloud version: 21.0.1 Operating system: FreeBSD 12.2-RELEASE-p3 amd64 Apache version: apache24-2.4.46_2 PHP version: 7.4
The inserted "if" on line 57 of QuoteHelper.php seems to fix the problem.