Skip to content

Instantly share code, notes, and snippets.

View johnbender's full-sized avatar

John Bender johnbender

View GitHub Profile
module ActiveRecord
class Base
def Base.where(*args, &block)
#yielding the block will alter the Operations class
yield
#record altered conditions and values
conditions = ::RedQuery::Serializers::Operations.to_sql
values = ::RedQuery::Serializers::Operations.values
/Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:416:in `initialize_database': undefined method `configurations=' for ActiveRecord::Base:Class (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:141:in `process'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in `send'
from /Library/Ruby/Gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in `run'
from /Users/johnbender/Sites/happenings/config/environment.rb:17
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
# Be sure to restart your server when you modify this file
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
ENV['GEM_PATH'] = '/usr/lib/ruby/gems/1.8:/home/tchob/.gem/ruby/1.8:/Library/Ruby/Gems/1.8:/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
# Be sure to restart your server when you modify this file
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
ENV['GEM_PATH'] = '/usr/lib/ruby/gems/1.8:/home/tchob/.gem/ruby/1.8:/Library/Ruby/Gems/1.8:/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
module RedQuery
module ActiveRecord
@@where_mutex = Mutex.new
def where(*args, &block)
#establish scope for conditions
conditions = nil
#make sure only one thread at a time is altering the class
#variables inside RedQuery::Serializers::Operations
#Users who's last logon was in '05
#ActiveRecord
User.find(:all, :conditions => ["last_logon between ? and ?", "2005-01-01", "2005-12-31"])
#rquery
User.where {
:last_logon.between "2005-01-01", "2005-12-31"
}
#where :foo is a column of some table
ActiveRecord::Base.where{
:foo.is == "bar"
:foo.is > 1
:foo.is < 2
:foo.is >= 3
:foo.is <= 4
:foo.contains "bar"
:foo.between 10..20
:foo.from 10, 20
ActiveRecord::Base.where{
:foo.is_not == "bar"
:foo.is_not.between 10..20
:foo.is_not.from 10, 20
:foo.is_not.in 1,2,3,4,5
}
ActiveRecord::Base.where{
:foo.is_not == "bar"
:foo.is_not.between 10..20
:foo.is_not.from 10, 20
:foo.is_not.in 1,2,3,4,5
}