DBIx::Renderer::Constants - constants for the DBI rendering framework
use DBIx::Renderer ':all';
# mandatory name
use constant TYPE_MANDNAME => ( VARCHAR(255), NOTNULL );
my $struct = [
category => [
id => { TYPE_ID },
name => { TYPE_MANDNAME },
parent_id => { INT4, INDEX },
],
];
This module defines a range of constants and helper functions for use
in writing and talking to DBI renderers. Typically you won't use this
module directly, but import ':all' from DBIx::Renderer, which passes
this module's exports along.
The following constants and functions are exported:
Constants for those data types; specific DBI renderers can then decide how to render these constants in their SQL dialect. Actually they return a hash element consisting of the key 'type' and the actual constant as the value, so it doesn't make sense to specify more than one type; the last one specified wins.
CHAR($size) VARCHAR($size)
These aren't actually constants but functions that take the size as a parameter, as shown in the synopsis. In addition to the 'type' hash key and its value, these functions also return a 'size' hash key and its value.
Like CHAR and VARCHAR, this function returns a hash element with
'DEFAULT' as its key (as every field can have only one default value)
and the actual default as its value.
Defines constants for marking a field to be not nullable or to be unique, or for specifying that this field is a primary key or that it should be indexed. Per usual, these constants are a hash element with the constant's name as the key and 1 as its value.
These two are "complex" types; a TYPE_ID being a not-nullable primary
key of type int4, and TYPE_FK being a notnullable int4 used as a
foreign key into some other table.
get_types()
Returns a list of all possible data types.
get_attrs()
Returns a list of all possible field attributes (such as 'not nullable', 'unique value', 'has a default value').
get_markers()
Returns a list of all field markers (such as 'primary key' or 'indexed field').
None known so far. If you find any bugs or oddities, please do inform the author.
Marcel Grünauer <marcel@codewerk.com>
Copyright 2001 Marcel Grünauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl(1), DBI(3pm), DBIx::Renderer(3pm).