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 converting psql DB to mariadb: QuoteHelper.php line 62: Only strings, Literals and Parameters are allowed #26085

Closed
wivaku opened this issue Mar 12, 2021 · 9 comments · Fixed by #27429
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Milestone

Comments

@wivaku
Copy link

wivaku commented Mar 12, 2021

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)

@enoch85 enoch85 added the bug label Mar 12, 2021
@enoch85
Copy link
Member

enoch85 commented Mar 12, 2021

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

@dataCore
Copy link

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.

@skjnldsv skjnldsv added the 0. Needs triage Pending check for reproducibility or if it fits our roadmap label Mar 22, 2021
@maffblaster
Copy link

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

@n0k0m3
Copy link

n0k0m3 commented Mar 30, 2021

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

@kesselb
Copy link
Contributor

kesselb commented Mar 30, 2021

Mind to share the complete stack trace?

@n0k0m3
Copy link

n0k0m3 commented Apr 2, 2021

I don't have the logs any more

@ramebd
Copy link

ramebd commented Apr 7, 2021

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

@hankjordan
Copy link

hankjordan commented May 1, 2021

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

hankjordan added a commit to hankjordan/server that referenced this issue May 1, 2021
Signed-off-by: Henry Jordan <hank@henryjordan.com>
hankjordan added a commit to hankjordan/server that referenced this issue May 1, 2021
@solracsf solracsf linked a pull request May 3, 2021 that will close this issue
@elnicko
Copy link

elnicko commented May 14, 2021

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.

kesselb added a commit that referenced this issue Jun 8, 2021
addOrderBy expects a order expression. For the migration scenario we have column objects. Column objects are not supported by quoteColumnName yet.

A column object as order expression is most likely an edgy thing when migration database information.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
backportbot-nextcloud bot pushed a commit that referenced this issue Jun 9, 2021
addOrderBy expects a order expression. For the migration scenario we have column objects. Column objects are not supported by quoteColumnName yet.

A column object as order expression is most likely an edgy thing when migration database information.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
@MorrisJobke MorrisJobke added this to the Nextcloud 22 milestone Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet