fix: change products.canonical_name to TEXT, trim whitespace on import
VARCHAR(255) was too narrow for some OpenFoodFacts product names. Switching to TEXT removes the length constraint entirely. Also trim whitespace from resolved canonical names during import. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -209,9 +209,9 @@ func run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve canonical name: prefer English, fall back to any language.
|
// Resolve canonical name: prefer English, fall back to any language.
|
||||||
canonicalName := record.ProductNameEN
|
canonicalName := strings.TrimSpace(record.ProductNameEN)
|
||||||
if canonicalName == "" {
|
if canonicalName == "" {
|
||||||
canonicalName = record.ProductName
|
canonicalName = strings.TrimSpace(record.ProductName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply filter rules.
|
// Apply filter rules.
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ CREATE TABLE product_category_translations (
|
|||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
CREATE TABLE products (
|
CREATE TABLE products (
|
||||||
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
||||||
canonical_name VARCHAR(255) NOT NULL,
|
canonical_name TEXT NOT NULL,
|
||||||
category VARCHAR(50) REFERENCES product_categories(slug),
|
category VARCHAR(50) REFERENCES product_categories(slug),
|
||||||
default_unit VARCHAR(20) REFERENCES units(code),
|
default_unit VARCHAR(20) REFERENCES units(code),
|
||||||
barcode TEXT UNIQUE,
|
barcode TEXT UNIQUE,
|
||||||
|
|||||||
Reference in New Issue
Block a user