Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Articles breaks search function

This discussion is related to the Articles addon.
rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one"NY ✭✭✭

Running Vanilla 2.1.11 and the Articles application the builtin search breaks.
This is what error i'm getting when i use the search function:
"PDO Statement failed to prepare|Gdn_Database|Query|The used SELECT statements have a different number of columns"

Search is functional as soon as I disable the Articles application.

Comments

  • ShadowdareShadowdare π Moderator
    edited July 2015

    Thanks for reporting this issue. I've just created an issue for this in the GitHub repo and will look into it. If this issue is present in the current development code, I'll look into getting a fix out in Articles v1.1.0.

    Add Pages to Vanilla with the Basic Pages app | Publish articles with the Articles app

    rbrahmsonhgtonight
  • ShadowdareShadowdare π Moderator
    edited July 2015

    Just fixed this bug.

    Apparently, SearchModel requires that search base queries, constructed in ArticleSearchModel within the ArticleSql and ArticleCommentSql methods, have the same number of columns for the SELECT statement as the numbers of columns that are selected in Vanilla's discussion and comment search queries. This is because SearchModel does a UNION of all the search queries, which requires the same number of columns for all SELECT statements that are unified.

    To fix this, I just added one more column to the SELECT statement in each of the methods.

    Whether this kind of restriction was foreseen and not desirable or is intended functionality, I have no idea.

    Add Pages to Vanilla with the Basic Pages app | Publish articles with the Articles app

    rbrahmsonhgtonightzapz
  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    Great! (And I don't refer to the way you were forced to fix this bug...)

  • @Shadowdare said:
    Just fixed this bug.

    Apparently, SearchModel requires that search base queries, constructed in ArticleSearchModel within the ArticleSql and ArticleCommentSql methods, have the same number of columns for the SELECT statement as the numbers of columns that are selected in Vanilla's discussion and comment search queries. This is because SearchModel does a UNION of all the search queries, which requires the same number of columns for all SELECT statements that are unified.

    To fix this, I just added one more column to the SELECT statement in each of the methods.

    Whether this kind of restriction was foreseen and not desirable or is intended functionality, I have no idea.

    Can you please explain how you did this step by step for a non-tech savy person ?

    Thx

  • @zapz I don't think he intended for non-technical people patch it, he merely explains why the bug occurs.

    Wait for a release.

    grep is your friend.

  • ShadowdareShadowdare π Moderator

    This has been fixed in Articles 1.1.1, which is available for download here: http://vanillaforums.org/addon/articles-application

    Add Pages to Vanilla with the Basic Pages app | Publish articles with the Articles app

    hgtonightBleistivt
  • Thank you Shadoware.

    I'm not sure why, but I am running the latest version and I get:

    PDO Statement failed to prepare|Gdn_Database|Query|The used SELECT statements have a different number of columns

  • ShadowdareShadowdare π Moderator
    edited July 2015

    @zapz, are you using Vanilla 2.1 or 2.2 beta? I guess that the fix I applied works in Vanilla 2.2 beta, but not Vanilla 2.1, due to the SELECT statement having a different number of columns. IIRC, I've tested the fix in Vanilla 2.1 as well, but it's been a while since I've checked.


    It seems like the UNION of SQL SELECT queries are problematic. I've been thinking of a solution for this if the UNIONs must be kept. An idea I had was for the SearchModel to get the counts of columns that are going to be selected in every SQL SELECT query that is passed in for the search feature.

    An algorithm can be coded to handle the different counts and select a null column (this would be the solution). If a UNION has a smaller count than the largest count, then it would concatenate enough null column selects to allow the UNION to work.

    Fellow developers, what are your thoughts on this?

    Add Pages to Vanilla with the Basic Pages app | Publish articles with the Articles app

    Bleistivt
  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    Far from being a developer, I wonder why this is not a built-in functions within the SQL database...

  • Wouldn't it be easier to have two versions of this plug-in since the number of columns to search on is different in Vanilla 2.1 and 2.2?

    For now, I am toying with the idea of disabling search as a forum tool in favor of offering Articles. In turn (and although it would require an additional log-in) I am thinking, too, of creating another program interface using same database, named "/myforum-search" that users could enter in order to search. In that interface, I will not have Articles active. I will add a menu item "Articles" that users would click on that take them back to other interface, requiring another log-in.

    So I really like this add-on! Thanks for making it. I am going to try to make it work for my site until this search issue is resolved. Meanwhile, I also sure wish I had skill to write a query that would rewrite its requests based on the number of columns in the table it is querying ...

  • It appears my solution above does not require an additional log-on.

Sign In or Register to comment.