CStatElement with join bugfix #2049

merged 4 commits into from Jan 29, 2013


2 participants

Yiivgeny commented Jan 28, 2013

Model stat-relation defined with ambigous fields:

public function relations() {
    return array(
        'someRelation' => array(
            'join' => "JOIN `another_table` AS `r` ON `r`.`primary_id` = `t`.`primary_id`"

throws exception: Integrity constraint violation: 1052 Column 'primary_id' in field list is ambiguous. The SQL statement executed was:

SELECT `primary_id` AS `c`, COUNT(*) AS `s` 
FROM `task` `t` 
JOIN `another_table` AS `r` ON `r`.`primary_id` = `t`.`primary_id`  
WHERE (`t`.`primary_id`='2560') 
GROUP BY `primary_id`

samdark was assigned Jan 28, 2013


samdark commented Jan 28, 2013

Looks good for me. Please add a changelog line and we'll merge it.


Yiivgeny commented Jan 28, 2013

@samdark, fixed

@samdark samdark commented on an outdated diff Jan 29, 2013

@@ -14,6 +14,7 @@ Version 1.1.14 work in progress
- Bug #1984: CDbMigration: fix of undeclared variable usage in debug information in dropPrimaryKey (papulovskiy)
- Bug #1996: Using yiic help for commands with parameters with array as default value resulted in PHP error with latest PHP versions (dInGd0nG, samdark)
- Bug #2030: Fixed problem with MySQL 4.x: Undefined Index: Comment in CMysqlSchema (cebe)
+- Bug: CStatElement relation with join option throw exception when key-field present on joined table (Yiivgeny)

samdark Jan 29, 2013


Need #2049 here and it should be sorted properly.


Yiivgeny commented Jan 29, 2013

@samdark, fixed

@samdark samdark added a commit that referenced this pull request Jan 29, 2013

@samdark samdark Merge pull request #2049 from Yiivgeny/stat-relation-bugfix
CStatElement with join bugfix

@samdark samdark merged commit 479f4cd into yiisoft:master Jan 29, 2013


samdark commented Jan 29, 2013

Merged. Thanks!

Yiivgeny deleted the Yiivgeny:stat-relation-bugfix branch Jan 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment