Development

#1795 (I18n, propel-build-sql generates i18n tables with `culture` NOT NULL then tries to select with `culture` IS NULL)

You must first sign up to be able to contribute.

Ticket #1795 (new defect)

Opened 3 years ago

I18n, propel-build-sql generates i18n tables with `culture` NOT NULL then tries to select with `culture` IS NULL

Reported by: Andrejs.Verza Assigned to: fabien
Priority: major Milestone:
Component: i18n Version: 1.0.2
Keywords: propel, culture, I18n Cc:
Qualification:

Description

Symfony propel-build-sql creates the I18n table with culture column defined like:

culture VARCHAR(7) NOT NULL

Later, not having culture set in an object ...

$o = new Article();
// $o->setCulture('lv');
$o->setTitle('Test Title');
$o->setContent('Test Content');
$o->save();

... saves the object with culture set to an empty string, like:

INSERT INTO blog_article_i18n (TITLE,CONTENT,ID) VALUES ('Test Title','Test Content',1)

Therefore, the simple code like:

$o = ArticlePeer::retrieveByPk(1); // knowing the Pk is correct
$title = $o->getTitle();

... generates the following SQL (showing only the one related to the I18n table):

SELECT blog_article_i18n.TITLE, blog_article_i18n.CONTENT, blog_article_i18n.ID, blog_article_i18n.CULTURE FROM blog_article_i18n WHERE blog_article_i18n.ID=1 AND blog_article_i18n.CULTURE IS NULL

The error is that in this SQL the CULTURE is NEVER NULL by the definition, causing the right object not to be found. The CULTURE here should be an empty string.

Sugguestion: may be it would be a good idea to set any newly created objects to the current culture?

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.