DBIx::Class::Smooth::Fields - Specify columns
Version 0.0108, released 2020-11-29.
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/]);
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 and is_numeric.
data_type
is_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 or NonNumericalField which only sets is_numeric to the expected value.
NumericalField
NonNumericalField
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 named publisher_id with the size and data_type of the id field in ::Publisher.
belongs
publisher_id
size
id
::Publisher
These will all have is_numeric set to 1, in addition to their respective data_type:
1
BitField bit TinyIntField tinyint SmallIntField smallint MediumIntField mediumint IntegerField integer BigIntField bigint SerialField serial BooleanField boolean DecimalField decimal FloatField float DoubleField double
These will all have is_numeric set to 0, in addition to their respective data_type:
0
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 do EnumField(-list = [qw/one to three/])> instead of EnumField(extra = { list => [qw/one two three/] })>.
EnumField
EnumField(-list =
EnumField(extra =
https://github.com/Csson/p5-DBIx-Class-Smooth
https://metacpan.org/release/DBIx-Class-Smooth
Erik Carlsson <info@code301.com>
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.
To install DBIx::Class::Smooth, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::Smooth
CPAN shell
perl -MCPAN -e shell install DBIx::Class::Smooth
For more information on module installation, please visit the detailed CPAN module installation guide.