server icon indicating copy to clipboard operation
server copied to clipboard

Error converting psql DB to mariadb: QuoteHelper.php line 62: Only strings, Literals and Parameters are allowed

Open wivaku opened this issue 5 years ago • 9 comments

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)

wivaku avatar Mar 12 '21 11:03 wivaku

@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.

enoch85 avatar Mar 12 '21 13:03 enoch85

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.

dataCore avatar Mar 17 '21 22:03 dataCore

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();
}

maffblaster avatar Mar 22 '21 19:03 maffblaster

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

n0k0m3 avatar Mar 30 '21 01:03 n0k0m3

Mind to share the complete stack trace?

kesselb avatar Mar 30 '21 13:03 kesselb

I don't have the logs any more

n0k0m3 avatar Apr 02 '21 21:04 n0k0m3

@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>

ramebd avatar Apr 07 '21 13:04 ramebd

OP's workaround worked for me. Submitted pull request.

hankjordan avatar May 01 '21 21:05 hankjordan

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.

elnicko avatar May 14 '21 18:05 elnicko