{"record":{"id":"e9ae710ffba02268","repo":"mongodb/mongoid","slug":"ruby-does-not-allow-same-symbol-operator-with-diff","errorCode":null,"errorMessage":"Ruby does not allow same symbol operator with different values","messagePattern":"Ruby does not allow same symbol operator with different values","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/criteria/queryable/mergeable.rb","lineNumber":273,"sourceCode":"        private def _mongoid_expand_keys(expr)\n          raise ArgumentError, 'Argument must be a Hash' unless expr.is_a?(Hash)\n\n          result = BSON::Document.new\n          expr.each do |field, value|\n            field.__expr_part__(value.__expand_complex__, negating?).each do |k, v|\n              if existing = result[k]\n                if existing.is_a?(Hash)\n                  # Existing value is an operator.\n                  # If new value is also an operator, ensure there are no\n                  # conflicts and add\n                  if v.is_a?(Hash)\n                    # The new value is also an operator.\n                    # If there are no conflicts, combine the hashes, otherwise\n                    # add new conditions to top level with $and.\n                    if (v.keys & existing.keys).empty?\n                      existing.update(v)\n                    else\n                      raise NotImplementedError, 'Ruby does not allow same symbol operator with different values'\n                      result['$and'] ||= []\n                      result['$and'] << { k => v }\n                    end\n                  else\n                    # The new value is a simple value.\n                    # Transform the implicit equality to either $eq or $regexp\n                    # depending on the type of the argument. See\n                    # https://www.mongodb.com/docs/manual/reference/operator/query/eq/#std-label-eq-usage-examples\n                    # for the description of relevant server behavior.\n                    op = case v\n                         when Regexp, BSON::Regexp::Raw\n                           '$regex'\n                         else\n                           '$eq'\n                         end\n                    # If there isn't an $eq/$regex operator already in the\n                    # query, transform the new value into an operator\n                    # expression and add it to the existing hash. Otherwise","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/criteria/queryable/mergeable.rb#L255-L291","documentation":"Error \"Ruby does not allow same symbol operator with different values\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/criteria/queryable/mergeable.rb:273 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}