Can't automatically convert KeyedTuple (from sqlalchemy) to Julia's NamedTuple
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Julia
- Star
- 1.5k
- Fork
- 186
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
I use PyCall to call sqlalchemy from Julia, which uses a class called KeyedTuple to represent rows resulting from a query and I want to convert those automatically to julia's NamedTuple. I expected something like this to work:
using PyCall
sa = pyimport("sqlalchemy")
pytype_mapping(sa."util"."KeyedTuple", NamedTuple)
Base.convert(::Type{NamedTuple}, o::PyObject) = NamedTuple{Symbol.(o._fields)}([getproperty(o, f) for f in Symbol.(o._fields)])
x = sa.util.KeyedTuple([1, 2, 3], labels=["one", "two", "three"]) # returns (1, 2, 3)
This is no surprise, since:
o = @pycall sa.util.KeyedTuple([1, 2, 3], labels=["one", "two", "three"])::PyObject
pytype_query(o) # Returns `Tuple{Integer,Integer,Integer}`
I guess a simple way to make my thing work would be to alter the order in which pytype_query does things> I mean first look for a match in the pytype_queries array and then proceed with the rest...?
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Start with the pytype_query and pytype_queries entry points mentioned in the issue, then reproduce the Julia/PyCall example using SQLAlchemy's util.KeyedTuple. Determine whether the type-specific mapping should be checked before the existing tuple handling, and consider the conversion complete when the example produces a NamedTuple with the expected field names and values.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- julia, python, sqlalchemy
- Lĩnh vực
- databases
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100