-
-
29 Nov 2020 19:45:40 UTC
- Distribution: DBIx-Class-Smooth
- Module version: 0.0108
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (2 / 65 / 8)
- Kwalitee
Bus factor: 1- % Coverage
- License: perl_5
- Perl: v5.20.0
- Activity
24 month- Tools
- Download (45.8KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
DBIx::Class::Smooth::Fields - Specify columns
VERSION
Version 0.0108, released 2020-11-29.
SYNOPSIS
package Your::Schema::Result::Book; use Your::Schema::Result -components => [qw//]; use DBIx::Class::Smooth::Fields -all; primary id => IntegerField(auto_increment => true); belongs Publisher => ForeignKey(); col isbn => VarcharField(size => 13); col title => VarcharField(size => 150); col published_date => DateField(); col language => EnumField(indexed => 1, -list => [qw/english french german spanish/]);
DESCRIPTION
DBIx::Class::Smooth::Fields defines an alternative way to specify columns in DBIx::Class result sources. They make most sense when used together with the functions exported by Smooth::Helper::Row::Creation.
These are just functions that return the hashes that you normally use to configure DBIx::Class columns. With a couple of exceptions, they only set
data_type
andis_numeric
.Any key-value pairs passed will be included in the returned hash. If you need to use other data types, you can use
NumericalField
orNonNumericalField
which only setsis_numeric
to the expected value.Relational fields
ForeignKey()
belongs Publisher => ForeignKey();
This is not a field type at all, but helps define the relationship with another result source. The heavy lifting is done by
belongs
, but in short there will be a field namedpublisher_id
with thesize
anddata_type
of theid
field in::Publisher
.Numerical fields
These will all have
is_numeric
set to1
, in addition to their respectivedata_type
:BitField bit TinyIntField tinyint SmallIntField smallint MediumIntField mediumint IntegerField integer BigIntField bigint SerialField serial BooleanField boolean DecimalField decimal FloatField float DoubleField double
Non-numerical fields
These will all have
is_numeric
set to0
, in addition to their respectivedata_type
:VarcharField varchar CharField char VarbinaryField varbinary BinaryField binary TinyTextField tinytext TextField text MediumTextField mediumtext LongTextField longtext TinyBlobField tinyblob BlobField blob MediumBlobField mediumblob LongBlobField longblod EnumField enum DateField date DateTimeField datetime TimestampField timestamp TimeField time YearField year
For
EnumField
, you can doEnumField(-list =
[qw/one to three/])> instead ofEnumField(extra =
{ list => [qw/one two three/] })>.SEE ALSO
SOURCE
https://github.com/Csson/p5-DBIx-Class-Smooth
HOMEPAGE
https://metacpan.org/release/DBIx-Class-Smooth
AUTHOR
Erik Carlsson <info@code301.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by Erik Carlsson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install DBIx::Class::Smooth, copy and paste the appropriate command in to your terminal.
cpanm DBIx::Class::Smooth
perl -MCPAN -e shell install DBIx::Class::Smooth
For more information on module installation, please visit the detailed CPAN module installation guide.