Skip to content

crash when create view #178

New issue

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

By clicking “No 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? No Sign in to your account

Closed
fy0 opened this issue Aug 8, 2017 · 1 comment
Closed

crash when create view #178

fy0 opened this issue Aug 8, 2017 · 1 comment

Comments

@fy0
Copy link

fy0 commented Aug 8, 2017

  • asyncpg version: 0.12 (current pip version)
  • PostgreSQL version: 9.6
  • Python version: 3.6
  • Platform: Windows 10
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?:
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : No

Code:

async def func():
    asyncpg_conn = await asyncpg.connect('postgresql://postgres@localhost/test')
    sql = 'create view aaa (a) as select 1 from "one_table" where id = $1', (123,)
    print(await asyncpg_conn.fetch(sql[0], *sql[1]))

asyncio.get_event_loop().run_until_complete(func())

Error:

  File "E:\codes\2017\28.stage-two-backend\view\common\association.py", line 163, in func
    print(await asyncpg_conn.fetch(sql[0], *sql[1]))
  File "C:\Anaconda3\lib\site-packages\asyncpg\connection.py", line 341, in fetch
    return await self._execute(query, args, 0, timeout)
  File "C:\Anaconda3\lib\site-packages\asyncpg\connection.py", line 1188, in _execute
    return await self._do_execute(query, executor, timeout)
  File "C:\Anaconda3\lib\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 (1) does not match number of parameters (0)

Wow, what happened?

@elprans
Copy link
Member

elprans commented Aug 8, 2017

The main issue is that CREATE VIEW does not accept parameters:

# create view aaa (a) as select 1 from "pg_type" where oid = $1;
ERROR:  there is no parameter $1
LINE 1: ...eate view aaa (a) as select 1 from "pg_type" where oid = $1;

We'll check if it's possible to handle this better than now.

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

No branches or pull requests

2 participants