jarrodconnolly / sequelize-slugify

Sequelize Slugify is a plugin for the Sequelize ORM that automatically creates and updates unique, URL safe slugs for your database models.
https://sequelize-slugify.nestedquotes.ca/
MIT License
56 stars 27 forks source link

forceGenerateSlug ignored if nothing changed #44

Closed shem8 closed 3 years ago

shem8 commented 3 years ago

I want to add a slug field to my model. I'm trying to do so with a new migration in using regenerateSlug for all the model's instances, but I keep getting null as the slug. Looks like it's because forceGenerateSlug is ignored when nothing changed on the model: https://github.com/jarrodconnolly/sequelize-slugify/blob/4a6d98adecd4fc431dfdc8dfe234f9bbe98dda81/lib/sequelize-slugify.js#L33

gmmrx commented 3 years ago

@jarrodconnolly can you look at this please? some models are having null slugs probably because of this.

jarrodconnolly commented 3 years ago

Thank you, taking a look. The PR seems reasonable, though I would like some tests around this before merging.

jarrodconnolly commented 3 years ago

I added a test that does fail before your change and passes after, I believe this is the scenario you may be running into. Let me know if that makes sense.

jarrodconnolly commented 3 years ago

Published v1.3.2 with this change.

jarrodconnolly commented 3 years ago

@shem8 Going to close this as the change has been published.

@jrsakizci If you are seeing models with null slugs for another reason please file another issue with some details relating to that use case.