If I pass an invalid query to the dataset.empty? method, it raises a
Sequel::DataseDisconnectError. It would be a lot more helpful if it raised
a Sequel::DatabaseError like it does if I call dataset.all
EXISTS_ANYWHERE_SQL = <<~SQL.freeze
SELECT 1
FROM ap_invoices
WHERE
vendor_no = :vendor_no AND
REPLACE(invoice_no, ' ', '') = REPLACE(:invoice_no, ' ', '')
SQL
dataset = DB.fetch(EXISTS_ANYWHERE_SQL, vendor_no: 1, invoice_no: 1)
dataset.empty?
dataset.all
dataset.empty? tells me
Sequel::DatabaseDisconnectError: PG::ConnectionBad: PQconsumeInput() server
closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
dataset.all tells me
(0.006573s) SET standard_conforming_strings = ON
(0.007248s) SET client_min_messages = 'WARNING'
(0.005128s) SET DateStyle = 'ISO'
PG::UndefinedFunction: ERROR: function replace(bigint, unknown, unknown)
does not exist
LINE 5: REPLACE(invoice_no, ' ', '') = REPLACE(1, ' ', ...
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.: SELECT 1
FROM ap_invoices
WHERE
vendor_no = 1AND
REPLACE(invoice_no, ' ', '') = REPLACE(1, ' ', '')
Sequel::DatabaseError: PG::UndefinedFunction: ERROR: function replace(
bigint, unknown, unknown) does not exist
LINE 5: REPLACE(invoice_no, ' ', '') = REPLACE(1, ' ', ...
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.
The error message from dataset.all is a lot more helpful than the error
message from dataset.empty? Would it be possible for dataset.empty? to
raise a DatabaseDisconnectError to show what is wrong with the query?
--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/acf9555d-4089-48bb-80c5-26b16f4bffb7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.