[mysql-wb-doctrine-plugin:1] implementing validations?

7 views
Skip to first unread message

Johannes Mueller

unread,
Apr 16, 2010, 3:28:16 PM4/16/10
to mysql-workbench-doctrine-plugin
I was asked to implement validations[1] to the plugin. What's your
opinion about that?

If we implement such a feature, I would recommend to bypass the
information (like in *:actAs) directly from the comments of each
column. I'm not certain if this is a good solution but it's easy and
fast to implement, while giving plenty of rope to the users.

[1] http://www.doctrine-project.org/documentation/manual/1_2/en/data-validation



Here is the email - in fact the thanks go to all developers of the
plugin:

Hi Johannes,

I've been using your Doctrine plugin for MySQL Workbench. It is
working very well. Well done!

I was wondering if it is possible to add things like validators to
fields? Perhaps via the comments field like how you can add
behaviours via the table comments field?

Kind Regards,
xxx


--
Subscription settings: http://groups.google.com/group/mysql-workbench-doctrine-plugin/subscribe?hl=de

Baxter

unread,
May 4, 2010, 11:20:59 AM5/4/10
to mysql-workbench-doctrine-plugin
This is how I would structure it:

use

{doctrine}
{/doctrine}

Anything that is entered into the table comment gets merged into the
root element so it could look like this:

{doctrine}
connection: second
actAs:
Timestampable:
created:
name: inserted
type: integer(10)
updated:
name: updated
type: integer(10)
attributes:
export: none
validate: false
{/doctrine}

These declarations would merge into the main class declaration, we
would then parse the comments for each column in the table and add any
additional declarations to that columns yaml state so for a column
comment it could be:

{doctrine}
minlength: 12
email: true
{/doctrine}

lastly parse the foreign key comment for additional information there:

ie:

{doctrine}
foreignAlias: foo
alias: bar
{/doctrine}

This would allow for additional control and remove the need for adding
additional features as they are released. This may require some work
for backwards compatibility but I think would give a better overall
control to the end user.

Cheers,

Jay

On Apr 16, 3:28 pm, Johannes Mueller <johannes.muel...@gmail.com>
wrote:
> I was asked to implement validations[1] to the plugin. What's your
> opinion about that?
>
> If we implement such a feature, I would recommend to bypass the
> information (like in *:actAs) directly from the comments of each
> column. I'm not certain if this is a good solution but it's easy and
> fast to implement, while giving plenty of rope to the users.
>
> [1]http://www.doctrine-project.org/documentation/manual/1_2/en/data-vali...
>
> Here is the email - in fact the thanks go to all developers of the
> plugin:
>
> Hi Johannes,
>
> I've been using your Doctrine plugin for MySQL Workbench.  It is
> working very well.  Well done!
>
> I was wondering if it is possible to add things like validators to
> fields?  Perhaps via the comments field like how you can add
> behaviours via the table comments field?
>
> Kind Regards,
> xxx
>
> --
> Subscription settings:http://groups.google.com/group/mysql-workbench-doctrine-plugin/subscr...
Message has been deleted

Johannes Mueller

unread,
May 4, 2010, 5:55:38 PM5/4/10
to mysql-workbench-doctrine-plugin
The problem will be "parsing the comments". It's easier to derive your
actions from specific comments than arranging unstructured content.
The user has to define his needs anyway, so it doesn't really matter
if he writes one or two more comment blocks for doctrine. This would
prevent us from having to parse the comments. At the moment we have
{doctrine:actAs /} as the main and most used comment option i think.
This one is very strong, because you can arrange almost everything.

> {doctrine}
> minlength: 12
> email: true
> {/doctrine}
>
> lastly parse the foreign key comment for additional information there:

This is already implemented, just try the code beneath in a comment of
a column, and it will be passed to the output
{doctrine:validators}
email: true
{/doctrine:validators}

> ie:
>
> {doctrine}
> foreignAlias:  foo
> alias:  bar
> {/doctrine}
>
> This would allow for additional control and remove the need for adding
> additional features as they are released. This may require some work
> for backwards compatibility but I think would give a better overall
> control to the end user.

Thats true. We can arrange this even without breaking backwards
compatibility, just by adding a suffix.

{doctrine:rawRelation}
foreignAlias: foo
alias: bar
{/doctrine:rawRelation}

This would be easy to implement, except that the output would be
doubled (we have to replace the automatic generated output). On the
other hand it's a feature of the plugin, to automate as much as we
can, otherwise you could write the yaml by hand :)

J.
Reply all
Reply to author
Forward
0 new messages