How do i return results from a non matching query

I’ve written a query that passed in an array and returned the results from that array ok.
I’d also like to know which values I passed that weren’t in the array.

    flash.alert  = "No matching results for ..."  + Good.where.not(sku:  @blah2).to_s

this gave me an empty string…

What about something like this?

This was executed in a bin/rails c from this sample project … for convenience here are the commands in text:

@blah2 = ['Nancy', 'Robert']
Employee.where.not(first_name: @blah2).map(&:first_name).join(', ')

hmm, maybe that’s not what i’m after.

Say, I pass in an array of [1,2,3,4,5] to a query and I get back the matching result [2,4,5]

I want to know [1,3], the params I passed that weren’t in the results.

Thanks, Joe

Wouldn’t you just want where they match as one query and then where they don’t match for the other query?

Matching items:

Good.where(sku:  @blah2)

Not matching items:

Good.where.not(sku:  @blah2)

Could you do something like this?

matching_skus = Good.where.not(sku: @blah2).pluck(:sku)
non_matching_skus = matching_skus - @blah2