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

Provide the erroneous query in the SQLException class #166

Open
penguinpowernz opened this issue Oct 7, 2015 · 0 comments
Open

Provide the erroneous query in the SQLException class #166

penguinpowernz opened this issue Oct 7, 2015 · 0 comments
Labels

Comments

@penguinpowernz
Copy link
Contributor

Would be good to be able to pull the specific query that caused the error from the SQLException class. For example:

begin
  ids = ids.join(",")
  db.execute("SELECT * FROM table WHERE id IN(#{ids});")
rescue SQLite3::SQLException => e
  log.error e.message # near ",": syntax error
                      # (WTF?)
  log.debug e.query   # SELECT * FROM table WHERE id IN(,1,2,3,4);
                      # (oh, right there's a nil entry in the array)
end

Gives some context to the particular SQL error that happened, assisting in troubleshooting code. I would submit a pull request, but I can't see in the code where I could set a attribute on the exception class (looks like it's done from C?).

Cheers

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

No branches or pull requests

2 participants