Skip to content

Commit 6f4d8f0

Browse files
authored
Merge pull request #318 Fixed list type as field result in sqlalchemy
2 parents dc7182e + a434c51 commit 6f4d8f0

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Add list type to converter from result to native type (fix problem with get list result in dbapi/sqlalchemy)
2+
13
## 3.3.5 ##
24
* Fixed use positional argument instead of named in WriterAsyncIO.__del__
35
* Fixed release buffer while read topic by one messages

tests/sqlalchemy/test_inspect.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from sqlalchemy import text
2+
13
import ydb
24

35
import sqlalchemy as sa
@@ -18,3 +20,10 @@ def test_get_columns(driver_sync, sa_engine):
1820
]
1921

2022
session.execute_scheme("DROP TABLE test")
23+
24+
25+
def test_query_list(sa_engine):
26+
with sa_engine.connect() as connection:
27+
result = connection.execute(text("SELECT AsList(1, 2, 3, 4) as c"))
28+
row = next(result)
29+
assert row["c"] == [1, 2, 3, 4]

ydb/convert.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ def _optional_type_to_native(type_pb):
227227
return types.OptionalType(type_to_native(type_pb.optional_type.item))
228228

229229

230+
def _list_type_to_native(type_pb):
231+
return types.ListType(type_to_native(type_pb.list_type.item))
232+
233+
230234
def _primitive_type_to_native(type_pb):
231235
return _primitive_type_by_id.get(type_pb.type_id)
232236

@@ -240,6 +244,7 @@ def _null_type_factory(type_pb):
240244
"type_id": _primitive_type_to_native,
241245
"decimal_type": _decimal_type_to_native,
242246
"null_type": _null_type_factory,
247+
"list_type": _list_type_to_native,
243248
}
244249

245250

0 commit comments

Comments
 (0)