Extra Codegen Declarations

thread: 7 messages  |  last: about 5 years ago  |  started: tuesday, october 17, 2006, 4:11 pm pdt


#1  |  Mike Hostetler (Denver, CO) United States of America Qcodo Administrator
Tuesday, October 17, 2006, 4:11 PM PDT

I've got a quick request for an additional feature to the new QCodeGen Beta 3.  This feature specifically relates to functionality I need for QDrupal.

Because I use the same database for Drupal as well as Qcodo, I have many Drupal tables that I do not want to be included in the codegen.  The way I currently handle this is by prefixing all of my 'Qcodo' tables with something.  I then just filter out all tables that do not have that prefix, and voila!

This is a feature I'd really like to see in the main Qcodo distribution.  It's fairly trivial and I'd be happy to put together a patch.

The second feature request is very tightly coupled with the first.  There are a few cases to include tables from Drupal in my codegen, even if they do not have the special prefix.  I currently include these via a comma-delimited list.

My logic ends up to be something like this:

Skip any table that doesn't have the prefix 'qdrupal_' except tables that are in this comma seperated list $exception_list.

Thanks Mike!

#2  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Tuesday, October 17, 2006, 10:04 PM PDT

Hey Mike... yeah, actually, there have been others who have asked about similar functionality.  Is this something you'd be able to whip up?

-Me

#3  |  Mike Hostetler (Denver, CO) United States of America Qcodo Administrator
Wednesday, October 18, 2006, 7:31 AM PDT

Definitely.  I'll whip up a patch and email it to you.

I'll also try to expand the options a bit to make a little more sense.  I'm thinking adding 4 options along the same lines:

** Include Pattern (regexp)
** Include List (comma separated list)
** Exclude Pattern (regex)
** Exclude List (comma separated list)

Mike

#4  |  VexedPanda (Calgary, AB) Canada
Wednesday, October 18, 2006, 9:57 AM PDT

Ok, quick question. I have tables that I want to codegen, and include the relations to tables that I don't want to codegen. Similarly, I have tables I want to codegen without including the relations to tables I'm not going to codegen. Would it be possible for you to include those kinds of options as well (basically an “Include External Relations” switch)?

Reason being, I'm building a modular framework, so the modules should be aware of the core at design time, but not vice-versa.

I don't mind having a seperate configuration to use when doing a codegen on a module vs the core.

#5  |  Mike Hostetler (Denver, CO) United States of America Qcodo Administrator
Wednesday, October 18, 2006, 11:01 AM PDT

It is my understanding that this is not possible right now.  The reason being is that to do the relations in the codegen, you must include the related table.  Otherwise, the relation is ignored.

I am honestly not sure how this could be done.  Perhaps the best way would be simply to not write the file once it is done, that way it is nicely skipped.  However, your “LoadArrayBy*” methods wouldn't work because you wouldn't have the class files available.

#6  |  VexedPanda (Calgary, AB) Canada
Wednesday, October 18, 2006, 11:13 AM PDT

In my case, the external classes would still be generated, just using different settings.

Currently, to keep my core clean I need a mirror database without module tables to codegen the core from, and one with them, to codegen the modules, throwing out all the module-aware core classes.

So simply not writing the file, while still “including” it in the codegen sounds like a near-perfectt solution (only a little wasted CPU time).

#7  |  Mike Hostetler (Denver, CO) United States of America Qcodo Administrator
Wednesday, October 18, 2006, 12:04 PM PDT

If you could email me your email address, I will send you the updated files that support the options I just coded this morning.  Perhaps you could dig into the codegen code and send Mike a patch that would do what you need.  

You can find my email address at http://www.amountaintop.com/feedback

Mike



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.