pangea-server 1.0.59 → 1.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ class Db {
16
16
  const { scopes, attributes, order, paranoid = true } = options;
17
17
  const scopedModel = scopes?.length ? model.scope(...scopes) : model;
18
18
  const baseOptions = {
19
- attributes: getFinalAttributes(attributes),
19
+ attributes: getFinalAttributes(model, attributes),
20
20
  paranoid,
21
21
  subQuery: false,
22
22
  transaction: this.__tx,
@@ -81,7 +81,7 @@ class Db {
81
81
  };
82
82
  }
83
83
  return {
84
- attributes: getFinalAttributes(attributes),
84
+ attributes: getFinalAttributes(model, attributes),
85
85
  ...getInclude(model, { attributes, where: { ...where, ...searchWhere } }),
86
86
  ...(group && { group: group.map(pangea_helpers_1.camelToSnake) }),
87
87
  order: getFinalOrder(order),
@@ -183,14 +183,17 @@ class Db {
183
183
  }
184
184
  exports.Db = Db;
185
185
  // internal functions
186
- function getFinalAttributes(attributes) {
186
+ function getFinalAttributes(model, attributes) {
187
187
  if (!attributes)
188
188
  return;
189
189
  return Object.entries(attributes).map(([alias, column]) => {
190
- if (typeof column === 'string')
191
- return [(0, sequelize_1.col)((0, pangea_helpers_1.camelToSnake)(column)), alias];
192
- const [op, field] = column;
193
- return [(0, sequelize_1.fn)(op, (0, sequelize_1.col)((0, pangea_helpers_1.camelToSnake)(field))), alias];
190
+ if (typeof column === 'string') {
191
+ const field = column.includes('.') ? column : `${model.name}.${(0, pangea_helpers_1.camelToSnake)(column)}`;
192
+ return [(0, sequelize_1.col)(field), alias];
193
+ }
194
+ const [op, fieldName] = column;
195
+ const field = fieldName.includes('.') ? fieldName : `${model.name}.${(0, pangea_helpers_1.camelToSnake)(fieldName)}`;
196
+ return [(0, sequelize_1.fn)(op, (0, sequelize_1.col)(field)), alias];
194
197
  });
195
198
  }
196
199
  function convertWhereKeys(obj) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "1.0.59",
4
+ "version": "1.0.60",
5
5
  "files": [
6
6
  "dist"
7
7
  ],