HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.14k stars 656 forks source link

SPOD broken #3828

Closed ncannasse closed 9 years ago

ncannasse commented 9 years ago

After updating, I can no longer compile my SPOD classes (long time not touched this)

class Key extends sys.db.Object {

    public var id : SId;
    public var encKey : haxe.io.Bytes;
    @:relation(uid)
    public var user : SNull<User>;
}

It complains about Unexpected id type (DInt), use either SId, SUid, SBigID or SString I'm not sure why ? uid should be DInt there, SId being the primary key.

Also, we should not use throw here but error() and report the correct position the error occurs in user code.

Seems like @sebpatu #2970 is the cause, @waneck since you merged it you take responsibility : I'm awaiting for your cut finger :)

waneck commented 9 years ago

Can you show me how your User class looks like?

waneck commented 9 years ago

I think that should fix it. Can you check?

waneck commented 9 years ago

Hmmm travis is failing now. Wait a sec before you try

sebpatu commented 9 years ago

Does not the related field (uid from User) needs to be an ID field to ensure the relationship to be valid? if its only DInt, we're not sure it uniq, but its mandatory for the relation, or i miss something?

Le 02/02/2015 11:22, Nicolas Cannasse a écrit :

After updating, I can no longer compile my SPOD classes (long time not touched this)

|class Key extends sys.db.Object {

 public var id : SId;
 public var encKey : haxe.io.Bytes;
 @:relation(uid)
 public var user : SNull<User>;

} |

It complains about |Unexpected id type (DInt), use either SId, SUid, SBigID or SString| I'm not sure why ? |uid| should be DInt there, SId being the primary key.

Also, we should not use |throw| here but |error()| and report the correct position the error occurs in user code.

Seems like @sebpatu https://github.com/sebpatu #2970 https://github.com/HaxeFoundation/haxe/pull/2970 is the cause, @waneck https://github.com/waneck since you merged it you take responsibility : I'm awaiting for your cut finger :)

— Reply to this email directly or view it on GitHub https://github.com/HaxeFoundation/haxe/issues/3828.

waneck commented 9 years ago

It should be fixed now, @ncannasse

delahee commented 9 years ago

@Simn @waneck

teste with 3.2rc1 Hi !

We have heap load of spod classes broken here.

we have something like that :

package db;
@:skip
class BaseUser extends sys.db.Object {
    public var id : SInt; //changing to SId allows compilation...
...
    @:relation(ruid)
    public var refUser : SNull<User>;
}
package db;
class User extends baseUser{
}

error prints : ../twinBase/base/db/BaseUser.hx:25: characters 8-34 : Unexpected id type $t for the relation. Use either SId, SInt, SUId, SUInt, SBigID, SBigInt or SString

If i change SInt to SId , it works...I belive this use case should still be valid.

Thanks !

Simn commented 9 years ago

Yeah the code and error message don't really match up there.

Simn commented 9 years ago

@waneck: You'll have to address this before I can make a release.

waneck commented 9 years ago

I'll tackle this today. Sorry for taking so long!

waneck commented 9 years ago

@delahee , while the error message seems to be bad, you really haven't defined any id for the BaseUser class. I don't even know how this used to work before!

waneck commented 9 years ago

Hmm okay, it seems that SPOD automatically considered the id variable as the ID. I'll handle this then.