@cheetah.js/orm 0.1.87 → 0.1.89

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.
@@ -206,8 +206,21 @@ class SqlJoinManager {
206
206
  const match = /\.(?<propriedade>[\w]+)/.exec(relationShip.fkKey.toString());
207
207
  const propertyKey = match ? match.groups.propriedade : '';
208
208
  const entity = this.entityStorage.get(relationShip.entity());
209
+ if (!entity) {
210
+ throw new Error(`Entity not found in storage for relationship. ` +
211
+ `Make sure the entity ${relationShip.entity().name} is decorated with @Entity()`);
212
+ }
209
213
  const property = Object.entries(entity.properties).find(([key, _value]) => key === propertyKey)?.[1];
210
- return property.options.columnName;
214
+ if (property) {
215
+ return property.options.columnName;
216
+ }
217
+ const relation = entity.relations.find(rel => rel.propertyKey === propertyKey);
218
+ if (relation && relation.columnName) {
219
+ return relation.columnName;
220
+ }
221
+ throw new Error(`Property or relation "${propertyKey}" not found in entity "${entity.tableName}". ` +
222
+ `Available properties: ${Object.keys(entity.properties).join(', ')}. ` +
223
+ `Available relations: ${entity.relations.map(r => r.propertyKey).join(', ')}`);
211
224
  }
212
225
  getTableName() {
213
226
  const tableName = this.entity.tableName || this.model.name.toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cheetah.js/orm",
3
- "version": "0.1.87",
3
+ "version": "0.1.89",
4
4
  "description": "A simple ORM for Cheetah.js",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
@@ -55,5 +55,5 @@
55
55
  "bun",
56
56
  "value-object"
57
57
  ],
58
- "gitHead": "f7ded7894ef2218a131a9275756477b43d0ae992"
58
+ "gitHead": "466942b8f3150372473238d0860408d0651ddd39"
59
59
  }