GithubHelp home page GithubHelp logo

activerecord-hackery / meta_where Goto Github PK

View Code? Open in Web Editor NEW
590.0 590.0 37.0 345 KB

ActiveRecord 3 query syntax on steroids. Not currently maintained.

Home Page: http://erniemiller.org/2013/11/17/anyone-interested-in-activerecord-hackery/

License: MIT License

Ruby 100.00%

meta_where's People

Contributors

bcardarella avatar fonsan avatar joerixaop avatar scarroll32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

meta_where's Issues

Doesn't work on group method

Hi ernie,

I'm trying to use "meta where style" on group method but this doesn't work.

ruby-1.9.2-p180 :001 > Person
 => Person(id: integer, name: string)
ruby-1.9.2-p180 :002 > Patient.joins(:person).group(:person => :id).debug_sql
 => "SELECT \"patients\".* FROM \"patients\" INNER JOIN \"people\" ON \"people\".\"id\" = \"patients\".\"person_id\" GROUP BY '--- \n:person: :id\n'"

Doesn't have support or it's an issue?

Rails 3.0.7 with PostgreSQL
MetaWhere 1.0.4

Cheers

Issues with eager loading

I'm having problems with this gem and nested fields. When rails queries the object that's loaded into a fields_for it comes back with the association class instead of the model class.

I think that this may be related to what the fields_for_nested_model function is getting back when it calls object.to_model on the association.

Support for column calculations?

Not sure if I'm missing something or just can't figure it out, but I'm trying to create a where clause in MetaWhere that finds what I call "odometer entries" whose distance is within 250 of a "reminder." Here's what I tried to do, but it doesn't work:

.where(
        {
          :next_occurrence_at.gte => Time.current.beginning_of_day, :next_occurrence_at.lte => 2.weeks.from_now.end_of_day
        } |
        {
          :odometer_entries => {
            :distance.gte => (:next_occurrence_distance - 250)
          }
        }
      )

Does MetaWhere support something like this? I can't find anything similar in the examples or unit tests..

Can't use an '|' (and) when doing query with two polymorphic accociations

Hi I'm using rails 3.07 and meta_where 1.0.4

When I do this: Seller.joins(:phones, :emails).where(:phones => {:phone_number => ['342737153', '24325124']}, :emails => {:email_address => ['[email protected]']}).to_sql Everything is OK:

=> "SELECT "sellers".* FROM "sellers" INNER JOIN "phones" ON "phones"."phoneable_id" = "sellers"."id" AND "phones"."phoneable_type" = 'Seller' INNER JOIN "emails" ON "emails"."emailable_id" = "sellers"."id" AND "emails"."emailable_type" = 'Seller' WHERE (("phones"."phone_number" IN ('342737153', '24325124') AND "emails"."email_address" IN ('[email protected]')))"

But when I do this: Seller.joins(:phones, :emails).where(:phones => {:phone_number => ['342737153', '24325124']}, :emails => {:email_address => ['[email protected]']}).to_sql I get an error:

=> "SELECT "sellers".* FROM "sellers" INNER JOIN "phones" ON "phones"."phoneable_id" = "sellers"."id" AND "phones"."phoneable_type" = 'Seller' INNER JOIN "emails" ON "emails"."emailable_id" = "sellers"."id" AND "emails"."emailable_type" = 'Seller' WHERE (("phones"."phone_number" IN ('342737153', '24325124') AND "emails"."email_address" IN ('[email protected]')))"
ruby-1.9.2-p180 :040 > Seller.joins(:phones, :emails).where(:phones => {:phone_number => ['342737153', '24325124']} | :emails => {:email_address => ['[email protected]']}).to_sql
SyntaxError: (irb):40: syntax error, unexpected tASSOC, expecting ')'
...153', '24325124']} | :emails => {:email_address => ['example...
... ^
(irb):40: syntax error, unexpected ')', expecting $end
...ss => ['[email protected]']}).to_sql
... ^
from /Users/nielskristianschjoedt/.rvm/gems/ruby-1.9.2-p180@autouncle/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in start' from /Users/nielskristianschjoedt/.rvm/gems/ruby-1.9.2-p180@autouncle/gems/railties-3.0.7/lib/rails/commands/console.rb:8:instart'
from /Users/nielskristianschjoedt/.rvm/gems/ruby-1.9.2-p180@autouncle/gems/railties-3.0.7/lib/rails/commands.rb:23:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'
ruby-1.9.2-p180 :041 >

I can't figure out why I'm not able to do the last thing - could his be due to a bug?

using meta_where with new ruby 1.9 symbol setter

(sorry for the weird title, not sure how it's called)

In Ruby 1.9 we can now use title: "my title" instead of :title => "my title", I was in the process of modifying my code when I cam across some meta_where queries. Is there a way to get the same results with meta_where and the new syntax?

Like: :title.eq => "my title" becomes title.eq: "my title" or title:.eq "my title"

The code looks kind of weird this way, so I guess we can't (yet)? Any insight in how to tackle this once :symbol => "x" is removed from the Ruby language (if and when that happens)?

Thanks.

Does not work on Rails 3.1

Bundler could not find compatible versions for gem "arel":
  In Gemfile:
    meta_where depends on
      arel (~> 1.0.0.rc1)

    rails (= 3.1.0) depends on
      arel (2.2.1)

Maybe you should use arel 2.2?

Symbol in hash is not converted to Arel::Attribute

This may just be me being dense, but I'm having trouble getting Metawhere to look at other column values in the same row during a comparison. I'm using 1.0.4

The query I am running is ParentChildRelationship.where(:parent_id => :child_id)

The generated SQL is:

SELECT "parent_child_relationships".* FROM "parent_child_relationships" WHERE "parent_child_relationships"."parent_id" = 'child_id'

I expect to get something like

SELECT "parent_child_relationships".* FROM "parent_child_relationships" WHERE "parent_child_relationships"."parent_id" = "parent_child_relatinoships"."child_id"

I believe the problem lies in the Hash predicate visitor function, specifically in that the "value" side of the hash never appears to be converted into a Arel::Attribute. This is a reasonably clean rails app, in that the only additional gems activated are meta_where, jquery and sqlite3 are enabled.

predicates = [
  Arel:Node::Equality
    @left = Arel::Atribute::Integer #<struct ... >
    @right = :child_id
]


1 Current /Volumes/Sites/meta_where/lib/meta_where/visitors/predicate.rb:54
2 /Volumes/Sites/meta_where/lib/meta_where/visitors/visitor.rb:43
3 /Volumes/Sites/meta_where/lib/meta_where/visitors/visitor.rb:29
4 /Volumes/Sites/meta_where/lib/meta_where/relation.rb:257
5 /Volumes/Sites/meta_where/lib/meta_where/relation.rb:157
6 /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-3.0.10/lib/active_record/relation/query_methods.rb:149
7 /opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-3.0.10/lib/active_record/relation.rb:321
8 /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.10/lib/rails/commands/runner.rb:4
9 /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.10/lib/rails/commands.rb:48
10 /Volumes/Sites/agrport/script/rails:39
11 /Volumes/Sites/agrport/script/rails:6

uninitialized constant Arel::Attributes::Attribute::Predications in Ruby 1.9.2/Rails 3.1

I get the following error when I try to run Rails after bundle installing meta_where from rubyforge...

/Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/meta_where-0.5.2/lib/core_ext/symbol.rb:2:in <class:Symbol>': uninitialized constant Arel::Attributes::Attribute::Predications (NameError) from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/meta_where-0.5.2/lib/core_ext/symbol.rb:1:in<top (required)>'
from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/meta_where-0.5.2/lib/meta_where.rb:22:in require' from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/meta_where-0.5.2/lib/meta_where.rb:22:in<top (required)>'
from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/bundler-1.0.14/lib/bundler/runtime.rb:68:in require' from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/bundler-1.0.14/lib/bundler/runtime.rb:68:inblock (2 levels) in require'
from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/bundler-1.0.14/lib/bundler/runtime.rb:66:in each' from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/bundler-1.0.14/lib/bundler/runtime.rb:66:inblock in require'
from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/bundler-1.0.14/lib/bundler/runtime.rb:55:in each' from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/bundler-1.0.14/lib/bundler/runtime.rb:55:inrequire'
from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/bundler-1.0.14/lib/bundler.rb:120:in require' from /Users/sam/haystash/config/application.rb:7:in<top (required)>'
from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/railties-3.1.0.rc1/lib/rails/commands.rb:52:in require' from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/railties-3.1.0.rc1/lib/rails/commands.rb:52:inblock in <top (required)>'
from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/railties-3.1.0.rc1/lib/rails/commands.rb:49:in tap' from /Users/sam/.rvm/gems/ruby-1.9.2-p180@railspre/gems/railties-3.1.0.rc1/lib/rails/commands.rb:49:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'

Meta Where Breaks mongoid

I am pretty sure it has to do with the conditional hashes themselves. Mongoid has conditional hashes also and somewhere they clash. I will see if I can dig deeper if I have the time.

meta_where slows project down extremely

We have ~ 965 rspec tests in a project. Without metawhere the rspecs run in ~ 6m30s. adding meta_where to the Gemfile (not using any features what so ever) the rspec run time jumped up to 50m.

Does meta_where 'LIKE' support MySQL and PostgreSQL?

My app is running on Heroku, which uses PostgreSQL, and as a result I have if statements that change my search queries from LIKE to ILIKE to maintain case-insensitivity.

Does meta_where change LIKE to ILIKE on its own, or is there a way to make it do this across the whole app depending on environment?

.count() not parsing MetaWhere::Function

First off, I love, love, love MetaWhere!

Second, I'm trying to return a count with groupings and SQL functions:

Client.select(:year[:date_of_birth].as('age')).group(:county, :age)

... works great. But adding .count to the end:

Client.select(:year[:date_of_birth].as('age')).group(:county, :age).count
SELECT COUNT(#<MetaWhere::Function:0x106fd0230>) AS count_metawhere_function_0x106fd0230, county AS county, age AS age FROM `clients` GROUP BY county,age

I've worked around it by using a COUNT() sql function in the select, but it's sloppier and forces me also to select the other fields and to do a map:

Client.select([
        :count[Client.arel_table[:client_id]].as(:client_count),
        :county,
        :year[:date_of_birth].as('age')
      ]).
      group(:county, :age).map {|c| [c.county, c.age, c.client_count]}

This works; I'm just wondering if I ran into a bug or I'm not using it right. Thanks!

default_scope is applied when scopes are chained from unscoped

I have this model:

class Category < ActiveRecord::Base
  default_scope where(:status => "Active").order(:classification, :name)
  scope :archived, where(:status => "Archived")
end

Category.unscoped.archived returns:

SELECT `categories`.* 
FROM `categories` 
WHERE `categories`.`status` = 'Active' AND `categories`.`status` = 'Archived' 
ORDER BY `categories`.`classification` ASC, `categories`.`name` ASC, `categories`.`classification` ASC, `categories`.`name` ASC

tested with Rails 3.0.6 and meta_where HEAD

latest documentation and examples?

Hello,

I am looking at the documentation Ii've come across for metawhere and gotten confused. Is this the most up to date, what is found on github?

I am having challenges, for example, determining if something is null or just over-all using the right format. For example, I tried:

t = Todo.where(:done_date.is_not_null => true)

That looks like what the syntax should be but it's not clear from the examples. The only one that seems to work for me is null, but I'm guessing that there are probably alot of other WHERE's we can use?

Thanks

The name 'squeel' is kind of lame.

(This is opinion.)

So I was talking to the rest of my team about the new version of metawhere, which is called "squeel". The moment I mentioned the name, everyone started laughing, somewhat derisively.. My friend says, "It'll go great with HAML!"

Ok, that was kind of funny. But, honestly, being a little embarrassed about the name actually makes me slightly less likely to use it. Even though I've used metawhere and I know the quality of Ernie's code and dedication to making the plugin awesome is completely top-notch. I thought Metawhere was really a kickass name.

I strongly encourage a Metawhere 2.0... I'll probably keep using the plugin regardless of what it's called, but if I was a new user perusing options, I'd probably just pass Squeel right over because it just sounds kind of lame.

(end opinion)

Not In clause not working as expected

Given posts with ids [1,2,3]
When I do
Post.where(:id.not_in => [])
I expect result to be [1,2,3].

The current generated query is
SELECT posts.* FROM posts WHERE posts.id NOT IN (NULL)

Which returns [].
So, Post where id is not in empty array returns instead of all posts .. an empty array.

Problem when merging scopes and ordering via associations

First of all, I would like to express my love for meta_where. I switched it off for debugging this issue and realized how more elegant is the syntax and the power it adds to AR.

Enhanced order clauses break when merged from associations

class ToyBrand < ActiveRecord::Base
  belongs_to :manu
  has_many :toys
  scope :meta_order, joins(:manu).order({:manu => :name}, :name) #works if called directly, not when merged
  scope :join_order, joins(:manu).order('manus.name, toy_brands.name')  #this does direct and merged
end

ToyBrand.meta_order #works

class Toy < ActiveRecord::Base
  belongs_to :toy_brand

  scope :order_via_meta, joins(:toy_brand).merge(ToyBrand.meta_order) # fails
 scope :order_via_string, joins(:toy_brand).merge(ToyBrand.join_order) # works
end

Toy.order_via_meta #fails

Related issue (due to AR)

See rails/rails#3002
With MetWhere active, the Toy.join_merge works!

In my test application everything works for this case. However, in my real application which is much more complicated, when I use the following scope:

class ShippingItem
   belongs_to :item_variant
   scope :ordering_test, joins(:item_variant).merge(ItemVariant.scoped)
end

like this:
Shipment.find(106).shipping_items.joins(:item_variant).ordering_test
I get:
MetaWhere::JoinDependency::ConfigurationError: Association named 'item_variants' was not found; perhaps you misspelled it?
.../meta_where-1.0.4/lib/meta_where/join_dependency.rb:26:in build_with_metawhere'When I call the same thing over the association like this, it works beautifully:Shipment.find(106).shipping_items.joins(:item_variant).merge(ItemVariant.scoped)`

I'm really puzzled by this. I tried every combination. I would like to encapsulate all sortings in the respective models so the controllers just call the scope containing the wanted sorting without seeing the implementation....

Thanks for the help,
gam

Rails 3.0.9 / meta_where 1.0.4 / Ruby 1.9.2

Conflict with Sequel

Hi there,
Is there any way to avoid meta_where conflicting with sequel?
They both seem to open Symbol for ordering for example. Any experience to have these two co-exist?

thanks!

Odd YAML output when passing to select()

Attempting to use the 'Intelligent hash condition mapping' I was trying to get the following SQL:

SELECT histories.*, count(*), sum(vendor_earnings) FROM `histories`

so I tried the following:

History.select( [ { :histories => '*' }, :count.func( '*' ), :sum.func( :vendor_earnings) ] ).to_sql

But it didn't work. Two things wrong as you can see in what it actually produced:

> History.select( [ {:histories => '*' }, :count.func( '*' ), :sum.func( :vendor_earnings) ] ).debug_sql
 => "SELECT '--- \\n:histories: \\\"*\\\"\\n', count('*'), sum(vendor_earnings) FROM `histories`" 

The two issues are

  1. '*' instead of just *
  2. The odd yaml

Its possible I'm just using MetaWhere for something its not designed for (select vs where) but its tantalisingly close to Just Working.

keyword "not" not working properly?

where(:photo_file_name => nil) works fine, but how to check for "not null"?

This is what i tried, but none works (throws exception when loading class):
where(:photo_file_name.not => nil)
where(:photo_file_name.not.eq => nil)

Thought I got it working with operators:
where(:photo_file_name ^ nil)

MetaWhere::Column instead of column name

I'm getting the following error:

ActiveRecord::StatementInvalid PGError: ERROR: column observations.#<MetaWhere::Column:0x0000010347dcf0> does not exist

The full SQL query it's attempting is:

 SELECT "observations".* FROM "observations" WHERE (("observations"."district_id" = 1) OR (("observations"."#<MetaWhere::Column:0x0000010347dcf0>" IN (4, 1)) OR (("observations"."teacher_id" = 12) OR ("observations"."observer_id" = 12))))

I'm using MetaWhere through CanCan, so I'm not sure where the issue is located, but the line of ruby producing the issue is in the Ability class for CanCan:

can :read, Observation, :school_id.in => user.schools_over_ids

If I comment that out, no error.

I'm happy to take the issue over to CanCan if needed, but figured I'd start here. Any insights into further diagnosis would be awesome.

stange error when using meta_where

I'm using ruby 1.9.2-head and rails3.0 beta3. When adding meta_where to my gemfile I cannot start the server nor the console. The output is like:

$ rails c

.rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp/response.rb:70:in block in <class:Response>': undefined methoddowncase' for nil:NilClass (NoMethodError)
from .rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp/response.rb:68:in each' from .rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp/response.rb:68:ininject'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp/response.rb:68:in <class:Response>' from .rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp/response.rb:16:inmodule:SFTP'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp/response.rb:3:in <module:Net>' from .rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp/response.rb:3:in<top (required)>'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inblock in require'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:in block in load_dependency' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:523:innew_constants_in'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:in load_dependency' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inrequire'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp/request.rb:2:in <top (required)>' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inrequire'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in block in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:inblock in load_dependency'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:523:in new_constants_in' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:inload_dependency'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp/session.rb:5:in<top (required)>'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inblock in require'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:in block in load_dependency' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:523:innew_constants_in'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:in load_dependency' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inrequire'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/net-sftp-2.0.4/lib/net/sftp.rb:2:in <top (required)>' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inrequire'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in block in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:inblock in load_dependency'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:523:in new_constants_in' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:inload_dependency'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/capistrano-2.5.18/lib/capistrano/transfer.rb:2:in<top (required)>'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inblock in require'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:in block in load_dependency' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:523:innew_constants_in'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:in load_dependency' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inrequire'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/capistrano-2.5.18/lib/capistrano/configuration/actions/file_transfer.rb:1:in <top (required)>' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inrequire'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in block in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:inblock in load_dependency'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:523:in new_constants_in' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:inload_dependency'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/capistrano-2.5.18/lib/capistrano/configuration.rb:12:in<top (required)>'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inblock in require'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:in block in load_dependency' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:523:innew_constants_in'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:195:in load_dependency' from .rvm/gems/ruby-1.9.2-head@rails3/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:inrequire'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/capistrano-2.5.18/lib/capistrano.rb:1:in <top (required)>' from .rvm/gems/ruby-1.9.2-head@rails3/gems/bundler-0.9.25/lib/bundler/runtime.rb:46:inrequire'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/bundler-0.9.25/lib/bundler/runtime.rb:46:in block (2 levels) in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/bundler-0.9.25/lib/bundler/runtime.rb:41:ineach'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/bundler-0.9.25/lib/bundler/runtime.rb:41:in block in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/bundler-0.9.25/lib/bundler/runtime.rb:40:ineach'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/bundler-0.9.25/lib/bundler/runtime.rb:40:in require' from .rvm/gems/ruby-1.9.2-head@rails3/gems/bundler-0.9.25/lib/bundler.rb:89:ingem_require'
from Coding/projects/gimy/config/application.rb:7:in <top (required)>' from Coding/projects/gimy/config/environment.rb:2:inrequire'
from Coding/projects/gimy/config/environment.rb:2:in <top (required)>' from .rvm/gems/ruby-1.9.2-head@rails3/gems/railties-3.0.0.beta3/lib/rails/commands.rb:33:inrequire'
from .rvm/gems/ruby-1.9.2-head@rails3/gems/railties-3.0.0.beta3/lib/rails/commands.rb:33:in <top (required)>' from script/rails:9:inrequire'
from script/rails:9:in `

'

Without having meta_where in the gemfile my app works without any problems.

AREL merge (&) causes redundant joins

Without meta_where:

> (UserVote.joins(:user) & User.verified).to_sql
=> "SELECT `votes`.* FROM `votes` INNER JOIN `users` ON `users`.`id` = `votes`.`user_id` WHERE `votes`.`type` = 'UserVote' AND (verified_at is not null)"

With meta_where:

> (UserVote.joins(:user) & User.verified).to_sql
=> "SELECT `votes`.* FROM `votes` INNER JOIN `users` ON `users`.`id` = `votes`.`user_id` INNER JOIN `users` `voting_users_votes` ON `voting_users_votes`.`id` = `votes`.`user_id` WHERE `votes`.`type` = 'UserVote' AND (verified_at is not null)"

MetaWhere breaks creating new objects from scopes

MetaWhere seems to break creating new objects from scopes:

class Foo < ActiveRecord::Base
  scope :bar, where(:baz => 'pelle')
end

# Without MetaWhere

Foo.bar.build
=> #<Foo id: nil, baz: "pelle">

# With MetaWhere

Foo.bar.build
=> #<Foo id: nil, baz: nil>

Can't be used with latest meta_search under Rails 3.1.

This is really unfortunate, two of my favorite gems!

Bundler could not find compatible versions for gem "arel":
  In Gemfile:
    meta_where (~> 1.0.4) depends on
      arel (~> 2.0.7)

    meta_search (~> 1.1.0.pre2) depends on
      arel (2.1.4)

operator_overload! breaks symbol =~

If I use MetaWhere.operator_overload! then Symbol's regex operator (=~) breaks.

Stock Ruby behavior:

$ irb
ruby-1.9.2-p180 :001 > :hello =~ /blah/
 => nil 
ruby-1.9.2-p180 :002 > :hello =~ /ell/
 => 1 

Rails with MetaWhere.operator_overload! :

$ rails c
Loading development environment (Rails 3.0.6)
ruby-1.9.2-p180 :001 > :hello =~ /blah/
 => #<MetaWhere::Condition:0xabe11d0 @column=:hello, @value=/blah/, @method="matches"> 
ruby-1.9.2-p180 :002 > :hello =~ /ell/
 => #<MetaWhere::Condition:0xabdec3c @column=:hello, @value=/ell/, @method="matches"> 

This might be "works as designed" but it should probably be documented at least.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.