Skip to content

bug: passing datetime.date value as parameter of request execution throws [ERROR] TypeError: 'datetime.date' object cannot be interpreted as an integer #163

@megazhuk

Description

@megazhuk

Bug Report

YDB Python version: ydb 2.12.2, Python 3.11

Current behavior:

YQL:

DECLARE $userid AS String;
DECLARE $birthday AS Date;
INSERT INTO `users/profile` (userid, birthday)
VALUES ($userid, $birthday);

Parameters:

{
'$userid': b'\x91K\xf4\x06\xac\xdcG\xf8\x95\x19\xe6\xbc\x83\x9c\x9fH', 
'$birthday': datetime.date(1982, 10, 7)
}

EXCEPTION:

[ERROR] TypeError: 'datetime.date' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/function/runtime/runtime.py", line 191, in handle_event
    result = h(r.event, r.context)
  File "/function/code/index.py", line 90, in handler
    session = yandexId(token)
  File "/function/code/index.py", line 69, in yandexId
    db.insert('users/profile', kv)
  File "/function/code/ydb_helper.py", line 57, in insert
    self.execute('\n'.join(yql), params, commit)
  File "/function/code/ydb_helper.py", line 43, in execute
    return self._pool.retry_operation_sync(callee)
  File "/function/code/ydb/table.py", line 2500, in retry_operation_sync
    return retry_operation_sync(wrapped_callee, retry_settings)
  File "/function/code/ydb/table.py", line 991, in retry_operation_sync
    for next_opt in opt_generator:
  File "/function/code/ydb/table.py", line 952, in retry_operation_impl
    result = YdbRetryOperationFinalResult(callee(*args, **kwargs))
  File "/function/code/ydb/table.py", line 2498, in wrapped_callee
    return callee(session, *args, **kwargs)
  File "/function/code/ydb_helper.py", line 41, in callee
    return session.transaction().execute(
  File "/function/code/ydb/table.py", line 2280, in execute
    _tx_ctx_impl.execute_request_factory(
  File "/function/code/ydb/_tx_ctx_impl.py", line 43, in decorator
    return func(session_state, tx_state, *args, **kwargs)
  File "/function/code/ydb/_tx_ctx_impl.py", line 146, in execute_request_factory
    parameters=convert.parameters_to_pb(parameters_types, parameters)
  File "/function/code/ydb/convert.py", line 299, in parameters_to_pb
    result.value.MergeFrom(_from_native_value(ttype, parameters_values[name]))
  File "/function/code/ydb/convert.py", line 276, in _from_native_value
    return _from_native_map.get(type_pb.WhichOneof("type"))(type_pb, value)
  File "/function/code/ydb/convert.py", line 184, in _primitive_to_pb
    data_type.set_value(value_pb, value)
  File "/function/code/ydb/types.py", line 180, in set_value
    setattr(pb, self._proto_field, value)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions