On Sunday, April 2, 2017 at 8:00:52 PM UTC-7, Aryk Grosz wrote:
>
> The dataset that is used to lookup a row is calculated by:
>
> sql = sql.dup
> ds = dataset
> ds.literal_append(sql, pk)
> ds.fetch_rows(sql){|r| return ds.row_proc.call(r)}
>
>
> However, when the error is raised, only the dataset on the model is passed
> in and from it you cannot extrapolate which primary key was looked up. This
> data is gone.
>
> This seems to be important data to report back an error like:
>
> "User could not be found with ID: 4". There is no way to get this data.
>
> Was this intentional? Anyway, we could add in a way to pass in the primary
> key into the NoMatchingError error?
>
If you really needed this, you could just override the method you are
calling, call super and rescue NoMatchingRow, and raise an new exception
that included the id.
In terms of supporting it by default, NoMatchingRow could not be used,
since it is not specific to primary keys. We would have to create a new,
model-specific exception class, such as NoMatchingRowForPrimaryKey. I'm
not sure the benefit of that would be worth the cost, but I'm open to
feedback on the idea.
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.