viralogic / py-enumerable

A Python module used for interacting with collections of objects using LINQ syntax
MIT License
187 stars 24 forks source link

Field name not found, throw exception #83

Open ksusanto opened 1 year ago

ksusanto commented 1 year ago

aa = Enumerable([{'numbertag': 1, 'numberdesign': 1, 'notes': None, 'status': 128, 'plcstart': '2023-11-10 21:00:02', 'plcstop': '2023-11-10 21:01:04', 'groupuid': 'GROUP:3303', 'tagtype': 'CYCLETIME'},{'numbertag': 5, 'numberdesign': 5, 'notes': '', 'status': 0}, {'numbertag': 1, 'numberdesign': 1, 'notes': None, 'status': 8, 'plcstart': '2023-11-10 20:59:04', 'plcstop': '2023-11-10 20:59:15', 'groupuid': 'GROUP:3305', 'tagtype': 'GROUPOP'}])

bb = aa.where(lambda x: x['tagtype'] != 'CYCLETIME' and x['status'] & 32 != 32).to_list()

in py-linq==1.3.0, it works but not in 1.4.0. it throw the exception Traceback (most recent call last): File "", line 1, in File "c:_Envision\venv\dataprocessor\lib\site-packages\py_linq\py_linq.py", line 90, in to_list return [x for x in self] File "c:_Envision\venv\dataprocessor\lib\site-packages\py_linq\py_linq.py", line 90, in return [x for x in self] File "c:_Envision\venv\dataprocessor\lib\site-packages\py_linq\core.py", line 103, in iter for index, item in enumerate(self._data): File "", line 1, in KeyError: 'tagtype'