Sha256: 1e36df983767c9aa409c73b619f31188b0969978b35caa18f97e6164e71d1161

Contents?: true

Size: 1.55 KB

Versions: 39

Compression:

Stored size: 1.55 KB

Contents

- name: string key - matches
  document:
    # Document field names in MongoDB are always strings.
    '42': foo
  # The paths are also always strings.
  key: '42'
  
  result:
    - foo

- name: string key - does not match
  document:
    # Document field names in MongoDB are always strings.
    '42': foo
  # The paths are also always strings.
  key: '4'
  
  result: []

- name: array value - matches
  document:
    '42':
      - foo
  key: '42'
  
  result:
    - ['foo']

- name: subfield of numeric key - matches
  document:
    '42':
      foo: bar
  key: 42.foo
  
  result: 
    - bar

- name: numeric key under array
  document:
    a:
      -
        '42': bar

  key: a.42

  result: 
    - bar

- name: multiple values under numeric key under array
  document: &numeric-key-under-array
    a:
      -
        '42': bar
      -
        '42': foo

  key: a.42

  result: 
    - bar
    - foo

- name: array indexing with values under numeric key under array
  document: *numeric-key-under-array

  key: a.1

  result: 
    - 
      '42': foo

- name: multiple values under array under numeric key
  document:
    a:
      '42':
        -
          foo: bar
        -       
          foo: baq

  key: a.42.foo

  result: 
    - bar
    - baq

- name: path component interpretable as both array index and hash key
  document: 
    a:
      -
        '1': bar
      -
        '1': foo

  key: a.1

  result: 
    # The order of these results isn't guaranteed:
    # 1 interpreted as the array index:
    -
      '1': foo
    # 1 interpreted as hash key:
    - bar
    - foo

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
mongoid-8.1.7 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-9.0.3 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.1.6 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-9.0.2 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-9.0.1 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-9.0.0 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.0.8 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.1.5 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.1.4 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.0.7 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.1.3 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.1.2 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.0.6 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-7.5.4 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.1.1 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.0.5 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.1.0 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-7.5.3 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.0.4 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
mongoid-8.0.3 spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml