MySQL-Util

 view release on metacpan or  search on metacpan

lib/MySQL/Util/Lite/Column.pm  view on Meta::CPAN

package MySQL::Util::Lite::Column;

our $VERSION = '0.01';

use Modern::Perl;
use Moose;
use namespace::autoclean;
use Method::Signatures;
use Data::Printer alias => 'pdump';

has name => (
	is => 'ro',
	isa => 'Str',
	required => 1,
);

has key => (
	is => 'ro',
	isa => 'Str|Undef',
);

has default => (
	is => 'ro',
	isa => 'Str|Undef',
);

has type => (
	is => 'ro',
	isa => 'Str',
	required => 1,
);

has is_null => (
	is => 'rw',
	isa => 'Bool',
	required => 1,
);

has is_autoinc => (
	is => 'rw',
	isa => 'Bool',
	default => 0,
);

method get_moose_type {

	my $str;
	my $type = $self->type;
	
	if ( $type =~ /varchar/i ) {
		$str = 'Str|HashRef';
	}
	elsif ( $type =~ /timestamp/i || $type =~ /datetime/i) {
		$str = 'Str|HashRef';
	}
	elsif ( $type =~ /enum/i ) {
		$str = 'Str|HashRef';
	}
	else {
		$str = 'Num|HashRef';
	}

	if ( $self->is_null ) {
		$str .= '|Undef';
	}



( run in 0.683 second using v1.01-cache-2.11-cpan-39bf76dae61 )