Created
September 30, 2010 11:14
-
-
Save pedromg/604417 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'dm-core' | |
require 'dm-postgres-adapter' | |
require 'adapter.rb' # local; patched | |
require 'comparison.rb' # local; patched | |
require 'symbol.rb' | |
#require 'dm-migrations' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'postgres://user:password@localhost/database') | |
class Item | |
include DataMapper::Resource | |
property :id, Serial | |
property :kind, String | |
end | |
#DataMapper.auto_upgrade! | |
DataMapper.finalize | |
# DataMapper | |
# dm-postgres-adapter ILIKE patch | |
# | |
# To check for the Symbol class issue. | |
# This works: | |
# $ irb -r dm_pg_ilike_demo.rb | |
# irb> Item.create(:kind => "Product") | |
# irb> Item.all(:kind.like => "product").count # returns 0 | |
# irb> Item.all(:kind.ilike => "product").count # returns 1 | |
# | |
# Now, comment line #6 and run a new IRB session | |
# Rerun the code above and ilike will return an error. | |
# Now, still in IRB require symbol.rb, and the code will work. | |
# Symbol class must be loaded after requiring adapter.rb and comparison.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment