diff --git a/README.md b/README.md index 1975ce5..ddb9e97 100644 --- a/README.md +++ b/README.md @@ -187,13 +187,10 @@ predicate for the `&&` operator. ```ruby user_arel = User.arel_table -query = user_arel.where(user_arel[:tags].array_overlap(['one','two'])) - .project(Arel.sql('*')) -query.to_sql -# => SELECT \"users\".* FROM \"users\" WHERE \"users\".\"tags\" && '{one,two}' # Execute the query -User.find_by_sql(query.to_sql) +User.where(user_arel[:tags].array_overlap(['one','two'])) +# => SELECT \"users\".* FROM \"users\" WHERE \"users\".\"tags\" && '{one,two}' ``` #### ANY or ALL functions @@ -223,13 +220,10 @@ user_arel = User.arel_table any_tags_function = Arel::Nodes::NamedFunction.new('ANY', [user_arel[:tags]]) predicate = Arel::Nodes::Equality.new('test', any_tags_function) -query = user_arel.where(predicate).project(Arel.sql('*')) - -query.to_sql -#=> SELECT \"users\".* FROM \"users\" WHERE 'test' = ANY(\"users\".\"tags\") # Execute the query -User.find_by_sql(query.to_sql) +User.where(predicate) +#=> SELECT \"users\".* FROM \"users\" WHERE 'test' = ANY(\"users\".\"tags\") ``` The ALL version of this same predicate can be generated by swap `'ANY'` @@ -256,24 +250,22 @@ predicate for the `<<` operator. ```ruby user_arel = User.arel_table -query = user_arel.where(user_arel[:ip_address].contained_witin('127.0.0.1/24')) - .project(Arel.sql('*')) - -query.to_sql -# => SELECT \"users\".* FROM \"users\" WHERE \"users\".\"ip_address\" << '127.0.0.1/24' # Execute the query -User.find_by_sql(query.to_sql) +User.where(user_arel[:ip_address].contained_witin('127.0.0.1/24')) +# => SELECT \"users\".* FROM \"users\" WHERE \"users\".\"ip_address\" << '127.0.0.1/24' ``` ## Indexes ### Index types -Postgres\_ext allows you to specify an index type at index creation. +Postgres\_ext allows you to specify index type and index operator +class at index creation. ```ruby add_index :table_name, :column, :index_type => :gin +add_index :table_name, :column, :index_type => :gin, :index_opclass => :gin_trgm_ops ``` ### Where clauses