coleifer / peewee

a small, expressive orm -- supports postgresql, mysql, sqlite and cockroachdb
http://docs.peewee-orm.com/
MIT License
11.06k stars 1.37k forks source link

TypeError: execute_sql() got an unexpected keyword argument 'named_cursor' (in 3.17.6, no problem in 3.17.5) #2923

Closed Narann closed 3 weeks ago

Narann commented 3 weeks ago

Hello, and thanks again for your amazing work. :)

I had a problem upgrading to 3.17.6.

After some investigation, 3.17.5 have no problem.

Traceback (most recent call last):
  File "D:\...\main_window.py", line 779, in <module>
    start_standalone()
  File "D:\...\main_window.py", line 767, in start_standalone
    window.apply_settings()
  File "D:\...\main_window.py", line 714, in apply_settings
    self._main_central_wgt.refresh()
  File "D:\...\main_window.py", line 333, in refresh
    self.left_wgt.refresh()
  File "D:\...\main_window.py", line 173, in refresh
    self.proj_cbb.projects = list(self._app.db.projects())
  File "...\db.py", line 153, in projects
    for pw_project in all_projects(active_only):
  File "...\backend\peewee\project.py", line 55, in all_projects
    yield from all_from_model(PwProject, active_only)
  File "...\backend\peewee\_common_query.py", line 104, in all_from_model
    yield from query
  File "...\lib\site-packages\peewee.py", line 7275, in __iter__
    self.execute()
  File "...\lib\site-packages\peewee.py", line 2036, in inner
    return method(self, database, *args, **kwargs)
  File "...\lib\site-packages\peewee.py", line 2107, in execute
    return self._execute(database)
  File "...\lib\site-packages\peewee.py", line 2280, in _execute
    cursor = database.execute(self)
  File "...\lib\site-packages\playhouse\postgres_ext.py", line 503, in execute
    cursor = self.execute_sql(sql, params, named_cursor=named_cursor)
TypeError: execute_sql() got an unexpected keyword argument 'named_cursor'

I think the problem appears with this commit: https://github.com/coleifer/peewee/commit/c6f4c4da7a1579021a35bbb1412b6b41e74b2d38

The called self.execute_sql(sql, params, named_cursor=named_cursor) does not seems to be the one wrote just below.

I hope its helping.

Keep the good work! :)

coleifer commented 3 weeks ago

Do you have an override on the Database, using a ReconnectMixin or something that supplies it's own execute_sql()? See

You can see on line 508 that execute_sql() accepts the named cursor argument. See #2914 for some discussion.

Narann commented 3 weeks ago

Good catch !

class OurDatabase(RetryOperationalError, PostgresqlExtDatabase):
    pass

We had to do this to ensure we reconnect when the server close the connection.

So yes, I have to rewrite my wrapper fonction.

Thanks for your hard work !