Skip to content

Improve error message for (unsupported) named parameter usage #475

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

Open
JKDingwall opened this issue May 9, 2025 · 1 comment · May be fixed by #476
Open

Improve error message for (unsupported) named parameter usage #475

JKDingwall opened this issue May 9, 2025 · 1 comment · May be fixed by #476

Comments

@JKDingwall
Copy link

Lyrion Music Server added some new database queries using named parameters in the statement. This is supported by SQLite (via DBD-SQLite) but this is not available to DBD-mysql/MySQL (or MariaDB). When the query is executed the reported error is:

[25-05-02 18:47:27.2333] Slim::Schema::Storage::throw_exception (122) Error: DBI Exception: DBD::mysql::st bind_param failed: Illegal parameter number [for Statement "
                                        SELECT contributor_album.role AS role, contributors.name AS name, contributors.id AS id
                                        FROM contributor_album
                                        JOIN contributors ON contributors.id = contributor_album.contributor
                                        WHERE contributor_album.album = :album
                                        AND contributor_album.role IN (5,1)
                                        ORDER BY contributor_album.role, contributors.namesort
                                "]
[25-05-02 18:47:27.2343] Slim::Schema::Storage::throw_exception (122) Backtrace:

Full report: LMS-Community/slimserver#1265

It took a bit of digging to discover this. It seems possible to add a more helpful error message which turns the error in to:

    [25-05-06 20:46:04.2629] Slim::Schema::Storage::throw_exception (122) Error: DBI Exception: DBD::mysql::st bind_param failed: named parameters are unsupported: :album [for Statement "
                                            SELECT contributor_album.role AS role, contributors.name AS name, contributors.id AS id
                                            FROM contributor_album
                                            JOIN contributors ON contributors.id = contributor_album.contributor
                                            WHERE contributor_album.album = :album
                                            AND contributor_album.role IN (5,1)
                                            ORDER BY contributor_album.role, contributors.namesort
                                    "]

The change is based on the named parameter handling in DBD-SQLite: https://github.com/DBD-SQLite/DBD-SQLite/blob/60515b30f8b816cb09e9f40f2f0a5829af031899/dbdimp.c#L1559

@JKDingwall
Copy link
Author

Related PR: #476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant