Skip to content

Update using r.literal() in nested structure fails (?) #5977

@neonrust

Description

@neonrust

I have a database migration script that (amongst other things) converts a "flat" value into structured value. In my case I'm changing an id referencing a document in another table to storing the other document "inline".

Anyway, to specifics.

Given the following document:

{
   'id': 'test', 
   'data': 'flat_value' 
}

And then doing an update, replacing data with a structured value that contains r.literal() (and in my case a lot of other things).
Performing the write works fine. Or at least appears to:

>> table.get('test').update({
   'data': {
       'nested': r.literal()
    }
}).run()
{
   'replaced': 1,
   'skipped': 0,
   'unchanged': 0,
   'inserted': 0,
   'deleted': 0,
   'errors': 0
}

No error. However, attempting to retrieve the document fails:

>> table.get('test').run()
ReqlDriverError: Unknown pseudo-type LITERAL

This happens only when replacing an existing value with an object that contains r.literal().
Given the original document and adding a new field works fine:

>> table.get('test').update({
   'new_data': {
      'nested': r.literal()
   }
}).run()
>> table.get('test').run()
{
   'id': 'test',
   'data': 'flat_value',
   'new_data': { }
}

edit: shortened queries
edit2: fixed output of last query

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions