balderdashy / balderdashy/sails

Sails model is not populating columns with __c in case of Join.

Open
#7,167 5 comments 0 reactions 0 assignees View on GitHub
what do you think?
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**Node version**: v12.18.4
**Sails version** _(sails)_: 1.4.0
**ORM hook version** _(sails-hook-orm)_: 2.1.1
**Sockets hook version** _(sails-hook-sockets)_: 2.0.0
**DB adapter & version** _(e.g. sails-mysql@5.55.5)_: sails-postgresql@2.0.0


I have 3 models. In the first model, I am associating the other 2 models. This all works perfectly and I am able to get the data from the other 2 models. The issue is for the parent model where I have defined the associations, not all the attributes are populated.

Only attributes with normal column name i.e. Id, name get populated but other columns such as test__c or a_b__c don't get populated.

I have tried this format:

```
metadata: {
type: 'string',
columnName: 'additional_data__c',
allowNull: true
},
```
and this as well

```
'additional_data__c': {
type: 'string'
},
```
But in both cases, this attribute gets skipped and does not get populated in final response.

I was checking the **sails-postgresql code**, and there was code to divide attributes based on parents and children if columnName has **__c** in it. But seems like children columns never get populated back.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the join with three associated models and the reported __c column names, then inspect the sails-postgresql code that divides attributes into parent and child columns. Done means joined results populate attributes such as test__c and a_b__c while preserving normal columns.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.