Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg.insert lost all arguments #38

Closed
fantix opened this issue Jul 21, 2017 · 1 comment
Closed

pg.insert lost all arguments #38

fantix opened this issue Jul 21, 2017 · 1 comment

Comments

@fantix
Copy link
Contributor

fantix commented Jul 21, 2017

pg.insert simply doesn't work:

Traceback (most recent call last):
  File "test.py", line 19, in <module>
    loop.run_until_complete(main())
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "test.py", line 6, in main
    val = await pg.insert('INSERT INTO users (nickname) VALUES ($1)', 'fantix')
  File "/Volumes/Home/fantix/py36env/lib/python3.6/site-packages/asyncpgsa/pgsingleton.py", line 91, in insert
    timeout=timeout)
  File "/Volumes/Home/fantix/py36env/lib/python3.6/site-packages/asyncpgsa/connection.py", line 138, in insert
    return await self.fetchval(query, *params, *args, **kwargs)
  File "/Volumes/Home/fantix/py36env/lib/python3.6/site-packages/asyncpgsa/connection.py", line 123, in fetchval
    return await super().fetchval(query, *args, **kwargs)
  File "/Volumes/Home/fantix/py36env/lib/python3.6/site-packages/asyncpg/connection.py", line 358, in fetchval
    data = await self._execute(query, args, 1, timeout)
  File "/Volumes/Home/fantix/py36env/lib/python3.6/site-packages/asyncpg/connection.py", line 1188, in _execute
    return await self._do_execute(query, executor, timeout)
  File "/Volumes/Home/fantix/py36env/lib/python3.6/site-packages/asyncpg/connection.py", line 1209, in _do_execute
    result = await executor(stmt, None)
  File "asyncpg/protocol/protocol.pyx", line 181, in bind_execute (asyncpg/protocol/protocol.c:66715)
  File "asyncpg/protocol/prepared_stmt.pyx", line 103, in asyncpg.protocol.protocol.PreparedStatementState._encode_bind_msg (asyncpg/protocol/protocol.c:62407)
ValueError: number of arguments (0) does not match number of parameters (1)

Looks like the overriden _execute method simply ignored the given args but only make use of the args found in the query object - if query is one:

    def _execute(self, query, args, limit, timeout, return_status=False):
        query, args = compile_query(query, dialect=self._dialect)
        return super()._execute(query, args, limit, timeout,
                                return_status=return_status)

The same happens with insert when using a SQLAlchemy core insert statement object with values included. Because the compile is done in insert, before _execute.

fantix added a commit to fantix/asyncpgsa that referenced this issue Jul 21, 2017
fantix added a commit to fantix/asyncpgsa that referenced this issue Jul 21, 2017
fantix added a commit to fantix/asyncpgsa that referenced this issue Jul 21, 2017
@nhumrich
Copy link
Contributor

The fix is in 0.14.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants