crud icon indicating copy to clipboard operation
crud copied to clipboard

Problem with inserting integers to double field even with ffi.cast('double', value)

Open GRISHNOV opened this issue 2 years ago • 2 comments

Consider a space test with the following format:

> crud.select('test')['metadata']

[
    {'name': 'id', 'type': 'unsigned'},
    {'name': 'bucket_id', 'type': 'unsigned'},
    {'type': 'double', 'name': 'data', 'is_nullable': false}
]

When trying to insert integer data into the third field with the recommended cast via ffi.cast('double', value), we get an error:

> crud.insert('test', {1, 1, ffi.cast('double', 0)})

- null
- line: 111
  class_name: InsertError
  err: 'Failed to insert: Tuple field 3 (data) type does not match one required by
    operation: expected double, got unsigned'
  file: /Users/i.grishnov/Desktop/git_all/crud/crud/insert.lua
  str: 'InsertError: Failed to insert: Tuple field 3 (data) type does not match one
    required by operation: expected double, got unsigned'

> crud.insert('test', {1, 1, ffi.cast('double', 1)})

- null
- line: 111
  class_name: InsertError
  err: 'Failed to insert: Tuple field 3 (data) type does not match one required by
    operation: expected double, got unsigned'
  file: /Users/i.grishnov/Desktop/git_all/crud/crud/insert.lua
  str: 'InsertError: Failed to insert: Tuple field 3 (data) type does not match one
    required by operation: expected double, got unsigned'

Despite the ffi.cast('double', INT_VALUE), we get expected double, got unsigned

GRISHNOV avatar May 31 '22 17:05 GRISHNOV