On Monday, March 11, 2019 at 5:11:44 AM UTC-7, Janko Marohnić wrote:
>
> Hello,
>
> I have the following problem: whenever an error is raised due to an
> invalid SQL query, e.g:
>
> DB[:table].select(:col1).order(:col2).group(:col3).where(col4: :col5).all
>
> the error message only shows part of the SQL query (I'm guessing it's
> truncated at the Postgres server/client level):
>
> PG::UndefinedTable: ERROR: relation "table" does not exist
> (Sequel::DatabaseError)
> LINE 1: SELECT "col1" FROM "table" WHERE ("col4" = "col5") GROUP BY ...
>
> Is there possibly some extension/setting which would automatically include
> the full SQL query in the error message? I've noticed the error_sql
> <https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/error_sql_rb.html>
> extension,
> but I would like if the SQL query is already included in the message.
>
I'm not sure if there is a PostgreSQL setting that logs the full error
message. You would have to ask on a PostgreSQL mailing list. That would
be the best way if it is possible.
You could use the error_sql extension and modify the test runner to try to
print the stored SQL for any exception if the exception supports it and the
stored SQL is present.
If neither of those approaches will work, you could copy the error_sql
extension and modify it to do what you want.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.