Open ivanvermeyen opened 4 years ago
yep
Fixed by #22
Just for later reference: using a LIKE
query seems to be case insensitive too and improves compatibility with other database types than MySQL.
@ivanvermeyen
I got the same problem while using UniqueTranslationRule
validation rule with Filament.
I have a mytable.name
translatable field. Here the Filament Resource:
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->rules([
fn (Forms\Get $get) => UniqueTranslationRule::for('mytable', 'name')
->ignore($get('id')),
])
->required(),
]);
Validation works pretty well when respecting the case (I cannot use Foo
twice), but seems to fail when using different case (I can save a record with name
=Foo
and another with name
=foo
using the same locale, but I shouldn't be allowed).
Database is MySQL with utf8mb4_unicode_ci
collation.
Am I missing or doing anything wrong?
Thanks!
@ivanvermeyen Thanks for reopening the issue
@eleftrik I'm a bit lost tho as why this is not working. My tests claim that its working and when I manually try it in my own project it works too. I'm not using Filament tho. For the Filament compatibility I've been trusting people's contributions.
It seems that the
where
clause in theunique_translation
rule is case sensitive.https://github.com/codezero-be/laravel-unique-translation/blob/1eb3d56b1f4af36b4985730619838bb124436b81/src/UniqueTranslationValidator.php#L161-L164
According to my Google searches, MySQL is supposed to be case insensitive when using a collation that ends in
_ci
(I'm usingutf8mb4_unicode_ci
). But that's not what my tests are saying...Is anyone else having this issue?