DBIx-Class-ResultDDL
view release on metacpan or search on metacpan
lib/DBIx/Class/ResultDDL.pm view on Meta::CPAN
integer[] data_type => 'integer[]', size => 11
integer $size,[] data_type => 'integer[]', size => $size
# MySQL variants
tinyint data_type => 'tinyint', size => 4
smallint data_type => 'smallint', size => 6
bigint data_type => 'bigint', size => 22
# MySQL specific flag which can be combined with int types
unsigned extra => { unsigned => 1 }
=head3 numeric, decimal
numeric data_type => 'numeric'
numeric($p) data_type => 'numeric', size => [ $p ]
numeric($p,$s) data_type => 'numeric', size => [ $p, $s ]
numeric[] data_type => 'numeric[]'
numeric $p,$s,[] data_type => 'numeric[]', size => [ $p, $s ]
# Same API for decimal
decimal ... data_type => 'decimal' ...
=head3 money
money data_type => 'money'
money[] data_type => 'money[]'
=head3 real, float4, double, float8
real data_type => 'real'
rea[] data_type => 'real[]'
float4 data_type => 'float4'
float4[] data_type => 'float4[]'
double data_type => 'double precision'
double[] data_type => 'double precision[]'
float8 data_type => 'float8'
float8[] data_type => 'float8[]'
=head3 float
# Call: Becomes:
float data_type => 'float'
float($bits) data_type => 'float', size => $bits
float[] data_type => 'float[]'
float $bits,[] data_type => 'float[]', size => $bits
SQLServer and Postgres offer this, where C<$bits> is the number of bits of precision
of the mantissa. Array notation is supported for Postgres.
=head3 char, nchar, bit
# Call: Becomes:
char data_type => 'char', size => 1
char($size) data_type => 'char', size => $size
char[] data_type => 'char[]', size => 1
char $size,[] data_type => 'char[]', size => $size
# Same API for the others
nchar ... data_type => 'nchar' ...
bit ... data_type => 'bit' ...
C<nchar> (SQL Server unicode char array) has an identical API but
returns C<< data_type => 'nchar' >>
Note that Postgres allows C<"bit"> to have a size, like C<char($size)> but SQL Server
uses C<"bit"> only to represent a single bit.
=head3 varchar, nvarchar, binary, varbinary, varbit
varchar data_type => 'varchar'
varchar($size) data_type => 'varchar', size => $size
varchar(MAX) data_type => 'varchar', size => "MAX"
varchar[] data_type => 'varchar[]'
varchar $size,[] data_type => 'varchar[]', size => $size
# Same API for the others
nvarchar ... data_type => 'nvarchar' ...
binary ... data_type => 'binary' ...
varbinary ... data_type => 'varbinary' ...
varbit ... data_type => 'varbit' ...
Unlike char/varchar relation, C<binary> does not default the size to 1.
=head3 MAX
Constant for C<"MAX">, used by SQL Server for C<< varchar(MAX) >>.
=head3 blob, tinyblob, mediumblob, longblob, bytea
blob data_type => 'blob',
blob($size) data_type => 'blob', size => $size
# MySQL specific variants:
tinyblob data_type => 'tinyblob', size => 0xFF
mediumblob data_type => 'mediumblob', size => 0xFFFFFF
longblob data_type => 'longblob', size => 0xFFFFFFFF
# Postgres blob type is 'bytea'
bytea data_type => 'bytea'
bytea[] data_type => 'bytea[]'
Note: For MySQL, you need to change the type according to '$size'. A MySQL blob is C<< 2^16 >>
max length, and probably none of your binary data would be that small. Consider C<mediumblob>
or C<longblob>, or consider overriding C<< My::Schema::sqlt_deploy_hook >> to perform this
conversion automatically according to which DBMS you are connected to.
For SQL Server, newer versions deprecate C<blob> in favor of C<VARCHAR(MAX)>. This is another
detail you might take care of in sqlt_deploy_hook.
=head3 text, tinytext, mediumtext, longtext, ntext
text data_type => 'text',
text($size) data_type => 'text', size => $size
text[] data_type => 'text[]'
# MySQL specific variants:
tinytext data_type => 'tinytext', size => 0xFF
mediumtext data_type => 'mediumtext', size => 0xFFFFFF
longtext data_type => 'longtext', size => 0xFFFFFFFF
# SQL Server unicode variant:
ntext data_type => 'ntext', size => 0x3FFFFFFF
ntext($size) data_type => 'ntext', size => $size
See MySQL notes in C<blob>. For SQL Server, you might want C<ntext> or C<< nvarchar(MAX) >>
instead. Postgres does not use a size, and allows arrays of this type.
Newer versions of SQL-Server prefer C<< nvarchar(MAX) >> instead of C<ntext>.
=head3 enum
enum(@values) data_type => 'enum', extra => { list => [ @values ] }
This function cannot take pass-through arguments, since every argument is an enum value.
=head3 bool, boolean
bool data_type => 'boolean'
bool[] data_type => 'boolean[]'
boolean data_type => 'boolean'
boolean[] data_type => 'boolean[]'
Note that SQL Server doesn't support 'boolean', the closest being 'bit',
though in postgres 'bit' is used for bitstrings.
=head3 date
date data_type => 'date'
date[] data_type => 'date[]'
=head3 datetime, timestamp
datetime data_type => 'datetime'
datetime($tz) data_type => 'datetime', timezone => $tz
datetime[] data_type => 'datetime[]'
datetime $tz, [] data_type => 'datetime[]', timezone => $tz
# Same API
timestamp ... data_type => 'timestamp', ...
B<NOTE> that C<datetime> and C<timestamp> had a bug before version 2 which set "time_zone"
instead of "timezone", causing the time zone (applied to DateTime objects by the inflator)
to not take effect, resulting in "floating" timezone DateTime objects.
=head3 array
array($type) data_type => $type.'[]'
array(@dbic_attrs) data_type => $type.'[]', @other_attrs
# i.e.
array numeric(10,3) data_type => 'numeric[]', size => [10,3]
Declares a postgres array type by appending C<"[]"> to a type name.
The type name can be given as a single string, or as any sugar function that
returns a C<< data_type => $type >> pair of elements.
=head3 uuid
uuid data_type => 'uuid'
uuid[] data_type => 'uuid[]'
=head3 json, jsonb
( run in 1.280 second using v1.01-cache-2.11-cpan-39bf76dae61 )