Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date range call with id query always returns empty set #232

Open
deepcover96 opened this issue Oct 16, 2014 · 3 comments
Open

Date range call with id query always returns empty set #232

deepcover96 opened this issue Oct 16, 2014 · 3 comments

Comments

@deepcover96
Copy link

this works:
model.Person.all({createdAt: {lt: ltVal, gt: gtVal}}, ...

this also works:
model.Person.all({id: ids, createdAt: {lt: ltVal}}, ...

this returns an empty set, even though it should return rows
model.Person.all({id: ids, createdAt: {lt: ltVal, gt: gtVal}}}, ...

seems like using a date range with an id will return an empty array every time
I tested with 13.0.4

here's what I see in the SQL, here's a good one
model.Person.all({id: ids, createdAt: {gte: gte}}, ...

SELECT FROM persons ... WHERE (persons."created_at" >= '2014-10-15T18:44:09.119' AND persons."id" IN ('723C3381-6ABB-5C37-4F99-B1AFF280940A', '14833DAB-D083-67D4-5D77-880A6BD93227', '05FF3F6B-B637-5D85-8533-B766ECC9AA4B'));

and now a problematic one
model.Person.all({id: ids, createdAt: {lt: ltVal, gt: gtVal}}}, ...

SELECT FROM persons ... WHERE (persons."created_at" >= '2014-10-16T07:00:00.000' AND persons."created_at" <= '2014-10-17T06:59:59.999' AND persons."id" >= NULL AND persons."id" <= NULL);
@danfinlay
Copy link
Contributor

Id >= null, eh? That sure looks buggy to me.

@mde
Copy link
Contributor

mde commented Oct 21, 2014

I can't repro this. I added a test for it, "test all, using id-range, and less-than-or-equal and greater-than-or-equal with createdAt":

409ccc0

The tests pass in all the supported adapters:

https://travis-ci.org/geddy/model/builds/38560682

Here's the generated SQL for the auto-increment ID tests (UUID string yields the same results):

SELECT "people"."id" AS "Person#id", "people"."created_at" AT TIME ZONE 'UTC' AS "Person#createdAt", "people"."updated_at" AT TIME ZONE 'UTC' AS "Person#updatedAt", "people"."family_name" AS "Person#familyName", "people"."given_name" AS "Person#givenName", "people"."title" AS "Person#title", "people"."description" AS "Person#description", "people"."child_person_id" AS "Person#childPersonId", "people"."admin_event_id" AS "Person#adminEventId", "people"."owner_event_id" AS "Person#ownerEventId"
FROM people people
WHERE ("people"."id" IN (916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935) AND "people"."created_at" <= '2014-10-21T01:30:48.990' AND "people"."created_at" >= '2014-10-21T01:30:38.990');

Could you provide a bit more information? It sounds like you're using Geddy v13, which is Model v6.

@deepcover96
Copy link
Author

OK. Hmm. Only thing that I see different is that I'm using UUID strings as IDs and you're using integers.

I tried it with v0.12.12 (model 0.5.16) and 13.0.4 (model 6.0.1) with the same results. I'll go through it tomorrow to make sure that the problem is real and report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants