-
Type: Bug
-
Resolution: Won't Fix
-
Priority: Minor - P4
-
None
-
Affects Version/s: 6.4.1, 7.0.1
-
Component/s: None
-
None
-
Environment:ruby 2.3.1 / rails 5.2 / ubuntu latest / mongo latest / mongoid 7.0.1
Greetings,
I ran into a ActiveJob Serialization for a mongoid class that has it's roots here:
https://github.com/rails/rails/blob/5-2-stable/activejob/lib/active_job/arguments.rb#L59
The issue appears that while getting an document "directly" by asking for it by id, or creating it, the case statement in #59 works fine. If you ask for a document in-directly, such as by traveling though it's relationships, the case statement does not work.
FYI: the case/when statement uses a === for class comparisions
Following this issue, the code below produces the error:
Mongoid.load!("config/mongoid.yml", :development) class BaseDoc include Mongoid::Document include GlobalID::Identification has_one :child, class_name: 'ChildDoc', inverse_of: :parent field :data, type: String end class ChildDoc include Mongoid::Document include GlobalID::Identification belongs_to :parent, class_name: 'BaseDoc', inverse_of: :child, optional: true field :data, type: String end base = BaseDoc.create(data: 'dog') child = ChildDoc.create(data: 'cat') child.parent = base child.save puts "GlobalID::Identification === base is #\{GlobalID::Identification === base}" puts "GlobalID::Identification === child is #\{GlobalID::Identification === child}" base2 = ChildDoc.where(data: 'cat').first.parent puts "GlobalID::Identification === base2 is #\{GlobalID::Identification === base2}" puts "base2.is_a?(GlobalID::Identification) is #\{base2.is_a?(GlobalID::Identification)}"
The exciting part, is the 3rd "puts", which returns false.
As far as I can tell, the objects are identical.
Because GlobalID::Identification === base2 is false, the ActiveJob::Serializer will throw up an exception at line 59, which will not catch it for base2
I have this setup on a digitalocean machine, if you give me your public key, I can give you access to the machine and you can scratch your head too.
Regards,
Daniel Lo
config/mongoid.yml
development: clients: default: database: mongoid hosts: - localhost:27017
- is duplicated by
-
MONGOID-5087 Association Proxies `===` returns false on its modules
- Closed
-
MONGOID-5088 Check whether module included in association fails
- Closed
- is related to
-
MONGOID-4618 Make Mongoid compatible with GlobalID
- Closed
- related to
-
MONGOID-3909 Improve GlobalID::Identification usage with associations
- Backlog