Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequelize is chopping of nested key length

I have a model named ManufacturerGuideline which is nested at the 4th level. When I try to fetch the record, its chopping of ManufacturerGuideline keys length to 5 characters. Although the Key value stored in postgreSQL table has full length.

Routes:

router.get('/:manufacturer_id', function(req, res) {
  var manufacturer_id = req.params.manufacturer_id;
  models.Manufacturer.findAll({
    where: {
      id: manufacturer_id
    },
    order: [[models.ManufacturerTab, 'sequence', 'ASC']],
    include: [{
                model: models.ManufacturerTab, 
                include: [{
                  model: models.ManufacturerField, 
                  include: [models.ManufacturerGuideline]
              }]
            }
        ]
  }).
  then(function(manufacturers) {  
      res.status(200).json(manufacturers);  
  }, function(error) {  
     res.status(500).send(error);  
  });  
});

So if the column name is Manufacturer it displays as Manuf. This issue is only appearing with ManufacturerGuideline table and not with the parent associated table.

like image 834
Rahul Dagli Avatar asked Oct 17 '25 18:10

Rahul Dagli


1 Answers

I was finally able to fix the issue by specifying separate: true while including the model in the routes.

include: [{
  separate: true,
  model: models.ManufacturerGuideline
}]
like image 140
Rahul Dagli Avatar answered Oct 20 '25 08:10

Rahul Dagli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!