Skip to content

Provide the erroneous query in the SQLException class #166

@penguinpowernz

Description

@penguinpowernz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions