Skip to content

fix(core): allow clearing the channel name on PostgreSQL - #725

Merged
navneetkumar-pim-webkul merged 2 commits into
3.xfrom
fix/1370-channel-name-nullable
Sep 24, 2026
Merged

navneetkumar-pim-webkul merged 2 commits into
3.xfrom
fix/1370-channel-name-nullable

Conversation

@navneetkumar-pim-webkul

Copy link
Copy Markdown
Collaborator

Issue Reference

Fixes https://git.webkul.com/unopim/UnoPim/-/issues/1370

Description

On PostgreSQL, removing a channel's Name/Label on edit fails with:

SQLSTATE[23502]: Not null violation: null value in column "name" of relation "channel_translations" violates not-null constraint

#569 made the channel name optional, but channel_translations.name stayed NOT NULL. On save, ConvertEmptyStringsToNull turns the cleared field into null. ChannelRepository::removeEmptyTranslations keeps that payload for a locale that already has a translation (on purpose, so clearing persists), so the update writes NULL. MySQL/MariaDB hid this because config/database.php runs them with 'strict' => false, which silently stores ''. PostgreSQL has no equivalent mode.

  • New migration makes channel_translations.name nullable. down() backfills NULL to '' before restoring NOT NULL. It uses the schema builder only, so it is prefix-safe on MySQL, MariaDB and PostgreSQL.
  • ChannelDataGrid fell back to the default locale's name only for an empty name (CHAR_LENGTH(TRIM(NULL)) is NULL), so it now wraps the requested name in COALESCE(..., '').

How To Test This?

  1. Use a PostgreSQL install (reproduced with Elasticsearch enabled too; ES is not involved).
  2. Settings → Channels → create a channel with Code, Locale, Currency and a Name, and save.
  3. Edit it, clear the Name, and save.
    • Before: "Something went wrong while saving", with the not-null violation in laravel.log.
    • After: "Update Channel Successfully".
  4. The channel grid shows the fallback-locale name (if any) for the cleared locale.
  5. vendor/bin/pest packages/Webkul/Admin/tests/Feature/Settings/ChannelTest.php. The new test "should clear the channel name when it is removed on update" fails before the fix on PostgreSQL. Run it with phpunit.pgsql.xml; MySQL non-strict passes it even without the fix.

Screenshots

After the fix on PostgreSQL, clearing the name saves successfully. Before the fix, the same save showed the generic save error and logged the 23502 violation.

Checklist

  • vendor/bin/pest passes locally (ChannelTest + ChannelActivationTest: 30 passed on PostgreSQL 16 and on MySQL 8)
  • vendor/bin/pint --test reports no style issues
  • Tailwind classes are reordered (no markup change)
  • New user-facing strings use translation keys (none added)
  • Target branch is 3.x

Also run: PHPStan on the changed files (no errors), Rector dry-run (no changes), and the migration's rollback and re-run on PostgreSQL. Playwright was not run.

Documentation

  • My pull request requires an update on the documentation repository.

The channel name became optional in #569, but channel_translations.name
stayed NOT NULL. Clearing the name on edit writes NULL, which PostgreSQL
rejects with a not-null violation; MySQL only hid it because the app runs
it non-strict, which silently stores an empty string.

Make the column nullable and have the channel datagrid fall back to the
default locale's name when the requested one is NULL as well as empty.
Copilot AI lite review requested due to automatic review settings September 24, 2026 14:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Add focused regression coverage for fallback display when the requested translation name is null.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

This pull request fixes PostgreSQL failures when clearing channel names by allowing nullable translations and handling null names in the channel grid.

Changes:

  • Adds a nullable channel_translations.name migration with rollback backfill.
  • Adds regression coverage for clearing channel names.
  • Updates grid fallback handling with COALESCE.
File Summary
packages/​Webkul/​Core/​src/​Database/​Migrations/​2026_09_24_172527_make_name_nullable_in_channel_translations_table.php Makes channel translation names nullable.
packages/​Webkul/​Admin/​tests/​Feature/​Settings/​ChannelTest.php Tests clearing a channel name.
packages/​Webkul/​Admin/​src/​DataGrids/​Settings/​ChannelDataGrid.php Handles null names during locale fallback.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/Webkul/Admin/src/DataGrids/Settings/ChannelDataGrid.php
@navneetkumar-pim-webkul
navneetkumar-pim-webkul merged commit bd9d8e2 into 3.x Sep 24, 2026
23 checks passed
@navneetkumar-pim-webkul
navneetkumar-pim-webkul deleted the fix/1370-channel-name-nullable branch September 24, 2026 15:38
@navneetkumar-pim-webkul navneetkumar-pim-webkul mentioned this pull request Sep 24, 2026
2 of 6 tasks
navneetkumar-pim-webkul added a commit that referenced this pull request Sep 24, 2026
Six merged pull requests since v3.1.1 carried no changelog entry: the
gallery unsaved badge and worker timeout handler (#713), the import filter
re-render (#720), the worker timeout alarm (#722), the channel name on
PostgreSQL (#725), the price input height (#726), and the export view
events (#717, #718). The two fixes pending in #727 and #728 are included
so the cut merges after them.

The model recommendation entry described the cheap-tier ranking that #724
replaced with newest-per-family; it now describes the shipped behaviour.

3.1.2 is a patch release, so everything is filed under bug fixes and
improvements; no feature section. Core::VERSION, package.json and the
UPGRADE.md walkthrough move to 3.1.2 together, as they did for 3.1.1.
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

Successfully merging this pull request may close these issues.

2 participants