Created
May 20, 2009 15:01
-
-
Save tpitale/114857 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
#!/usr/bin/env ruby | |
# | |
# A one file test to show ... | |
require 'rubygems' | |
require 'dm-core' | |
# setup the logger | |
DataMapper::Logger.new(STDOUT, :debug) | |
# connect to the DB | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Search | |
include DataMapper::Resource | |
property :id, Serial | |
end | |
class Result | |
include DataMapper::Resource | |
property :id, Serial | |
belongs_to :search | |
end | |
DataMapper.auto_migrate! | |
# play with this number, and watch the number of subsequent selects change | |
10.times do | |
Search.create | |
end | |
20.times do | |
if rand > 0.1 | |
Result.create(:search_id => rand(10)+1) | |
else | |
Result.create | |
end | |
end | |
puts "-"*80 | |
Result.all.each do |r| | |
puts r.search.inspect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment