#23 new
Kieran P

acts_as_taggable_on_steroids - 'order' parameter to tag_counts method

Reported by Kieran P | July 30th, 2008 @ 04:48 PM

sam writes:

The ‘order’ parameter to this vendor plugin makes some pretty bad assumptions.

First, it assumes that you can order by columns which weren’t in the original query, and makes no allowance for adding to the list of selected columns. Second, the example (which seems to be the one used) is ordering by a column which may have more than one value, which is entirely ambiguous.

Needless to say, Postgres refuses to answer this kind of rubbish. This is currently manifesting as a page error when creating a new Basket.

Anyway, the interface needs to change; it should accept information about what information is required and build an appropriate query.

Comments and changes to this ticket

  • Kieran P

    Kieran P July 30th, 2008 @ 04:48 PM

    same writes:

    note: by “more than one value” I mean that it is a column in a joined table, and the table isn’t a part of the GROUP BY clause. MySQL may be interpreting the “taggings.created_at” as “min(taggings.created_at)” or something like that.

  • Kieran P

    Kieran P July 30th, 2008 @ 04:49 PM

    walter writes:

    Hi Sam,

    Thanks for the input. If the bug is in that third party plugin, have you looked into whether you can report a bug on acts_as_taggable_on_steroids directly? Have you checked if a there is a later version of the plugin where this bug is fixed?

    Now, the Kete bug you are reporting is that with PostgreSQL, when a new basket is created you get an error. It sounds like you have tracked it back to this plugin… however, I’m not sure where you have received the error. Is it on the basket homepage which where is you would be directed to after you create the basket or before that on the create action (what processes new basket form).

    What revision of Kete are you running? You may be running something quite old at this point. We have split the tag cloud setting into a separate form for basket homepage options from the new basket form.

    Cheers,

    Walter

  • Kieran P

    Kieran P July 30th, 2008 @ 04:49 PM

    sam writes:

    Bug acknowledged upstream; Johnathan commented that this par for the course with Rails but would be willing to accept an adequate patch.

  • Kieran P

    Kieran P July 30th, 2008 @ 04:49 PM

    walter writes:

    Hi Sam,

    Thanks for contacting Johnathan. Just a heads up that we are super busy with big projects at the moment and don’t have the resources to support testing against another database. I’ve updated the Technical Requirements topic to make this more explicit:

    http://kete.net.nz/documentation...

    Please let me know if you create a patch for acts_as_taggable_on_steroids that fixes your problem and it is accepted. I’ll update Kete to use it as soon as I hear. I’m sorry we don’t have time to look into this right now.

    Cheers,

    Walter

  • Kieran P

    Kieran P July 30th, 2008 @ 04:49 PM

    walter writes:

    After reviewing what the code in question a little more, I have deciphered what “Johnathan commented that this par for the course with Rails” means.

    acts_as_taggable_on_steroids is processing it’s own specific arguments for its find method and then passing them to the standard ActiveRecord#find method. If there is an :order argument included by the calling code, it simply passes it along. In my view this means that acts_as_taggable_on_steroids is not at fault.

    In the grand scheme of things, Rails probably isn’t either. It seems to me that it would be a little tricky (or a performance drain) for the framework code to do enough self reflection on the call to prevent badly formed order by calls. Better to leave it the application developer(s) to fix their own code in this circumstance.

    So, the problem really is in Basket#tag_counts_array and how it sets up the arguments to tag_counts method.

    Here’s the relevant code from app/models/basket.rb:

    ...

    tag_order = nil

    case self.index_page_order_tags_by

    when ‘alphabetical’

    tag_order = ‘tags.name’

    when ‘latest’

    tag_order = ‘taggings.created_at desc’

    when ‘number’

    tag_order = ‘count desc’

    when ‘random’

    tag_order = ‘Rand()’

    end

    ...

    zoom_class_tag_counts = self.send(zoom_class.tableize).tag_counts(:limit => tag_limit, :order => tag_order)

    The Rand() function raises a red flag as being mysql specific. I have a db agnostic solution for getting random items implemented in another part of the code.

    Sam, if you could send a trace with the exact message that PG sends back as an error and what homepage options you have chosen when creating a new basket, that would be helpful. The idea being shaking out the specific options that are causing the error.

    Cheers,

    Walter

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Kete was developed by Horowhenua Library Trust and Katipo Communications Ltd. to build a digital library of Horowhenua material.

People watching this ticket

Pages