...

Text file src/go.mongodb.org/mongo-driver/testdata/crud/unified/bulkWrite-replaceOne-dots_and_dollars.yml

Documentation: go.mongodb.org/mongo-driver/testdata/crud/unified

     1description: "bulkWrite-replaceOne-dots_and_dollars"
     2
     3schemaVersion: "1.0"
     4
     5createEntities:
     6  - client:
     7      id: &client0 client0
     8      observeEvents: [ commandStartedEvent ]
     9  - database:
    10      id: &database0 database0
    11      client: *client0
    12      databaseName: &database0Name crud-tests
    13  - collection:
    14      id: &collection0 collection0
    15      database: *database0
    16      collectionName: &collection0Name coll0
    17
    18initialData: &initialData
    19  - collectionName: *collection0Name
    20    databaseName: *database0Name
    21    documents:
    22      - { _id: 1 }
    23
    24tests:
    25  - description: "Replacing document with top-level dotted key on 3.6+ server"
    26    runOnRequirements:
    27      - minServerVersion: "3.6"
    28    operations:
    29      - name: bulkWrite
    30        object: *collection0
    31        arguments:
    32          requests:
    33            - replaceOne:
    34                filter: { _id: 1 }
    35                replacement: &dottedKey { _id: 1, a.b: 1 }
    36        expectResult: &bulkWriteResult
    37          deletedCount: 0
    38          insertedCount: 0
    39          insertedIds: { $$unsetOrMatches: { } }
    40          matchedCount: 1
    41          modifiedCount: 1
    42          upsertedCount: 0
    43          upsertedIds: { }
    44    expectEvents: &expectEventsDottedKey
    45      - client: *client0
    46        events:
    47          - commandStartedEvent:
    48              command:
    49                update: *collection0Name
    50                updates:
    51                  - q: { _id: 1 }
    52                    u: *dottedKey
    53                    multi: { $$unsetOrMatches: false }
    54                    upsert: { $$unsetOrMatches: false }
    55    outcome:
    56      - collectionName: *collection0Name
    57        databaseName: *database0Name
    58        documents:
    59          - *dottedKey
    60
    61  - description: "Replacing document with top-level dotted key on pre-3.6 server yields server-side error"
    62    runOnRequirements:
    63      - maxServerVersion: "3.4.99"
    64    operations:
    65      - name: bulkWrite
    66        object: *collection0
    67        arguments:
    68          requests:
    69            - replaceOne:
    70                filter: { _id: 1 }
    71                replacement: *dottedKey
    72        expectError:
    73          isClientError: false
    74    expectEvents: *expectEventsDottedKey
    75    outcome: *initialData
    76
    77  - description: "Replacing document with dollar-prefixed key in embedded doc on 5.0+ server"
    78    runOnRequirements:
    79      - minServerVersion: "5.0"
    80    operations:
    81      - name: bulkWrite
    82        object: *collection0
    83        arguments:
    84          requests:
    85            - replaceOne:
    86                filter: { _id: 1 }
    87                replacement: &dollarPrefixedKeyInEmbedded { _id: 1, a: { $b: 1 } }
    88        expectResult: *bulkWriteResult
    89    expectEvents: &expectEventsDollarPrefixedKeyInEmbedded
    90      - client: *client0
    91        events:
    92          - commandStartedEvent:
    93              command:
    94                update: *collection0Name
    95                updates:
    96                  - q: { _id: 1 }
    97                    u: *dollarPrefixedKeyInEmbedded
    98                    multi: { $$unsetOrMatches: false }
    99                    upsert: { $$unsetOrMatches: false }
   100    outcome:
   101      - collectionName: *collection0Name
   102        databaseName: *database0Name
   103        documents:
   104          - *dollarPrefixedKeyInEmbedded
   105
   106  - description: "Replacing document with dollar-prefixed key in embedded doc on pre-5.0 server yields server-side error"
   107    runOnRequirements:
   108      - maxServerVersion: "4.99"
   109    operations:
   110      - name: bulkWrite
   111        object: *collection0
   112        arguments:
   113          requests:
   114            - replaceOne:
   115                filter: { _id: 1 }
   116                replacement: *dollarPrefixedKeyInEmbedded
   117        expectError:
   118          isClientError: false
   119    expectEvents: *expectEventsDollarPrefixedKeyInEmbedded
   120    outcome: *initialData
   121
   122  - description: "Replacing document with dotted key in embedded doc on 3.6+ server"
   123    runOnRequirements:
   124      - minServerVersion: "3.6"
   125    operations:
   126      - name: bulkWrite
   127        object: *collection0
   128        arguments:
   129          requests:
   130            - replaceOne:
   131                filter: { _id: 1 }
   132                replacement: &dottedKeyInEmbedded { _id: 1, a: { b.c: 1 } }
   133        expectResult: *bulkWriteResult
   134    expectEvents: &expectEventsDottedKeyInEmbedded
   135      - client: *client0
   136        events:
   137          - commandStartedEvent:
   138              command:
   139                update: *collection0Name
   140                updates:
   141                  - q: { _id: 1 }
   142                    u: *dottedKeyInEmbedded
   143                    multi: { $$unsetOrMatches: false }
   144                    upsert: { $$unsetOrMatches: false }
   145    outcome:
   146      - collectionName: *collection0Name
   147        databaseName: *database0Name
   148        documents:
   149          - *dottedKeyInEmbedded
   150
   151  - description: "Replacing document with dotted key in embedded doc on pre-3.6 server yields server-side error"
   152    runOnRequirements:
   153      - maxServerVersion: "3.4.99"
   154    operations:
   155      - name: bulkWrite
   156        object: *collection0
   157        arguments:
   158          requests:
   159            - replaceOne:
   160                filter: { _id: 1 }
   161                replacement: *dottedKeyInEmbedded
   162        expectError:
   163          isClientError: false
   164    expectEvents: *expectEventsDottedKeyInEmbedded
   165    outcome: *initialData

View as plain text