class Model < ApplicationRecord
self.primary_key = [:sub_id, :id]
....
When I call find_each on it, I get results like this:
SELECT "models".* FROM "models" WHERE "model"."sub_id" = $1 AND (("models"."sub_id" > 'xxxxx-yyy-...') OR ("models"."sub_id" = 'xxxxx-yyy-...' AND "models"."id" > 'aaaaa-bb....')) ORDER BY "models"."sub_id" ASC, "models"."id" ASC LIMIT $4
But when calling with this library, I'd expect the same, but am getting different:
# frozen_string_literal: true
class MyJob < ApplicationIterationJob
BATCH_SIZE = 2
def build_enumerator(sub_id, cursor:)
enumerator_builder.active_record_on_batches(
Model.where(sub_id: sub_id),
cursor: cursor,
batch_size: BATCH_SIZE
)
end
def each_iteration(models, _sub_id)
...
end
end
results in
SELECT "models".* FROM "models" WHERE "models"."sub_id" = $1 AND (models.sub_id > 'xxxxx-yyy-....' OR (models.sub_id = 'xxxxx-yyy-....' AND (models.id > 'xxxxx-yyy-....','aaaaa-bb.....'))) ORDER BY models.sub_id,models.id LIMIT $4
ActiveRecord::StatementInvalid: PG::DatatypeMismatch: ERROR: argument of AND must be type boolean, not type record
LINE 1: ...y_id = 'xxxxx-yyy....' AND (company_f...
And it's due to the fact that (models.id > 'xxxxx-yyy-....','aaaaa-bb.....') should just be using aaaaa-bb... instead of the whole thing.
I've checked the docs, and previous tickets, but not seeing this come up.
Hello.
I have the following model:
When I call
find_each
on it, I get results like this:But when calling with this library, I'd expect the same, but am getting different:
results in
And it's due to the fact that
(models.id > 'xxxxx-yyy-....','aaaaa-bb.....')
should just be usingaaaaa-bb...
instead of the whole thing.I've checked the docs, and previous tickets, but not seeing this come up.
Relevant PR https://github.com/Shopify/job-iteration/pull/365