You found a bug! We've classified it as
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
[4.1-RC1] HasOne association docs and implementation problems
(Sorry for my bad english)
Ext version tested:
ExtJs 4.1 beta 1, beta 2 , beta 3, RC1
Browser versions tested against:
- HasOne docs problem.
just check RC1 docs (not online docs) even when applies since 4.1 beta.
hasOne docs are describing the same thing as a belongsTo association. check the docs for both associations and ull see they are describing the same thing.
hasOne is not the same as belongsTo.
hasOne rc1 docs says "The owner model is expected to have a foreign key which references the primary key of the associated model"
and should say "The associated model is expected to have a foreign key which references the primary key of the owner model"
if this needs more detailed explanation just tell and ill explain but i think anyone that knows bout associations will understand this.
their diference is "where the foreign key is placed".
and anyway current hasOne is describing the same as belongsTo so if that were correct not point to have a hasOne association.
this correction is important because helps to understand what its implemented.
i posted this before in
besides that, the example was fixed in rc1, but still is wrong, the foreign key is bad placed (is placed as a belongsTo association)
foreign key should be placed in the address model of the example.
detailed explanation here (but this post is old and didnt know bout rc1 lil fix, but still applies)
- hasOne source code problem
setter is doing the same thing as belongsTo does, i guess because is trying to implement what docs says, but after you check docs are wrong then the implementation needs to change.
setter is setting a misplaced foreignKey, and getter does the same thing.
it explained here, it was posted for beta3 but still applies for RC1
please read those posts they are detailed and posted fixs for the implementation.
We will fix the documentation up
but its not just the documentation, and documentation actually is not the important part, doesnt matter is docs are wrong if code works fine, hasOne source code is doing what a belongsTo has to do, hasOne is not really implemented.
+1 for "hasOne" ... it´s more clear than "belongsTo"
So the problem between hasOne and belongsTo will not be resolved? I think dedoz has a point. At this point hasOne and belongsTo are the same, but they should differ and their docs should be updated accordingly. And there is matter of wheter to use hasOne or use hasMany istead?
This bug is still open so there is no reason to question if it will be resolved or not. If it was closed then I would question that.
Originally Posted by kiczor