Action window errors on python-sql > 1.2.0

Since the recent relase of python-sql I’ve seen two of our tryton tests suites failing with the following exception:

ERROR: test_ir_action_window (tests.test_xxxx.xxxxTestCase)
Test action windows are correctly defined
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/trytond/tests/test_tryton.py", line 203, in wrapper
    result = func(*args, **kwargs)
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/trytond/tests/test_tryton.py", line 615, in test_ir_action_window
    domain, order=order, limit=action_window.limit)
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/trytond/model/modelsql.py", line 1313, in search
    cursor.execute(*select)
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/sql/__init__.py", line 204, in __iter__
    yield self.params
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/sql/__init__.py", line 649, in params
    p.extend(self.from_.params)
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/sql/__init__.py", line 1121, in params
    p.extend(from_.params)
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/sql/__init__.py", line 649, in params
    p.extend(self.from_.params)
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/sql/__init__.py", line 1121, in params
    p.extend(from_.params)
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/sql/__init__.py", line 1066, in params
    if hasattr(item, 'params'):
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/sql/__init__.py", line 1066, in params
    if hasattr(item, 'params'):
  File "/builds/kopen/xxxx/.tox/py35-postgresql/lib/python3.5/site-packages/sql/__init__.py", line 1067, in params
    p.extend(item.params)
TypeError: 'Column' object is not iterable

This is only raised when using postgresql backend, it works without any issue on sqlite backend.

We have not modified anything of our module, so this seems clearly reeelated to the new release.

Does anyone found any similar issues?
Any idea on who to fix it?

I suspect that an AttributeError is raised when calling params on one of the table joined.
It is probably due to a window being wrongly defined or a column of the table being named windows.

Hello,

We noticed the same kind of problem following this new release:

File "/home/user/workspace/trytond/trytond/model/modelsql.py", line 843, in read
    getter_results = field.get(ids, cls, field_list, values=result)
  File "/home/user/workspace/trytond/trytond/modules/coog_core/fields.py", line 221, in get
    result = super().get(ids, Model, name, values)
  File "/home/user/workspace/trytond/trytond/model/fields/function.py", line 105, in get
    return call(names)
  File "/home/user/workspace/trytond/trytond/model/fields/function.py", line 99, in call
    return method(records, name)
  File "/home/user/workspace/trytond/trytond/modules/endorsement/endorsement.py", line 963, in getter_activation_history
    names)
  File "/home/user/workspace/trytond/trytond/modules/contract/contract.py", line 797, in getter_activation_history
    cursor.execute(*query)
  File "/home/user/.virtualenvs/workspace/lib/python3.6/site-packages/sql/__init__.py", line 204, in __iter__
    yield self.params
  File "/home/user/.virtualenvs/workspace/lib/python3.6/site-packages/sql/__init__.py", line 649, in params
    p.extend(self.from_.params)
  File "/home/user/.virtualenvs/workspace/lib/python3.6/site-packages/sql/__init__.py", line 1121, in params
    p.extend(from_.params)
TypeError: 'Column' object is not iterable 

@ced Could you elaborate on

It is probably due to a window being wrongly defined

since I know there isn’t a column named “windows” in my table ?

The problem is also present on the sale module:

======================================================================
FAIL: /home/pokoli/projectes/nclone/trytond/trytond/modules/sale/tests/scenario_sale_reporting.rst
Doctest: scenario_sale_reporting.rst
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.8/doctest.py", line 2204, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for scenario_sale_reporting.rst
  File "/home/pokoli/projectes/nclone/trytond/trytond/modules/sale/tests/scenario_sale_reporting.rst", line 0

----------------------------------------------------------------------
File "/home/pokoli/projectes/nclone/trytond/trytond/modules/sale/tests/scenario_sale_reporting.rst", line 143, in scenario_sale_reporting.rst
Failed example:
    with config.set_context(context=context):
        reports = Customer.find([])
        time_series = CustomerTimeseries.find([])
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python3.8/doctest.py", line 1336, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest scenario_sale_reporting.rst[90]>", line 2, in <module>
        reports = Customer.find([])
      File "/home/pokoli/projectes/nclone/proteus/proteus/__init__.py", line 816, in find
        ids = cls._proxy.search(condition, offset, limit, order,
      File "/home/pokoli/projectes/nclone/proteus/proteus/config.py", line 188, in __call__
        result = rpc.result(meth(*args, **kwargs))
      File "/home/pokoli/projectes/nclone/trytond/trytond/model/modelsql.py", line 1335, in search
        cursor.execute(*select)
      File "/home/pokoli/.virtualenvs/nclone/lib/python3.8/site-packages/sql/__init__.py", line 204, in __iter__
        yield self.params
      File "/home/pokoli/.virtualenvs/nclone/lib/python3.8/site-packages/sql/__init__.py", line 649, in params
        p.extend(self.from_.params)
      File "/home/pokoli/.virtualenvs/nclone/lib/python3.8/site-packages/sql/__init__.py", line 1121, in params
        p.extend(from_.params)
      File "/home/pokoli/.virtualenvs/nclone/lib/python3.8/site-packages/sql/__init__.py", line 649, in params
        p.extend(self.from_.params)
      File "/home/pokoli/.virtualenvs/nclone/lib/python3.8/site-packages/sql/__init__.py", line 1121, in params
        p.extend(from_.params)
      File "/home/pokoli/.virtualenvs/nclone/lib/python3.8/site-packages/sql/__init__.py", line 1066, in params
        if hasattr(item, 'params'):
      File "/home/pokoli/.virtualenvs/nclone/lib/python3.8/site-packages/sql/__init__.py", line 1066, in params
        if hasattr(item, 'params'):
      File "/home/pokoli/.virtualenvs/nclone/lib/python3.8/site-packages/sql/__init__.py", line 1067, in params
        p.extend(item.params)
    TypeError: 'Column' object is not iterable

This did not fail on the last drone run which run on python-sql 1.1.0

I found the problem and why tests did not catch it: Bug 68: Getting params from Select with windows fails - python-sql tracker

I can confirm it fixes the issue. Thank you so much!