Skip to content

support null type in queries #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 2.2.0 ##

* allow to refer endpoints by node id
* support null type in queries

## 2.1.0 ##

Expand Down
5 changes: 5 additions & 0 deletions ydb/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,15 @@ def _primitive_type_to_native(type_pb):
return _primitive_type_by_id.get(type_pb.type_id)


def _null_type_factory(type_pb):
return types.NullType()


_type_to_native_map = {
"optional_type": _optional_type_to_native,
"type_id": _primitive_type_to_native,
"decimal_type": _decimal_type_to_native,
"null_type": _null_type_factory,
}


Expand Down
15 changes: 15 additions & 0 deletions ydb/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datetime import date, datetime
import uuid
import struct
from google.protobuf import struct_pb2


if six.PY3:
Expand Down Expand Up @@ -214,6 +215,20 @@ def __str__(self):
return "Decimal(%d,%d)" % (self._precision, self._scale)


class NullType(AbstractTypeBuilder):
__slots__ = ("_repr", "_proto")

def __init__(self):
self._proto = _apis.ydb_value.Type(null_type=struct_pb2.NULL_VALUE)

@property
def proto(self):
return self._proto

def __str__(self):
return "NullType"


class OptionalType(AbstractTypeBuilder):
__slots__ = ("_repr", "_proto", "_item")

Expand Down