Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.2
-
Fix Version/s: None
-
Component/s: I18n
-
Labels:None
-
Environment:problem arises \w Symfony 1.4.6 on Mac OS X 10.6.4 with Mysql 5.1.38 and a also on Ubuntu 10.04 Lucid \w bundled Apache 2.2.14 and Mysql 5.1.41
Description
config/doctrine/schema.yml:
JobeetCategory:
actAs:
Timestampable: ~
I18n:
fields: [name]
columns:
id:
type: integer(4)
primary: true
autoincrement: true
num:
type: integer(4)
name:
type: string(255)
notnull: true
lib/form/doctrine/JobeetCategoryForm.class.php:
class JobeetCategoryForm extends BaseJobeetCategoryForm
{
public function configure()
}
then running:
./symfony doctrine:generate-module --non-verbose-templates --with-show backend category JobeetCategory
surfing to:
backend_dev.php/category/new
everything looks fine but as soon as I post valid data i get the following error:
500 | Internal Server Error | Doctrine_Connection_Mysql_Exception
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-nl' for key 'PRIMARY'
And in my sql log i see it tries to execute the following (and fails):
START TRANSACTION
INSERT INTO `jobeet_category` (`created_at`, `updated_at`) VALUES ('2005-01-01 00:00:00', '2005-01-01 00:01:00')
INSERT INTO `jobeet_category_translation` (`id`, `lang`, `name`) VALUES ('1', 'nl', '2378')
INSERT INTO `jobeet_category_translation` (`id`, `lang`) VALUES ('1', 'nl_NL')
ROLLBACK
Obviously this third insert is not ok, but why is doctrine running it?
I tried the Jobeet demo locally to see if I get the same issues with editing the I18n categories in the backend, but that all runs fine..
I tried a apps/backend/config/settings.yml with:
- i18n
i18n: true
default_culture: nl
standard_helpers: [Partial, I18N]
and I also tried it commenting it all out. Still doesn't work.
I really don't know why Doctrine runs this third insert and why it is using the incorrect "nl_NL" instead of "nl".
Hi,
I had the same problem, and was able to solve it setting the culture of the user.
In my case, I had two languages: "ca" and "es" (catalan and spanish), and my default culture defined in settings.yml was "ca_ES"
Every time I tried to save a symfony form with embeded translation forms, I got an error similar to the following one:
Integrity constraint violation: 1062 Duplicate entry '3-ca' for key 'PRIMARY'
Basically, symfony or Doctrine, was trying to do 3 inserts: one with the "ca" language, one with the "es" language and one with the "ca_ES" language!
Here is the symfony log:
Oct 13 14:38:46 symfony [info] {Doctrine_Connection_Mysql} exec : SET NAMES 'UTF8' - () Oct 13 14:38:46 symfony [info] {Doctrine_Connection_Statement} execute : SELECT COUNT(*) AS num_results FROM client c WHERE c.id = ? - (1) Oct 13 14:38:46 symfony [info] {Doctrine_Connection_Statement} execute : INSERT INTO campanya (client_id, idiomes, created_at, updated_at) VALUES (?, ?, ?, ?) - (1, a:1:{i:0;s:2:"ca";}, 2010-10-13 14:38:46, 2010-10-13 14:38:46) Oct 13 14:38:46 symfony [info] {Doctrine_Connection_Statement} execute : SELECT c.id AS c__id, c.lang AS c__lang, c.slug AS c__slug FROM campanya_translation c WHERE (c.slug LIKE ? AND c.lang = ? AND c.nom = ?) - (aixo-es-una-nova-campanya-en-catala%, ca, Això és una nova campanya, en català) Oct 13 14:38:46 symfony [info] {Doctrine_Connection_Statement} execute : INSERT INTO campanya_translation (id, lang, nom, descripcio, slug) VALUES (?, ?, ?, ?, ?) - (3, ca, Això és una nova campanya, en català, Lorem ipsum dolor... Hic et nunc!, aixo-es-una-nova-campanya-en-catala) Oct 13 14:38:46 symfony [info] {Doctrine_Connection_Statement} execute : SELECT c.id AS c__id, c.lang AS c__lang, c.slug AS c__slug FROM campanya_translation c WHERE (c.slug LIKE ? AND c.lang = ? AND c.nom = ?) - (%, es, ) Oct 13 14:38:46 symfony [info] {Doctrine_Connection_Statement} execute : INSERT INTO campanya_translation (id, lang, nom, descripcio, slug) VALUES (?, ?, ?, ?, ?) - (3, es, , , ) Oct 13 14:38:46 symfony [info] {Doctrine_Connection_Statement} execute : SELECT c.id AS c__id, c.lang AS c__lang, c.slug AS c__slug FROM campanya_translation c WHERE (c.slug LIKE ? AND c.lang = ? AND c.nom IS NULL) - (%, ca_ES) Oct 13 14:38:46 symfony [info] {Doctrine_Connection_Statement} execute : INSERT INTO campanya_translation (id, lang, slug) VALUES (?, ?, ?) - (3, ca_ES, ) Oct 13 14:38:46 symfony [err] {Doctrine_Connection_Mysql_Exception} SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '3-ca' for key 'PRIMARY'Finally, I was able to solve it doing a:
$this->getUser()->setCulture('ca');
when users log into my application.
I'm using symfony 1.4.9