Skip to content

Instantly share code, notes, and snippets.

@ahoward

ahoward/3.1.6.txt

Last active Aug 29, 2015
Embed
What would you like to do?
a:~/git/mongoid/mongoid $ ruby -r mongoid ~/a.rb
3.1.6
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (0.7300ms)
MOPED: 127.0.0.1:27017 COMMAND database=test command={:count=>"tables", :query=>{}} (0.2592ms)
MOPED: 127.0.0.1:27017 INSERT database=test collection=rooms documents=[{"_id"=>"5361d11faf481ca059000001"}] flags=[] (0.0758ms)
MOPED: 127.0.0.1:27017 INSERT database=test collection=tables documents=[{"_id"=>"5361d11faf481ca059000002", "parent_id"=>"5361d11faf481ca059000001", "parent_type"=>"Room"}] flags=[] (0.1209ms)
MOPED: 127.0.0.1:27017 QUERY database=test collection=tables selector={:_id=>"5361d11faf481ca059000002"} flags=[] limit=-1 skip=0 batch_size=nil fields=nil (0.2699ms)
MOPED: 127.0.0.1:27017 UPDATE database=test collection=tables selector={"_id"=>"5361d11faf481ca059000002"} update={"$push"=>{"chairs"=>{"_id"=>"5361d11faf481ca059000003"}}} flags=[] (0.0961ms)
MOPED: 127.0.0.1:27017 UPDATE database=test collection=tables selector={"_id"=>"5361d11faf481ca059000002"} update={"$push"=>{"chairs"=>{"_id"=>"5361d11faf481ca059000004"}}} flags=[] (0.0648ms)
MOPED: 127.0.0.1:27017 UPDATE database=test collection=tables selector={"_id"=>"5361d11faf481ca059000002"} update={"$push"=>{"chairs"=>{"_id"=>"5361d11faf481ca059000005"}}} flags=[] (0.0629ms)
MOPED: 127.0.0.1:27017 UPDATE database=test collection=tables selector={"_id"=>"5361d11faf481ca059000002"} update={"$push"=>{"chairs"=>{"_id"=>"5361d11faf481ca059000006"}}} flags=[] (0.0632ms)
MOPED: 127.0.0.1:27017 COMMAND database=test command={:count=>"tables", :query=>{}} (0.2232ms)
MOPED: 127.0.0.1:27017 QUERY database=test collection=tables selector={"_id"=>"5361d11faf481ca059000002"} flags=[:slave_ok] limit=0 skip=0 batch_size=nil fields=nil (0.1700ms)
yesssssss!
a:~/git/mongoid/mongoid $ ruby -I lib -r mongoid ~/a.rb
4.0.0.beta1
D, [2014-04-30T22:43:44.135185 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} runtime: 0.8710ms
D, [2014-04-30T22:43:44.135569 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 COMMAND database=test command={:count=>"tables", :query=>{}} runtime: 0.2440ms
D, [2014-04-30T22:43:44.140600 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 INSERT database=test collection=rooms documents=[{"_id"=>BSON::ObjectId('5361d100612e6ce3a7000000')}] flags=[]
D, [2014-04-30T22:43:44.140687 #58279] DEBUG -- : COMMAND database=test command={:getlasterror=>1, :w=>1} runtime: 2.5050ms
D, [2014-04-30T22:43:44.142848 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 INSERT database=test collection=tables documents=[{"_id"=>BSON::ObjectId('5361d100612e6ce3a7010000'), "parent_id"=>BSON::ObjectId('5361d100612e6ce3a7000000'), "parent_type"=>"Room"}] flags=[]
D, [2014-04-30T22:43:44.142894 #58279] DEBUG -- : COMMAND database=test command={:getlasterror=>1, :w=>1} runtime: 0.5700ms
D, [2014-04-30T22:43:44.143432 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 QUERY database=test collection=tables selector={:_id=>BSON::ObjectId('5361d100612e6ce3a7010000')} flags=[] limit=-1 skip=0 batch_size=nil fields=nil runtime: 0.2260ms
D, [2014-04-30T22:43:44.144747 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 UPDATE database=test collection=rooms selector={"_id"=>BSON::ObjectId('5361d100612e6ce3a7010000')} update={"$push"=>{"chairs"=>{"_id"=>BSON::ObjectId('5361d100612e6ce3a7020000')}}} flags=[]
D, [2014-04-30T22:43:44.144792 #58279] DEBUG -- : COMMAND database=test command={:getlasterror=>1, :w=>1} runtime: 0.3420ms
D, [2014-04-30T22:43:44.145550 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 UPDATE database=test collection=rooms selector={"_id"=>BSON::ObjectId('5361d100612e6ce3a7010000')} update={"$push"=>{"chairs"=>{"_id"=>BSON::ObjectId('5361d100612e6ce3a7030000')}}} flags=[]
D, [2014-04-30T22:43:44.145588 #58279] DEBUG -- : COMMAND database=test command={:getlasterror=>1, :w=>1} runtime: 0.3330ms
D, [2014-04-30T22:43:44.146101 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 UPDATE database=test collection=rooms selector={"_id"=>BSON::ObjectId('5361d100612e6ce3a7010000')} update={"$push"=>{"chairs"=>{"_id"=>BSON::ObjectId('5361d100612e6ce3a7040000')}}} flags=[]
D, [2014-04-30T22:43:44.146139 #58279] DEBUG -- : COMMAND database=test command={:getlasterror=>1, :w=>1} runtime: 0.2130ms
D, [2014-04-30T22:43:44.146640 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 UPDATE database=test collection=rooms selector={"_id"=>BSON::ObjectId('5361d100612e6ce3a7010000')} update={"$push"=>{"chairs"=>{"_id"=>BSON::ObjectId('5361d100612e6ce3a7050000')}}} flags=[]
D, [2014-04-30T22:43:44.146677 #58279] DEBUG -- : COMMAND database=test command={:getlasterror=>1, :w=>1} runtime: 0.2010ms
D, [2014-04-30T22:43:44.147113 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 COMMAND database=test command={:count=>"tables", :query=>{}} runtime: 0.1690ms
D, [2014-04-30T22:43:44.147605 #58279] DEBUG -- : MOPED: 127.0.0.1:27017 QUERY database=test collection=tables selector={"_id"=>BSON::ObjectId('5361d100612e6ce3a7010000')} flags=[] limit=0 skip=0 batch_size=nil fields=nil runtime: 0.1630ms
blurghy!
#require 'mongoid'
Mongoid.configure do |config|
config.connect_to('test')
end
class Room
include Mongoid::Document
has_one :table, as: :parent, autobuild: true
after_create :ensure_table
def ensure_table
table.save!
end
end
class Table
include Mongoid::Document
belongs_to :parent, polymorphic: true
embeds_many :chairs
end
class Chair
include Mongoid::Document
embedded_in :table
end
puts Mongoid::VERSION
logger = Logger.new(STDERR)
Mongoid.logger = logger
Moped.logger = logger
n = Table.count
m = 4
@room = Room.create!
@table = @room.table
@table.reload
m.times{ @table.chairs << Chair.new }
abort 'blargh' unless(Table.count == n + 1)
abort 'blurgh' unless(@table.chairs.size == m)
abort 'blurghy!' unless(Table.find(@table.id).chairs.size == m)
puts 'yesssssss!'
@ryana

This comment has been minimized.

Copy link

@ryana ryana commented May 1, 2014

Yeah this fails on 4.0.0.beta1. Must be an issue there.

ra:app(mention) ryan$ be ruby hrmph.rb 
blurghy!
ra:app(mention) ryan$ be gem list | grep mong
carrierwave-mongoid (0.7.0)
mongo_session_store-rails4 (5.0.1)
mongoid (4.0.0.beta1)
mongoid-embedded-errors-messages (2.0.1)
mongoid-grid_fs (1.9.2)
ra:app(mention) ryan$ 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment