0

Is it possible to use LIKE keyword and where_properties function together or something similar. Because i need to create query like this.

Ahoy::Event.where(name: "$click").where_properties("'href' LIKE '%#{brochure.id}%'").count.size
Emre
  • 119
  • 2
  • 8
  • Hi Emre, please try this: Ahoy::Event.where(name: "$click").where("properties -> 'href' like '%#{brochure.id}%'") – Anton Nov 13 '17 at 08:14
  • What is the column type for properties? This is actually extremely important when it comes to `#where_properties` as is evident in [`Ahoy::Properties::ClassMethods#where_properties`](https://github.com/ankane/ahoy/blob/master/lib/ahoy/properties.rb) – engineersmnky Nov 13 '17 at 14:48

1 Answers1

0

please try this:

 Ahoy::Event.where(name: "$click").where("properties ->> :key LIKE :value", key: "href", value: "%#{brochure.id}%").size

fix the query now works as expected.

Emre
  • 119
  • 2
  • 8
Anton
  • 540
  • 3
  • 13