Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect saving of empty translation values to the database #456

Open
a1ex7 opened this issue Aug 28, 2024 · 1 comment
Open

Incorrect saving of empty translation values to the database #456

a1ex7 opened this issue Aug 28, 2024 · 1 comment

Comments

@a1ex7
Copy link

a1ex7 commented Aug 28, 2024

✏️ Describe the bug

When saving translations, some of which have an empty value (null or empty string), only the last value is written to the database.

↪️ To Reproduce

Execute

$promotion->replaceTranslations('name', [
    "uk" => "Діти від 10 до 15 років",
    "ru" => "Дети от 10 до 15 лет",
    "en" => "Children from 10 to 15 years old",
    "pl" => "Podziewać od 10 do 15 lat",
    "de" => null,
    "cs" => null,
    "fr" => null,
    "es" => null,
    "it" => null,
]);

$promotion->save();

Then execute

$promotion->getTranslations('name');

The result will be correct
image

But in the value saved in the database we see the following

$promotion->getOriginal('name');

image

✅ Expected behavior

[
    "uk" => "Діти від 10 до 15 років",
    "ru" => "Дети от 10 до 15 лет",
    "en" => "Children from 10 to 15 years old",
    "pl" => "Podziewać od 10 do 15 lat",
    "de" => null,
    "cs" => null,
    "fr" => null,
    "es" => null,
    "it" => null,
]

or

[
    "uk" => "Діти від 10 до 15 років",
    "ru" => "Дети от 10 до 15 лет",
    "en" => "Children from 10 to 15 years old",
    "pl" => "Podziewać od 10 do 15 lat",
]
@freekmurze
Copy link
Member

Could you submit a PR to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants