-
Notifications
You must be signed in to change notification settings - Fork 25
Sluggable _makeUnique is buggy #21
Comments
How so? Number 4 wouldn't generate "abc-1" as "abc" doesn't exist, it would stay as "abc". |
Because you are using LIKE to check the slug. So the conditions is [slug LIKE] => 'abc%'. Which will return count as 1. That is how you get 'abc-1' at the Number 4. Hope it is clear. |
I'll have to change the LIKE logic then, because I guess "abcd" will also trigger it. |
Rewrote the queries. |
This will not work. For example:
You will see point 2 and 3 are producing the same slug. Why do not you just use a while loop to check the uniqueness of the slug? |
It runs 2 queries, so if our slug was abc. 1st query - If abc does not exist, then abc is the slug, else... The queries aren't doing an &&, they are 2 separate queries. |
My point 3 is saying: 1st query: abc exists, and $count = 1 , so continue to 2nd query You see the problem here? point 2 and 3 are producing the same slug. |
I just need to fix that if statement, one sec. |
_makeUnique functions checks the slug and append a count. This is not a correct way to make it unique.
e.g.
BUG: now we have two records with slug 'abc-1'.
The text was updated successfully, but these errors were encountered: