fix(shopping): capitalisation 1re lettre — catalogue + migration BDD v0.4.9
- CatalogueModal : cleanForm() capitalise désormais le nom avant envoi API (création et modification d'article) - Migration 005 : met à jour shopping.products.name et shopping.list_items.custom_name pour capitaliser les données existantes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""005 - capitaliser la première lettre des noms produits et articles libres
|
||||
|
||||
Revision ID: 005
|
||||
Revises: 004
|
||||
Create Date: 2026-05-25
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision = '005'
|
||||
down_revision = '004'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
UPDATE shopping.products
|
||||
SET name = UPPER(SUBSTRING(name, 1, 1)) || SUBSTRING(name, 2)
|
||||
WHERE name IS NOT NULL
|
||||
AND name != ''
|
||||
AND UPPER(SUBSTRING(name, 1, 1)) || SUBSTRING(name, 2) != name
|
||||
""")
|
||||
op.execute("""
|
||||
UPDATE shopping.list_items
|
||||
SET custom_name = UPPER(SUBSTRING(custom_name, 1, 1)) || SUBSTRING(custom_name, 2)
|
||||
WHERE custom_name IS NOT NULL
|
||||
AND custom_name != ''
|
||||
AND UPPER(SUBSTRING(custom_name, 1, 1)) || SUBSTRING(custom_name, 2) != custom_name
|
||||
""")
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -85,9 +85,14 @@ export default function CatalogueModal({ stores, onClose }: CatalogueModalProps)
|
||||
setError(null)
|
||||
}
|
||||
|
||||
function capitalize(s: string): string {
|
||||
const t = s.trim()
|
||||
return t.charAt(0).toUpperCase() + t.slice(1)
|
||||
}
|
||||
|
||||
function cleanForm(f: ProductCreate): ProductCreate {
|
||||
return {
|
||||
name: f.name.trim(),
|
||||
name: capitalize(f.name),
|
||||
brand: f.brand?.trim() || undefined,
|
||||
category: f.category?.trim() || undefined,
|
||||
description: f.description?.trim() || undefined,
|
||||
|
||||
Reference in New Issue
Block a user