Ticket #153 (new defect)

Opened 5 months ago

Last modified 5 months ago

script\generate model reports collision on plurality error

Reported by: ccornwell Assigned to:
Priority: minor Milestone: 0.9
Component: Active Support Keywords:
Cc:

Description

When I run 'script/generate model Specimen', I get the following output:

There where collisions when attempting to generate the model.
Please add force=true to the argument list in order to overwrite existing files.

Specimen should be a singular noun

and no files are created. Appending -force to the command line works around the immediate problem. However, it appears that the Inflector is interpreting 'Specimen' as a plural form, so I do not know what problems this may cause downstream. (This may need a separate bug report.)

Change History

04/24/08 17:27:50 changed by Kaste

we could add 'Specimen' as an irregular. is this a singluar-only word? I think I never saw 'specimens'.

04/24/08 18:00:02 changed by bermi

Kaste, we need a way to add irregular forms in the environment config file like in Rails

What do you think about adding this at the end of lib/AkInflector.php?

if(isset($inflections) && is_array($inflections)){
    foreach ($inflections as $__singular => $__plural){
        AkInflector::singularize($__plural, $__singular);
        AkInflector::pluralize($__singular, $__plural);
    }
    unset($inflections, $__singular, $__plural);
}

In regards to ccornwell problem I found that

singularize Specimens == Specimen

pluralize Specimen == Specimens

but

singularize Specimen == Speciman

We will need to add isSingular() at some point in the generator

04/24/08 18:39:45 changed by Kaste

- global pollution, somehow dirty

++ super easy implementation

I would like to see a hook in the init-phase of the framework at a point where we have some classes loaded. (config/init.php or so) (autoload functions in PHP5)

then we could simply

AkInflector::addIrregular(..,..);

and everyone could just do/code what he wants.

config/config.php is too early/dumb for these things.

(follow-up: ↓ 5 ) 04/25/08 13:28:09 changed by ccornwell

RE: singularize Specimens == Specimen, pluralize Specimen == Specimens

These are correct. After learning about Rail's approach to configuring the inflector I wondered whether Akelos had such a mechanism that I overlooked. Guess not, but it would be a nice addition.

With regard to the first problem - reporting a collision error even though the underlying error is something else - is there a simple way within Akelos coding conventions to allow generator implementations of hasCollisions() to report exception conditions to AkGenerator?._generate() so that a less confusing error message can be logged? Depending on the condition, using the -force override may not be the wisest thing to do.

(in reply to: ↑ 4 ) 04/25/08 13:46:11 changed by Kaste

Replying to ccornwell:

With regard to the first problem - reporting a collision error even though the underlying error is something else <snip>

It should sufficient to just change the error message. like "We have some concerns. Add -force to overrule."