DB Problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DB Problem

Lee Sylvester
Hey Nicolas,

Okay, I've hit another strange problem I haven't had before using
relations in SPOD classes. I have two classes, TimeLog and Projects.
They look like this

class TimeLog extends neko.db.Object
{
    public var date : Date;
    public var time : Date;
    public var projectId : Int;

    static var TABLE_NAME = "TimeLog";
    static var TABLE_IDS = ["time"];
   
    static function RELATIONS() {
        return [ { prop : "project", key : "projectId", manager :
untyped Projects.manager } ];
    }

    public var project( dynamic, dynamic ) : Projects;
    public static var manager = new neko.db.Manager< TimeLog >( TimeLog );
}

class Projects extends neko.db.Object
{
    public var id : Int;
    public var projectName : String;

    static var TABLE_NAME = "Projects";
    static var TABLE_IDS = ["id"];

    public static var manager = new neko.db.Manager< Projects >( Projects );
}

And the database looks like this :

CREATE TABLE TimeLog
(
       date DATE NOT NULL,
       time DATETIME NOT NULL,
       projectId INTEGER NOT NULL
)

CREATE TABLE Projects
(
       id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
       projectName TEXT NOT NULL
)


However, although the initRelation method in the Manager class gets
accessed, and the get_project and set_project methods added to the
class_proto.prototype, the project property still returns null. The
Projects table does contain a value for the passed foreign key, so it's
not that thats the problem, and I've not had any problems using
relations in previous projects (going back about a year ago).

Thanks,
Lee



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: DB Problem

Lee Sylvester
Hey,

I fixed it. I had an invalid record in my Projects table :-S

Thanks anyway ;-)
Lee


Lee McColl Sylvester wrote:

> Hey Nicolas,
>
> Okay, I've hit another strange problem I haven't had before using
> relations in SPOD classes. I have two classes, TimeLog and Projects.
> They look like this
>
> class TimeLog extends neko.db.Object
> {
>    public var date : Date;
>    public var time : Date;
>    public var projectId : Int;
>
>    static var TABLE_NAME = "TimeLog";
>    static var TABLE_IDS = ["time"];
>      static function RELATIONS() {
>        return [ { prop : "project", key : "projectId", manager :
> untyped Projects.manager } ];
>    }
>
>    public var project( dynamic, dynamic ) : Projects;
>    public static var manager = new neko.db.Manager< TimeLog >( TimeLog );
> }
>
> class Projects extends neko.db.Object
> {
>    public var id : Int;
>    public var projectName : String;
>
>    static var TABLE_NAME = "Projects";
>    static var TABLE_IDS = ["id"];
>
>    public static var manager = new neko.db.Manager< Projects >(
> Projects );
> }
>
> And the database looks like this :
>
> CREATE TABLE TimeLog
> (
>       date DATE NOT NULL,
>       time DATETIME NOT NULL,
>       projectId INTEGER NOT NULL
> )
>
> CREATE TABLE Projects
> (
>       id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
>       projectName TEXT NOT NULL
> )
>
>
> However, although the initRelation method in the Manager class gets
> accessed, and the get_project and set_project methods added to the
> class_proto.prototype, the project property still returns null. The
> Projects table does contain a value for the passed foreign key, so
> it's not that thats the problem, and I've not had any problems using
> relations in previous projects (going back about a year ago).
>
> Thanks,
> Lee
>
>
>


--
haXe - an open source web programming language
http://haxe.org