summaryrefslogtreecommitdiff
path: root/ext/librethinkdbxx/test/upstream/mutation/delete.yaml
blob: b222dba9142a7f245e4f38ebfe6d16475e0d1cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
desc: Tests deletes of selections
table_variable_name: tbl
tests:

    # Set up some data

    - py: tbl.insert([{'id':i} for i in xrange(100)])
      js: |
        tbl.insert(function(){
            var res = []
            for (var i = 0; i < 100; i++) {
                res.push({id: i});
            }
            return res;
        }())
      rb: tbl.insert((1..100).map{ |i| {"id" => i} })
      ot: ({'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':100})

    - cd: tbl.count()
      ot: 100

    # Point delete

    - cd: tbl.get(12).delete()
      ot: ({'deleted':1,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':0})

    # Attempt deletion with bad durability flag.

    - js: tbl.skip(50).delete({durability:'wrong'})
      rb: tbl.skip(50).delete({ :durability => 'wrong' })
      py: tbl.skip(50).delete(durability='wrong')
      ot: err('ReqlQueryLogicError', 'Durability option `wrong` unrecognized (options are "hard" and "soft").', [0])

    # Delete selection of table, soft durability flag.

    - js: tbl.skip(50).delete({durability:'soft'})
      rb: tbl.skip(50).delete({ :durability => 'soft' })
      py: tbl.skip(50).delete(durability='soft')
      ot: ({'deleted':49,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':0})

    # Delete whole table, hard durability flag.

    - js: tbl.delete({durability:'hard'})
      rb: tbl.delete({ :durability => 'hard' })
      py: tbl.delete(durability='hard')
      ot: ({'deleted':50,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':0})

    # test deletion on a non-deletable object
    - cd: r.expr([1, 2]).delete()
      ot: err('ReqlQueryLogicError', 'Expected type SELECTION but found DATUM:', [0])