[jifty-devel] user-defined data types

Jesse Vincent jesse at bestpractical.com
Thu Feb 22 13:48:43 EST 2007




On Wed, Feb 21, 2007 at 10:35:51PM -0500, Edgar Whipple wrote:
> I don't see anything in the jifty-devel archives about user-defined data
> types. Has there been any discussion?

There has. clkao has spent some effort on this, but he's on a hiking
trip right now.  (should be back this weekend.)

Cl,

Where did you get with things? What did your design look like?

Jesse

> 
> They wouldn't necessarily have to be supported in the database engine,
> although that might be useful. I can think of a couple of ways to do it
> at the model-declaration level.
> 
> 1. Use a simple string for the repeated column attributes.
> 
> 2. Define a subclass of Jifty::DBI::Column, the instances of which carry
> the repeated attributes.
> 
> 3. Define a separate subclass of Jifty::DBI::Column for each
> user-defined type.
> 
> Here are some guesses about how they might be used.
> 
> <code>
> 
> package MyJiftyApp::Model::MyModel1;
> use Jifty::DBI::Schema;
> 
> # setting up nos. 1 and 2. 
> # These would probably be in a separate package
> my $ud_type_string = qq(
>     type => 'text',
>     max_length => 128,
>     render_as => 'Text',
>     mandatory => '',
> )
> my $ud_type_object 
>     = Jifty::DBI::Column::UserDefined::Concrete
>         ->new( {type => 'text', @etcetera} )
>         
> 
> use MyJiftyApp::Record schema {
> 
>     # 1. example of using type definition string
>     column firstname =>
>         label is 'Firstname',
>         since '0.0.1',
>         ud_type is $ud_type_string;
> 
>     # 2. example of concrete Column subclass
>     column surname =>
>         label is 'Surname',
>         since '0.0.1'
>         ud_type is $ud_type_object;
> 
>     # 3. example of abstract Column subclass
>     column middlename =>
>         based_on MyJiftyApp::UserType::MyUserType1,
>         label is 'Middle',
>         since '0.0.1';
> 
> }
> 
> package MyJiftyApp::UserTypes::MyUserType1;
> use Jifty::DBI::Column::UserDefined::Abstract;
> ### and then goodness knows what goes here.
> 
> </code>
> 
> Each of these involves adding the indicated keyword to
> Jifty::DBI::Schema. We might also want a 'not' keyword, e.g. 'is not
> mandatory' in the model overrides 'is mandatory' in the reusable column
> type.
> 
> -Edgar
> 
> PS These are just top-of-my-head scribbles, so don't judge too harshly. 
> 
> -- 
> ln -s /dev/null ~/.sig
> 
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
> 

-- 


More information about the jifty-devel mailing list