Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Versionable behavior, error with fk in baseX Class #282

Closed
aamsellem opened this Issue · 4 comments

3 participants

@aamsellem

I got a problem with generated class using versionable behavior in the function "populateFromVersion"

The problem appears when we use two or more tables with the versionable behavior and one of them have a id field with a fieldname not equal to "id".

It's work if two id's name is "ID" because ID field exist in both table but if one id field name is different the error appear.

schema :
A:
diff_id : { type: integer, required: true, primaryKey: true, autoIncrement: true, phpName: Id }
_propel_behaviors:

versionable: { log_created_at: true, log_created_by: true}
B:
id: ~
a_id: { type: integer, foreignTable: a, foreignReference: diff_id, default : null }
_propel_behaviors:

versionable: { log_created_at: true, log_created_by: true}

It will generate in baseA :

$c1 = $query->getNewCriterion(BPeer::DIFF_ID, $value);

instead of

$c1 = $query->getNewCriterion(BPeer::ID, $value);

in that case $query is a BQuery object.

It's seems that the problem come from here : a54ac77

@aamsellem

I think if you replace in the file generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php:

L.151 : $fkColumn = $fk->getForeignColumn();

with

L.151 : $fkColumn = $foreignVersionTable->getFirstPrimaryKeyColumn();

it fix the problem.

@fzaninotto
Collaborator

Could you create a unit test showing the problem, and proving that your fix works?

@aamsellem

I can't today, but I will try ASAP.

@aamsellem aamsellem referenced this issue from a commit in aamsellem/Propel
@aamsellem aamsellem Fix #282 versionable behavior FK in generated object classes
Fix #282 by replacing foreign key references with PrimaryKey
+ Add Phpunit test
b1f651f
@aamsellem

Finally I found some time to work on.

@aamsellem aamsellem closed this
@aamsellem aamsellem reopened this
@aamsellem aamsellem referenced this issue from a commit in aamsellem/Propel
@aamsellem aamsellem Fix #282 version able behavior FK in generated object class
Fix #282 by replacing foreign key references with PrimaryKey
+ Add Phpunit test
24ef626
@willdurand willdurand closed this issue from a commit
@aamsellem aamsellem Fix #282 versionable behavior FK in generated object classes
Fix #282 by replacing foreign key references with PrimaryKey
5ebefc3
@willdurand willdurand closed this in 5ebefc3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.