upsert method doesn't trigger any hooks for mysql adapter
- Langage dominant
- JavaScript
- Étoiles
- 2k
- Forks
- 238
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hi,
I found that the upsert method won't trigger any hook if the adapter support updateOrCreate method (mysql in my case). I debugged and found the reason in below code:
https://github.com/1602/jugglingdb/blob/04adcdbd13c9ad9ddb0b9bb0a18e4620c17f56fc/lib/model.js#L336
```javascript
if (this.schema.adapter.updateOrCreate) {
const inst = new Model(data);
this.schema.callAdapter('updateOrCreate', Model.modelName, stripUndefined(inst.toObject(true)), (err, data) => {
if (data) {
return inst.reload(callback);
}
callback(err, null);
});
} else {
...
}
```
I think it should trigger *save/update* hooks like other methods,
If you need, i can create a PR for it,
Thank you very much for a nice job!
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
The issue is in lib/model.js around line 336, where the upsert method uses adapter.updateOrCreate. Look at the save/update hooks in the same file to see how they are triggered elsewhere. Test with the MySQL adapter to confirm hooks are missing, then modify the updateOrCreate path to call the appropriate hooks. Check test files for hook-related tests to ensure the fix works.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, mysql
- Domaine
- backend, databases
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 45/100