Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Support for JPA "columnDefinition" (patch)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nico Kaiser  
View profile  
 More options Dec 8 2009, 8:14 am
From: Nico Kaiser <n...@kaiser.me>
Date: Tue, 08 Dec 2009 14:14:31 +0100
Local: Tues, Dec 8 2009 8:14 am
Subject: [2.0] Support for JPA "columnDefinition" (patch)

Hi!

Some weeks ago we discussed creation of custom Types [1] like the MySQL
enum [2] and custom field modifiers like "UNSIGNED" [3]

While in need for another custom type (char - for fixed length text)
that - like enum - can be mapped to a Doctrine StringType, I implemented
a "columnDefinition" element for @Column annonations.

According to the JPA specification the "columnDefinition" stands for
"The SQL fragment that is used when generating the DDL for the column".
It holds custom, most likely platform specific, column definitions for
Doctrine types, which are passed to the database as they are.

With the attached patch (for trunk Doctrine 2.0, r6895) you can do
something like this:

     /**
      * @Column(name="name", type="string", columnDefinition="CHAR(32)")
      */
     public $name;

In vanilla Doctrine 2.0 this column is created as STRING, but the
patched version generates a "CHAR(32)" database column (of course this
throws an exception if the DBM does not support "CHAR(32)".

You can easily map enums as well:

     /**
      * @Column(name="type", type="string",
columnDefinition="enum('business', 'private')")
      */
     public $type;

One question I did not find an answer for yet is, what exactly should be
passed to the DBM? This is especially interesting if there are
additional definitions (like PRIMARY KEY, NOT NULL, etc.).

Should this code:

     @Column(name="id", type="integer", columnDefinition="SMALLINT") @Id
@GeneratedValue(strategy="AUTO")

generate "SMALLINT PRIMARY KEY AUTOINCREMENT" or just "SMALLINT"?
(Currently this breaks the patch, I'll change this)

What do you think?

Nico

[1]
http://groups.google.com/group/doctrine-user/browse_thread/thread/a3e...

[2] http://www.doctrine-project.org/jira/browse/DDC-65

[3]
http://groups.google.com/group/doctrine-user/browse_thread/thread/6e0...

  columndefinition.patch
8K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[2.0] Support for JPA "columnDefinition" (patch)" by Nico Kaiser
Nico Kaiser  
View profile  
 More options Dec 8 2009, 11:56 am
From: Nico Kaiser <n...@kaiser.me>
Date: Tue, 08 Dec 2009 17:56:55 +0100
Local: Tues, Dec 8 2009 11:56 am
Subject: Re: [doctrine-user] [2.0] Support for JPA "columnDefinition" (patch)

This is an updated patch (again, for current trunk version) that fixes
AUTO_INCREMENT behavior for MySQL and sqlite.

I also created a JIRA issue to discuss this:
http://www.doctrine-project.org/jira/browse/DDC-200

Nico

Am 08.12.2009 14:14 schrieb Nico Kaiser:

  ddc-200-columndefinition.patch
10K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »