-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type
Milestone
Description
What are you doing?
Querying a Postgres table with a daterange column and returning it as JSON.
const Timeline = Sequelize.define({
id: {type: Sequelize.INTEGER, primaryKey: true},
date_range: {type: Sequelize.RANGE(Sequelize.DATEONLY)}
});
const range = [
{value: new Date(Date.UTC(2017, 0, 1)), inclusive: true},
{value: new Date(Date.UTC(2017, 6, 1)), inclusive: false},
];
await Timeline.create({id: 1, date_range: range});
const row = await Timeline.findById(1);
console.log(JSON.stringify(row)); // No inclusive propertyWhat do you expect to happen?
When returning the data as JSON, the inclusive data should not be lost.
In the docs, there is this optional format for updating, this would be better because it can be turned into JSON without losing any information:
const range = [
{ value: '2017-01-01', inclusive: false },
{ value: '2017-07-01', inclusive: true },
];What is actually happening?
The inclusive property is lost. This is because the inclusive property is set on an array, and array properties are not converted into JSON (like Array.length).
{id:1, date_range: ['2017-01-01', '2017-07-01']}Dialect: postgres
Dialect version: 9.6
Database version: 9.6
Sequelize version: 4.4.3
Tested with master branch: Yes
Metadata
Metadata
Assignees
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type