Hi there

I can't for the life of me work out how to limit the index based on a
HABTM association. My scenario:

Product has_and_belongs_to_many :suppliers
Supplier has_and_belongs_to_many :products

I'm trying to create an attribute that contains
product.suppliers.count but it wont play nicely with me.

This is what I am trying:

has "count(DISTINCT products.id) AS count_distinct_products_id FROM
'products' INNER JOIN 'products_suppliers' ON
'products_suppliers'.product_id = 'products'.id INNER JOIN 'suppliers'
ON 'suppliers'.id = 'products_suppliers'.supplier_id", :as
=> :supplier_count, :type => :integer

but I get a SQL error:

ERROR: index 'product_core': sql_range_query: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near ''products' INNER JOIN
'products_suppliers' ON 'products_suppliers'.product_id = ' at line 1

What would be the correct way to achieve this?

Any guidance would be appreciated.

Shaun
-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.


Reply via email to