Skip to content

Range bounds are not applied #8176

@skilFullGH

Description

@skilFullGH

What you are doing?

I compare time range with inclusive bounds.

let range = [
      data.period[0],
      data.period[1]
    ]
    range.inclusive = true

const d = await model.findOne({
      where: {
        id: {
          $ne: data.id
        },
        StudentId: data.Student.id,
        TimePeriodId: data.TimePeriod.id,
        WeekDayId: data.WeekDay.id,
        level,
        period: {
          $overlap: range
        }
      }
    })

What do you expect to happen?

Query

SELECT "id", "period", "level", "studyYear", "order" FROM "AsSchedules" AS "AsSchedule" WHERE "AsSchedule"."id" != 0 AND "AsSchedule"."StudentId" = 507 AND "AsSchedule"."TimePeriodId" = 8 AND "AsSchedule"."WeekDayId" = 1 AND "AsSchedule"."level" = 1 AND "AsSchedule"."period" && '["2016-11-04 21:00:00.000 +00:00","2016-11-05 21:00:00.000 +00:00"]' LIMIT 1

What is actually happening?

But receive

SELECT "id", "period", "level", "studyYear", "order" FROM "AsSchedules" AS "AsSchedule" WHERE "AsSchedule"."id" != 0 AND "AsSchedule"."StudentId" = 507 AND "AsSchedule"."TimePeriodId" = 8 AND "AsSchedule"."WeekDayId" = 1 AND "AsSchedule"."level" = 1 AND "AsSchedule"."period" && '["2016-11-04 21:00:00.000 +00:00","2016-11-05 21:00:00.000 +00:00")' LIMIT 1

Property inclusive lost after code

options = Utils.cloneDeep(options);

in findOne() function.

Dialect: postgres
__Database version: 9.6.3
__Sequelize version: 4.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugDEPRECATED: replace with the "bug" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions