Repository navigation
Closed
Labels
type: bugDEPRECATED: replace with the "bug" issue type
Description
Set up a table with int4range attribute :
What you are doing?
module.exports = function(sequelize, DataTypes) {
return sequelize.define('test', {
id: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true
},
name: {
type: DataTypes.TEXT,
allowNull: false,
unique: true
},
interval: {
type: DataTypes.RANGE(DataTypes.INTEGER),
allowNull: false,
unique: true
}
}, {
tableName: 'test'
});
};INSERT INTO test (name, interval) VALUES ('test', '[1,4]');Perform a findAll
var query = models.test.findAll({})What do you expect to happen?
[{"id":1,"name":"test","interval":[[1],[5]]}]
-> 5 when incluse = false
What is actually happening?
[{"id":1,"name":"test","interval":[[],[]]}]
-> Bounds are empty
Debug
//lib/dialects/postgres/range.js
[...]
function parse (value, parser) {
console.log("var parser: "+ parser)
if (value === null) return null;
if (value === 'empty') {
var empty = [];
empty.inclusive = [];
return empty;
}
var result = value
.substring(1, value.length - 1)
.split(',', 2);
console.log("Before parseRangeBound, result = "+ result)
if (result.length !== 2) return value;
result = result
.map(function (value) {
return parseRangeBound(value, parser);
});
console.log("After parseRangeBound, result = "+ result)
result.inclusive = [(value[0] === '['), (value[value.length - 1] === ']')];
return result;
}Output :
Before parseRangeBound, result = 1,7
After parseRangeBound, result = ,
Dialect: postgres
Database version: 9.5
Sequelize version: 3.21.0
Metadata
Metadata
Assignees
Labels
type: bugDEPRECATED: replace with the "bug" issue type
Activity
alitaheri commentedon Jun 1, 2016
Does this still fail?
sushantdhiman commentedon Jun 20, 2016
Confirmed