Skip to content

Commit

Permalink
🐛 Use the correct model name (instead of constructor name) for schema…
Browse files Browse the repository at this point in the history
…s of a Route
  • Loading branch information
skerit committed Mar 16, 2024
1 parent 93b7df7 commit 897b9bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Fix `Alchemy.Client.Schema.isSchema(value)` never returning true
* Add support for asynchronous custom schema values in the `Schema` field class
* Make the `Controller#model` getter try to get the model from the same namespace
* Use the correct model name (instead of constructor name) for schemas of a Route

## 1.4.0-alpha.3 (2024-02-25)

Expand Down
13 changes: 6 additions & 7 deletions lib/class/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Route.setProperty(function has_type_class_checks() {
*
* @author Jelle De Loecker <[email protected]>
* @since 1.3.7
* @version 1.3.7
* @version 1.4.0
*
* @return {Schema}
*/
Expand All @@ -159,7 +159,6 @@ Route.enforceProperty(function schema(new_value) {
added_fields = {},
prefix,
param,
model_constructor,
definition;

new_value = alchemy.createSchema();
Expand All @@ -172,22 +171,22 @@ Route.enforceProperty(function schema(new_value) {
}

for (param of definition.param_definitions) {
model_constructor = param.model_constructor;
let model_name = param.model_constructor?.model_name;

if (model_constructor) {
if (model_name) {

if (added_models[model_constructor.name]) {
if (added_models[model_name]) {
continue;
}

if (added_fields[param.name]) {
continue;
}

added_models[model_constructor.name] = true;
added_models[model_name] = true;

try {
new_value.belongsTo(model_constructor.name);
new_value.belongsTo(model_name);
} catch (err) {
// Ignored
alchemy.distinctProblem('route-schema-' + this.name, 'Route schema error', {error: err});
Expand Down

0 comments on commit 897b9bf

Please sign in to comment.