sparklemotion / sparklemotion/sqlite3-ruby
Provide the erroneous query in the SQLException class
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 845
- Forks
- 220
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 3
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the db.execute entry point and trace how SQLite3::SQLException is created across the Ruby binding and its C implementation. Determine how the failing SQL can be retained on the exception, then verify that rescuing the exception exposes the query shown in the issue without changing the existing error message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby, sqlite
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100