8000 query("insert... returning") fails to commit · Issue #648 · webpy/webpy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

query("insert... returning") fails to commit #648

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

Closed
pbuckner opened this issue Jun 23, 2020 · 0 comments · Fixed by #649
Closed

query("insert... returning") fails to commit #648

pbuckner opened this issue Jun 23, 2020 · 0 comments · Fixed by #649
Assignees

Comments

@pbuckner
Copy link

performing db.query("INSERT into sample_table (value) VALUES ('a')" )works as anticipated: data is stored and committed.

performing db.query("INSERT into sample_table (valid) VALUES ('a') RETURNING idx") fails to commit the insert. Data is added to database, idx is indeed returned, but the insert is not committed, so data is not available.

Problem is due to class DB, query() change with introduction self.create_result_set()

Compare web.py 038 db.py line 661:

if db_cursor.description:
    ...
    out.list = ...
else:
    out = db_cursor.rowcount
if not self.ctx.transactions:
    self.ctx.commit()
return out

0.51:

if db_cursor.description:
   return self.create_result_set(db_cursor)  # <---- HERE
else:
   out = db_cursor.rowcount
if not self.ctx.transactions:
    self.ctx.commit()
return out

INSERT...RETURNING sets db_cursor.description, which causes 0.51 to perform return self.create_result_set(db_cursor) which means self.ctx.commit() is never called.

It appears (with limited testing) a possible solution may be as simple as replacing:

return self.create_result_set(db_cursor)

with:

out = self.create_result_set(db_cursor)

and allowing it to flow through to return out.

anandology added a commit that referenced this issue Jun 24, 2020
The insert ... returning ... query was not getting commited to the db
due to a recent change.

Issue #648
anandology added a commit that referenced this issue Jun 24, 2020
This test was getting blocked when tried without the fix in the previous
commit.

Issue #648
anandology added a commit to anandology/webpy that referenced this issue Jun 24, 2020
This test was getting blocked when tried without the fix in the previous
commit.

Issue webpy#648
anandology added a commit to anandology/webpy that referenced this issue Jun 24, 2020
This test was getting blocked when tried without the fix in the previous
commit.

Issue webpy#648
anandology added a commit to anandology/webpy that referenced this issue Jun 24, 2020
This test was getting blocked when tried without the fix in the previous
commit.

Issue webpy#648
iredmail pushed a commit that referenced this issue Jun 24, 2020
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

Successfully merging a pull request may close this issue.

3 participants
0