'number of bound variables does not match number of tokens' error for representative node relation

Created on 19 August 2014, over 10 years ago
Updated 20 January 2025, 1 day ago

Setup:
- create a taxonomy 'Product'
- create a content type 'Installer' with the following extra fields:
'Product' as Taxonomy reference to 'product'
'Version' as Text
'Released' as Date
- add some samples (multiple products and version)
- create a view that contains each item from the 'Product' taxonomy
- add a 'Representative node' relation with the 'Installer' content type that sorts the nodes on the 'Released' field and selects the latest
- add the version and released fields from the representative node relation to the view fields

This should give you a view which presents the latest version of all products.
However sometimes this view is empty and when editing the view the preview gives the following error:

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

I tracked this down to a part in the code that creates a temporary view and returns the resulting query as a string, not taking into account that views can create queries with arguments.

Attached is a patch to replace the arguments in the sql string with their actual values. Since the query isn't saved and executed multiple times, I don't think it's worth changing the interface to return both the sql and the arguments (and somehow ensure that the arguments remain unique). However feel free to change this.

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

views.module

Created by

πŸ‡§πŸ‡ͺBelgium Bram Tassyns

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Tried to follow the steps but not sure I'm able to replicate or don't fully understand the issue.

    Can the issue summary be cleaned up to include clear steps for how to replicate in D11.

    If no update in 3 months this could be closed out.

    Thanks

Production build 0.71.5 2024