On Mon, Jan 18, 2010 at 4:37 AM, Koen Deforche <[email protected]> wrote: > Good point, I hadn't consider many-to-many between the same class.
Common thing for hierarchal trees like the groups example above. :) On Mon, Jan 18, 2010 at 4:37 AM, Koen Deforche <[email protected]> wrote: >> perhaps let hasMany take a 5th parameter that lets you name the >> variable this side represents in the ManyToMany table so I could do >> something like this: >> /* snip */ >> dbo::hasMany(a, groups, dbo::ManyToMany, >> "Group_Group_Link", >> "Group_id_parent"); >> dbo::hasMany(a, isSubGroupOf, dbo::ManyToMany, >> "Group_Group_Link", >> "Group_id_child"); >> /* snip */ > > Perhaps this is the more elegant solution; we can make the 5th > argument optional. This is how SqlAlchemy does it (I *love* SqlAlchemy, you might look at it for ideas, it has changed a lot while it has been out and settled on its current design as the most powerful and expressive and simple to use). On Mon, Jan 18, 2010 at 4:37 AM, Koen Deforche <[email protected]> wrote: > You should be running the latest git version of a few seconds ago! > You'll notice the improvement :-) Hehe, I shall update soonish, maybe tonight. On Mon, Jan 18, 2010 at 4:37 AM, Koen Deforche <[email protected]> wrote: >> And we need a way to redefine an existing table, at the very least to >> add columns to it so I do not have to save out and re-enter my data >> every time I make a change. Even something like setting a static >> version number to the entity class along with a function that lets me >> describe change from version to version would be perfect, then I can >> say what to remove, what to add, how to reformat something, etc... >> propagating all the way through the changes. > > Yes we need that. But we need ideas to keep this simple too. As stated, I like a good versioning upgrade system, that is how I did it in SqlAlchemy (it did not have native things to do that, but was still able to bypass it enough to do that, would be great to have it built in, remind me later when I have time and I can mock-up some code that could demonstrate how it can be done). On Mon, Jan 18, 2010 at 6:45 AM, Koen Deforche <[email protected]> wrote: >> The fact that Wt::Dbo automatically does schema creation entails >> that it includes schema and schema object creation policy. >> >> - Could you spell out the Wt::Dbo policy for database management is? > > Wt::Dbo was created for the case of a typical web application. All > data is accessed through a single database user. Most (if not all) > database access is through Wt::Dbo. > > You can let Wt::Dbo create a schema for you (which is mostly a > convenience during development), or you can manage the schema yourself > (which is what you will end up doing during deployment). You are not > obliged to use schema creation of Wt::Dbo, and as such I would not > consider that Wt::Dbo has a policy there. > > The term 'database management' is quite generic and overloaded; what > exactly do you refer to ? I like that it can handle the creation optionally (ala SqlAlchemy, very similar design), but it does need some ways to be able to manipulate it, that is one shortcoming of SqlAlchemy, you have to bypass all its nice, pretty, and optimized interface to do such things. On Mon, Jan 18, 2010 at 6:45 AM, Koen Deforche <[email protected]> wrote: >> I fair that Wt::Dbo is a way for Emweb to make other peoples mistakes (see >> this thread for example), > > So I found out that there are two categories of programmers when you > involve a database. > > Some people believe that ORMs are silly because they create additional > problems and do not solve any. They believe that you should use all > the bells and whistles of your database and not be restricted by any > layer in between. Then there are other people (I guess like me) who > have developed several applications using Hibernate or an other ORM > tool and were pleased to be able to conveniently manipulate the > database from within his object oriented language, and were also > pleased they could tell their customer to deploy using the database > that they feel most comfortable with. I can be either depending on my problem domain, for web pages I am generally the latter unless I need something super-optimized for whatever reason. On Mon, Jan 18, 2010 at 6:45 AM, Koen Deforche <[email protected]> wrote:> But it seems that our users cannot agree on the one thing, and looking > at the applications that people develop with Wt, there is a diversity > that I would never have predicted beforehand. And I am happy to see > that, but it means that yes we still need to work hard on improving Wt > and extending it in all directions and there are more directions than > we originally anticipated. > > But perhaps you should just indicate of what is on your wishlist > instead of saying what isn't. I am definitely pushing for little enhancements and bug fixes as I find the need (I have made a few new features myself, should figure out what would be useful to others, I made a new WMenuItem that has an X that will close it when clicked on, would that be useful? Perhaps I could make it even more generic, WMenuItem is surprisingly hard to use, had to change a lot of it...). And I have also found a new bug, let me explain it with code: Here I am making some basic categories, specifically look at the where the parent's are set dbo::ptr<Forum_Category> forum_CategoryGeneral = add(new Forum_Category()); dbo::ptr<Forum_Category> forum_CategoryGeneralIdeas = add(new Forum_Category()); dbo::ptr<Forum_Category> forum_CategoryGeneralOffTopic = add(new Forum_Category()); dbo::ptr<Forum_Category> forum_CategoryTechSupport = add(new Forum_Category()); dbo::ptr<Forum_Category> forum_CategoryPrivate = add(new Forum_Category()); Forum_Category *_forum_CategoryGeneral = forum_CategoryGeneral.modify(); Forum_Category *_forum_CategoryGeneralIdeas = forum_CategoryGeneralIdeas.modify(); Forum_Category *_forum_CategoryGeneralOffTopic = forum_CategoryGeneralOffTopic.modify(); Forum_Category *_forum_CategoryTechSupport = forum_CategoryTechSupport.modify(); Forum_Category *_forum_CategoryPrivate = forum_CategoryPrivate.modify(); _forum_CategoryGeneral->name = "General"; _forum_CategoryGeneralIdeas->name = "Ideas, Wishlists, and bug reports"; _forum_CategoryGeneralOffTopic->name = "Off-Topic"; _forum_CategoryTechSupport->name = "Tech Support"; _forum_CategoryPrivate->name = "Private Area"; _forum_CategoryGeneral->description = "General section for any generally related thing that does not go in other categories"; _forum_CategoryGeneralIdeas->description = "Ideas for changes to any part of this site and bug reports of things that should be fixed"; _forum_CategoryGeneralOffTopic->description = "Anything not directly related to this site"; _forum_CategoryTechSupport->description = "Tech support, help, etc... for things not related to this site (otherwise goto the ideas and bugs forum since it probably is one if you have to ask or remark about something"; _forum_CategoryPrivate->description = "A private board that only certain users can see"; _forum_CategoryGeneralIdeas->parent = forum_CategoryGeneral; // Parents are set here! _forum_CategoryGeneralOffTopic->parent = forum_CategoryGeneral; _forum_CategoryGeneral->ordering = 0; _forum_CategoryGeneralIdeas->ordering = 100; _forum_CategoryGeneralOffTopic->ordering = 200; _forum_CategoryTechSupport->ordering = 300; _forum_CategoryPrivate->ordering = 400; _forum_CategoryGeneral->permCanView = _permViewGenericForumCategory->name; _forum_CategoryGeneralIdeas->permCanView = _permViewGenericForumCategory->name; _forum_CategoryGeneralOffTopic->permCanView = _permViewGenericForumCategory->name; _forum_CategoryTechSupport->permCanView = _permViewGenericForumCategory->name; _forum_CategoryPrivate->permCanView = "ViewForumCategory_PrivateTest"; And it generates this SQL: CREATE TABLE Forum_Category( id integer primary key autoincrement, version integer not null, "name" text not null, "description" text not null, "parent_id" integer references "Forum_Category"("id"), "ordering" integer not null, "permCanView" text not null, "permCanPost" text not null, "permCanReply" text not null ); INSERT INTO "Forum_Category" VALUES(1,0,'General','General section for any generally related thing that does not go in other categories',NULL,0,'ViewForumCategory_Generic','',''); INSERT INTO "Forum_Category" VALUES(2,0,'Ideas, Wishlists, and bug reports','Ideas for changes to any part of this site and bug reports of things that should be fixed',1,100,'ViewForumCategory_Generic','',''); INSERT INTO "Forum_Category" VALUES(3,0,'Private Area','A private board that only certain users can see',1,400,'ViewForumCategory_PrivateTest','',''); INSERT INTO "Forum_Category" VALUES(4,0,'Off-Topic','Anything not directly related to this site',1,200,'ViewForumCategory_Generic','',''); INSERT INTO "Forum_Category" VALUES(5,0,'Tech Support','Tech support, help, etc... for things not related to this site (otherwise goto the ideas and bugs forum since it probably is one if you have to ask or remark about something',1,300,'ViewForumCategory_Generic','',''); Now, what you may notice is that parent_id is null for General, but it is 1 for everything else, although only 2 of them are supposed to be set to 1 where the others are supposed to be null. My thought is that something is not being cleared out between runs since it seems to be inheriting values from past sets if the parent is null. As a test, I set: _forum_CategoryGeneralOffTopic->parent = forum_CategoryGeneralIdeas; So OffTopic will be set to 2 for parent_id while the Ideas should still be 1 and the rest 'should' be null. When run it generates this SQL: CREATE TABLE Forum_Category( id integer primary key autoincrement, version integer not null, "name" text not null, "description" text not null, "parent_id" integer references "Forum_Category"("id"), "ordering" integer not null, "permCanView" text not null, "permCanPost" text not null, "permCanReply" text not null ); INSERT INTO "Forum_Category" VALUES(1,0,'Tech Support','Tech support, help, etc... for things not related to this site (otherwise goto the ideas and bugs forum since it probably is one if you have to ask or remark about something',NULL,300,'ViewForumCategory_Generic','',''); INSERT INTO "Forum_Category" VALUES(2,0,'Private Area','A private board that only certain users can see',NULL,400,'ViewForumCategory_PrivateTest','',''); INSERT INTO "Forum_Category" VALUES(3,0,'General','General section for any generally related thing that does not go in other categories',NULL,0,'ViewForumCategory_Generic','',''); INSERT INTO "Forum_Category" VALUES(4,0,'Ideas, Wishlists, and bug reports','Ideas for changes to any part of this site and bug reports of things that should be fixed',3,100,'ViewForumCategory_Generic','',''); INSERT INTO "Forum_Category" VALUES(5,0,'Off-Topic','Anything not directly related to this site',4,200,'ViewForumCategory_Generic','',''); Oh hey, look at that, the Ideas one is set to General (which is 3 in this iteration apparently, deterministic it is not, but do not care about that), and the rest are null as expected, since apparently they happened *before* the others that were set. Lets change that line to this now: _forum_CategoryGeneralOffTopic->parent = forum_CategoryTechSupport; And that generated: CREATE TABLE Forum_Category( id integer primary key autoincrement, version integer not null, "name" text not null, "description" text not null, "parent_id" integer references "Forum_Category"("id"), "ordering" integer not null, "permCanView" text not null, "permCanPost" text not null, "permCanReply" text not null ); INSERT INTO "Forum_Category" VALUES(1,0,'General','General section for any generally related thing that does not go in other categories',NULL,0,'ViewForumCategory_Generic','',''); INSERT INTO "Forum_Category" VALUES(2,0,'Ideas, Wishlists, and bug reports','Ideas for changes to any part of this site and bug reports of things that should be fixed',1,100,'ViewForumCategory_Generic','',''); INSERT INTO "Forum_Category" VALUES(3,0,'Private Area','A private board that only certain users can see',1,400,'ViewForumCategory_PrivateTest','',''); INSERT INTO "Forum_Category" VALUES(4,0,'Tech Support','Tech support, help, etc... for things not related to this site (otherwise goto the ideas and bugs forum since it probably is one if you have to ask or remark about something',1,300,'ViewForumCategory_Generic','',''); INSERT INTO "Forum_Category" VALUES(5,0,'Off-Topic','Anything not directly related to this site',4,200,'ViewForumCategory_Generic','',''); Hmm, this is interesting, Ideas is general this time (General is back to 1 this iteration nicely), but look, Private Area is also set to 1, although its parent was null in the code, meaning it should be NULL here, but instead it inherited the value of the one in the last iteration. Oh hey, Tech Support did the same thing, also set to 1 when it should be NULL, and Off-Topic is set to 4 as it should be. So yes, it appears that for Wt::Dbo::Ptr's their nullness does not propagate as it should when being saved to things. This is a rather big, irritating, and non-deterministic bug (deterministic once compiled, but at compile time it seems to make a nice random order to things). Right now I am working around it by running sqlite3 on the database and setting those to null manually, but I keep forgetting to do that considering how often I clear the DB, plus it is happening to other tables too with identical circumstances, which is throwing a lot of stuff off. Had fun first trying to figure out what was happening randomly until I "sqlite3 mydb.db .dump" and saw that things where not what I was telling them to set as, gotta love those moments of realization. :) ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
