From: Justin Hunter Date: Mon, 6 Jul 2009 06:57:10 +0000 (-0700) Subject: implement 'use aliased' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=44547961080e3091989e0f2bbfbc85ad510da235;p=dbsrgits%2FSQL-Translator-2.0-ish.git implement 'use aliased' code format change --- diff --git a/lib/SQL/Translator.pm b/lib/SQL/Translator.pm index 78512bc..591eba5 100644 --- a/lib/SQL/Translator.pm +++ b/lib/SQL/Translator.pm @@ -5,17 +5,17 @@ use MooseX::Types::Moose qw(Str); use SQL::Translator::Types qw(DBIHandle); has 'parser' => ( - isa => Str, - is => 'ro', - init_arg => 'from', - required => 1, + isa => Str, + is => 'ro', + init_arg => 'from', + required => 1, ); has 'producer' => ( - isa => Str, - is => 'ro', - init_arg => 'to', - required => 1, + isa => Str, + is => 'ro', + init_arg => 'to', + required => 1, ); has 'dbh' => ( diff --git a/lib/SQL/Translator/Object/Column.pm b/lib/SQL/Translator/Object/Column.pm index 3d7a061..a387566 100644 --- a/lib/SQL/Translator/Object/Column.pm +++ b/lib/SQL/Translator/Object/Column.pm @@ -6,53 +6,53 @@ use SQL::Translator::Types qw(Trigger); extends 'SQL::Translator::Object'; has 'name' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); has 'data_type' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); has 'size' => ( - is => 'rw', - isa => Maybe[Int], - required => 1 + is => 'rw', + isa => Maybe[Int], + required => 1 ); has 'is_nullable' => ( - is => 'rw', - isa => Bool, - required => 1, - default => 1 + is => 'rw', + isa => Bool, + required => 1, + default => 1 ); has 'is_auto_increment' => ( - is => 'rw', - isa => Bool, - required => 1, - default => 0 + is => 'rw', + isa => Bool, + required => 1, + default => 0 ); has 'default_value' => ( - is => 'rw', - isa => Maybe[Str], - required => 0 + is => 'rw', + isa => Maybe[Str], + required => 0 ); has 'remarks' => ( - is => 'rw', - isa => Maybe[Str], - required => 0 + is => 'rw', + isa => Maybe[Str], + required => 0 ); has 'trigger' => ( - is => 'rw', - isa => Trigger, - required => 0 + is => 'rw', + isa => Trigger, + required => 0 ); __PACKAGE__->meta->make_immutable; diff --git a/lib/SQL/Translator/Object/Constraint.pm b/lib/SQL/Translator/Object/Constraint.pm index a5c303a..525a529 100644 --- a/lib/SQL/Translator/Object/Constraint.pm +++ b/lib/SQL/Translator/Object/Constraint.pm @@ -7,28 +7,35 @@ use SQL::Translator::Types qw(Column); extends 'SQL::Translator::Object'; has 'name' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); has 'columns' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[Column], - provides => { - exists => 'exists_column', - keys => 'column_ids', - get => 'get_column', - set => 'set_column', - }, - required => 1 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Column], + provides => { + exists => 'exists_column', + keys => 'column_ids', + get => 'get_column', + }, + curries => { + set => { + add_column => sub { + my ($self, $body, $column) = @_; + $self->$body($column->name, $column); + } + } + }, + required => 1 ); has 'type' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); __PACKAGE__->meta->make_immutable; diff --git a/lib/SQL/Translator/Object/Index.pm b/lib/SQL/Translator/Object/Index.pm index e5a0bb6..9828ce0 100644 --- a/lib/SQL/Translator/Object/Index.pm +++ b/lib/SQL/Translator/Object/Index.pm @@ -7,29 +7,36 @@ use SQL::Translator::Types qw(Column); extends 'SQL::Translator::Object'; has 'name' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); has 'columns' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[Column], - provides => { - exists => 'exists_column', - keys => 'column_ids', - get => 'get_column', - }, - curries => { set => { add_column => sub { my ($self, $body, $column) = @_; $self->$body($column->name, $column); } } }, - default => sub { {} }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Column], + provides => { + exists => 'exists_column', + keys => 'column_ids', + get => 'get_column', + }, + curries => { + set => { + add_column => sub { + my ($self, $body, $column) = @_; + $self->$body($column->name, $column); + } + } + }, + default => sub { {} }, + required => 0 ); has 'type' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); __PACKAGE__->meta->make_immutable; diff --git a/lib/SQL/Translator/Object/Procedure.pm b/lib/SQL/Translator/Object/Procedure.pm index 1350b5c..8f781a4 100644 --- a/lib/SQL/Translator/Object/Procedure.pm +++ b/lib/SQL/Translator/Object/Procedure.pm @@ -4,51 +4,51 @@ use Moose; use MooseX::Types::Moose qw(HashRef Int Maybe Str); use MooseX::AttributeHelpers; use SQL::Translator::Types qw(); -use SQL::Translator::Object::Schema; +use aliased 'SQL::Translator::Object::Schema'; extends 'SQL::Translator::Object'; has 'name' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); has 'contents' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); has 'parameters' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => Maybe[HashRef[Int|Str]], - provides => { - exists => 'exists_parameter', - keys => 'parameter_ids', - get => 'get_parameter', - set => 'set_parameter', - }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => Maybe[HashRef[Int|Str]], + provides => { + exists => 'exists_parameter', + keys => 'parameter_ids', + get => 'get_parameter', + set => 'set_parameter', + }, + required => 0 ); has 'owner' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); has 'comments' => ( - is => 'rw', - isa => Str, - required => 0 + is => 'rw', + isa => Str, + required => 0 ); has 'schema' => ( - is => 'rw', - isa => Schema, - required => 1, - default => sub { SQL::Translator::Object::Schema->new } + is => 'rw', + isa => Schema, + required => 1, + default => sub { Schema->new } ); __PACKAGE__->meta->make_immutable; diff --git a/lib/SQL/Translator/Object/Schema.pm b/lib/SQL/Translator/Object/Schema.pm index 3b4bfef..6d3487c 100644 --- a/lib/SQL/Translator/Object/Schema.pm +++ b/lib/SQL/Translator/Object/Schema.pm @@ -7,52 +7,73 @@ use SQL::Translator::Types qw(Procedure Table View); extends 'SQL::Translator::Object'; has 'name' => ( - is => 'rw', - isa => Maybe[Str], - required => 1, - default => '' + is => 'rw', + isa => Maybe[Str], + required => 1, + default => '' ); has 'tables' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[Table], - provides => { - exists => 'exists_table', - keys => 'table_ids', - get => 'get_table', - }, - curries => { set => { add_table => sub { my ($self, $body, $table) = @_; $self->$body($table->name, $table); } } }, - default => sub { {} }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Table], + provides => { + exists => 'exists_table', + keys => 'table_ids', + get => 'get_table', + }, + curries => { + set => { + add_table => sub { + my ($self, $body, $table) = @_; + $self->$body($table->name, $table); + } + } + }, + default => sub { {} }, + required => 0 ); has 'views' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[View], - provides => { - exists => 'exists_view', - keys => 'view_ids', - get => 'get_view', - }, - curries => { set => { add_view => sub { my ($self, $body, $view) = @_; $self->$body($view->name, $view); } } }, - default => sub { {} }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[View], + provides => { + exists => 'exists_view', + keys => 'view_ids', + get => 'get_view', + }, + curries => { + set => { + add_view => sub { + my ($self, $body, $view) = @_; + $self->$body($view->name, $view); + } + } + }, + default => sub { {} }, + required => 0 ); has 'procedures' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[Procedure], - provides => { - exists => 'exists_procedure', - keys => 'procedure_ids', - get => 'get_procedure', - }, - curries => { set => { add_procedure => sub { my ($self, $body, $procedure) = @_; $self->$body($procedure->name, $procedure); } } }, - default => sub { {} }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Procedure], + provides => { + exists => 'exists_procedure', + keys => 'procedure_ids', + get => 'get_procedure', + }, + curries => { + set => { + add_procedure => sub { + my ($self, $body, $procedure) = @_; + $self->$body($procedure->name, $procedure); + } + } + }, + default => sub { {} }, + required => 0 ); __PACKAGE__->meta->make_immutable; diff --git a/lib/SQL/Translator/Object/Sequence.pm b/lib/SQL/Translator/Object/Sequence.pm index 436319b..f5ff257 100644 --- a/lib/SQL/Translator/Object/Sequence.pm +++ b/lib/SQL/Translator/Object/Sequence.pm @@ -5,7 +5,11 @@ use MooseX::Types::Moose qw(Str); use SQL::Translator::Types qw(); extends 'SQL::Translator::Object'; -has 'name' => (is => 'ro', isa => Str, required => 1); +has 'name' => ( + is => 'ro', + isa => Str, + required => 1 +); __PACKAGE__->meta->make_immutable; diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm index 2a13e8a..1f1d010 100644 --- a/lib/SQL/Translator/Object/Table.pm +++ b/lib/SQL/Translator/Object/Table.pm @@ -8,65 +8,93 @@ use SQL::Translator::Object::Schema; extends 'SQL::Translator::Object'; has 'name' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); has 'columns' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[Column], - provides => { - exists => 'exists_column', - keys => 'column_ids', - get => 'get_column', - }, - curries => { set => { add_column => sub { my ($self, $body, $column) = @_; $self->$body($column->name, $column); } } }, - default => sub { {} }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Column], + provides => { + exists => 'exists_column', + keys => 'column_ids', + get => 'get_column', + }, + curries => { + set => { + add_column => sub { + my ($self, $body, $column) = @_; + $self->$body($column->name, $column); + } + } + }, + default => sub { {} }, + required => 0 ); has 'indexes' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[Index], - provides => { - exists => 'exists_index', - keys => 'index_ids', - get => 'get_index', - }, - curries => { set => { add_index => sub { my ($self, $body, $index) = @_; $self->$body($index->name, $index); } } }, - default => sub { {} }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Index], + provides => { + exists => 'exists_index', + keys => 'index_ids', + get => 'get_index', + }, + curries => { + set => { + add_index => sub { + my ($self, $body, $index) = @_; + $self->$body($index->name, $index); + } + } + }, + default => sub { {} }, + required => 0 ); has 'constraints' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[Constraint], - provides => { - exists => 'exists_constraint', - keys => 'constraint_ids', - get => 'get_constraint', - }, - curries => { set => { add_constraint => sub { my ($self, $body, $constraint) = @_; $self->$body($constraint->name, $constraint); } } }, - default => sub { {} }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Constraint], + provides => { + exists => 'exists_constraint', + keys => 'constraint_ids', + get => 'get_constraint', + }, + curries => { + set => { + add_constraint => sub { + my ($self, $body, $constraint) = @_; + $self->$body($constraint->name, $constraint); + } + } + }, + default => sub { {} }, + required => 0 ); has 'sequences' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[Sequence], - provides => { - exists => 'exists_sequence', - keys => 'sequence_ids', - get => 'get_sequence', - }, - curries => { set => { add_sequence => sub { my ($self, $body, $sequence) = @_; $self->$body($sequence->name, $sequence); } } }, - default => sub { {} }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Sequence], + provides => { + exists => 'exists_sequence', + keys => 'sequence_ids', + get => 'get_sequence', + }, + curries => { + set => { + add_sequence => sub { + my ($self, $body, $sequence) = @_; + $self->$body($sequence->name, $sequence); + } + } + }, + default => sub { {} }, + required => 0 ); __PACKAGE__->meta->make_immutable; diff --git a/lib/SQL/Translator/Object/Trigger.pm b/lib/SQL/Translator/Object/Trigger.pm index 8f91658..2b77ffa 100644 --- a/lib/SQL/Translator/Object/Trigger.pm +++ b/lib/SQL/Translator/Object/Trigger.pm @@ -5,7 +5,11 @@ use MooseX::Types::Moose qw(Str); use SQL::Translator::Types qw(); extends 'SQL::Translator::Object'; -has 'name' => (is => 'ro', isa => Str, required => 1); +has 'name' => ( + is => 'ro', + isa => Str, + required => 1 +); __PACKAGE__->meta->make_immutable; diff --git a/lib/SQL/Translator/Object/View.pm b/lib/SQL/Translator/Object/View.pm index dfabb15..414abd6 100644 --- a/lib/SQL/Translator/Object/View.pm +++ b/lib/SQL/Translator/Object/View.pm @@ -7,28 +7,36 @@ use SQL::Translator::Types qw(Column); extends 'SQL::Translator::Object'; has 'name' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); has 'columns' => ( - metaclass => 'Collection::Hash', - is => 'rw', - isa => HashRef[Column], - provides => { - exists => 'exists_column', - keys => 'column_ids', - get => 'get_column', - set => 'set_column', - }, - required => 0 + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Column], + provides => { + exists => 'exists_column', + keys => 'column_ids', + get => 'get_column', + }, + curries => { + set => { + add_column => sub { + my ($self, $body, $column) = @_; + $self->$body($column->name, $column); + } + } + }, + default => sub { {} }, + required => 0 ); has 'sql' => ( - is => 'rw', - isa => Str, - required => 1 + is => 'rw', + isa => Str, + required => 1 ); __PACKAGE__->meta->make_immutable; diff --git a/lib/SQL/Translator/Parser.pm b/lib/SQL/Translator/Parser.pm index 78d88ec..7b59ced 100644 --- a/lib/SQL/Translator/Parser.pm +++ b/lib/SQL/Translator/Parser.pm @@ -3,6 +3,7 @@ use namespace::autoclean; use Moose; use MooseX::Types::Moose qw(Str); use SQL::Translator::Types qw(DBIHandle); +use aliased 'SQL::Translator::Object::Schema'; my $apply_role_dbi = sub { my $self = shift; @@ -28,11 +29,9 @@ has 'filename' => ( trigger => $apply_role_ddl, ); -sub BUILD {} - sub parse { my $self = shift; - my $schema = SQL::Translator::Object::Schema->new({ name => $self->schema_name }); + my $schema = Schema->new({ name => $self->schema_name }); $self->_add_tables($schema); $schema; } diff --git a/lib/SQL/Translator/Parser/DBI.pm b/lib/SQL/Translator/Parser/DBI.pm index f81aebc..6937049 100644 --- a/lib/SQL/Translator/Parser/DBI.pm +++ b/lib/SQL/Translator/Parser/DBI.pm @@ -5,41 +5,41 @@ use MooseX::Types::Moose qw(Maybe Str); use DBI::Const::GetInfoType; use DBI::Const::GetInfo::ANSI; use DBI::Const::GetInfoReturn; -use SQL::Translator::Object::Column; -use SQL::Translator::Object::Index; -use SQL::Translator::Object::Table; -use SQL::Translator::Object::View; +use aliased 'SQL::Translator::Object::Column'; +use aliased 'SQL::Translator::Object::Index'; +use aliased 'SQL::Translator::Object::Table'; +use aliased 'SQL::Translator::Object::View'; has 'quoter' => ( - is => 'rw', - isa => Str, - requried => 1, - lazy => 1, - default => sub { shift->dbh->get_info(29) || q{"} } + is => 'rw', + isa => Str, + requried => 1, + lazy => 1, + default => sub { shift->dbh->get_info(29) || q{"} } ); has 'namesep' => ( - is => 'rw', - isa => Str, - required => 1, - lazy => 1, - default => sub { shift->dbh->get_info(41) || '.' } + is => 'rw', + isa => Str, + required => 1, + lazy => 1, + default => sub { shift->dbh->get_info(41) || '.' } ); has 'schema_name' => ( - is => 'rw', - isa => Maybe[Str], - required => 0, - lazy => 1, - default => undef + is => 'rw', + isa => Maybe[Str], + required => 0, + lazy => 1, + default => undef ); has 'catalog_name' => ( - is => 'rw', - isa => Maybe[Str], - required => 0, - lazy => 1, - default => undef + is => 'rw', + isa => Maybe[Str], + required => 0, + lazy => 1, + default => undef ); sub _subclass { @@ -59,14 +59,16 @@ sub _add_tables { my $sth = $self->dbh->table_info($self->catalog_name, $self->schema_name, '%', 'TABLE,VIEW'); while (my $table_info = $sth->fetchrow_hashref) { if ($table_info->{TABLE_TYPE} eq 'TABLE') { - my $table = SQL::Translator::Object::Table->new({ name => $table_info->{TABLE_NAME} }); + my $table = Table->new({ name => $table_info->{TABLE_NAME} }); $schema->add_table($table); $self->_add_columns($table); $self->_add_primary_key($table); } elsif ($table_info->{TABLE_TYPE} eq 'VIEW') { my $sql = $self->_get_view_sql($table_info->{TABLE_NAME}); - $schema->add_view(SQL::Translator::Object::View->new({ name => $table_info->{TABLE_NAME}, sql => $sql })); + my $view = View->new({ name => $table_info->{TABLE_NAME}, sql => $sql }); + $schema->add_view($view); + $self->_add_columns($view); } } } @@ -77,11 +79,11 @@ sub _add_columns { my $sth = $self->dbh->column_info($self->catalog_name, $self->schema_name, $table->name, '%'); while (my $col_info = $sth->fetchrow_hashref) { - my $column = SQL::Translator::Object::Column->new({ name => $col_info->{COLUMN_NAME}, - data_type => $col_info->{TYPE_NAME}, - size => $col_info->{COLUMN_SIZE}, - default_value => $col_info->{COLUMN_DEF}, - is_nullable => $col_info->{NULLABLE}, }); + my $column = Column->new({ name => $col_info->{COLUMN_NAME}, + data_type => $col_info->{TYPE_NAME}, + size => $col_info->{COLUMN_SIZE}, + default_value => $col_info->{COLUMN_DEF}, + is_nullable => $col_info->{NULLABLE}, }); $table->add_column($column); } } @@ -96,7 +98,7 @@ sub _add_primary_key { $pk_name = $pk_col->{PK_NAME}; push @pk_cols, $pk_col->{COLUMN_NAME}; } - my $index = SQL::Translator::Object::Index->new({ name => $pk_name, type => 'PRIMARY_KEY' }); + my $index = Index->new({ name => $pk_name, type => 'PRIMARY_KEY' }); $index->add_column($table->get_column($_)) for @pk_cols; $table->add_index($index); } diff --git a/lib/SQL/Translator/Producer.pm b/lib/SQL/Translator/Producer.pm index 64035f3..a19eab3 100644 --- a/lib/SQL/Translator/Producer.pm +++ b/lib/SQL/Translator/Producer.pm @@ -4,22 +4,17 @@ use Moose; use MooseX::Types::Moose qw(Str); use SQL::Translator::Types qw(Schema); -use Data::Dumper; - has 'schema' => ( - isa => Schema, - is => 'rw', - required => 1 + isa => Schema, + is => 'rw', + required => 1 ); sub produce { my $self = shift; my $schema = $self->schema; - my $tables = $schema->tables; - foreach my $tname (keys %$tables) { - $self->_create_table($tables->{$tname}); - } + $self->_create_table($_) for values %{$schema->tables}; } sub _create_table { @@ -31,23 +26,27 @@ sub _create_table { my $sqlite_version = 0; my $create_table; + my (@column_defs, @index_defs, @constraint_defs); + + $create_table .= 'DROP TABLE ' . $table->name . ";\n" if $add_drop_table; + $create_table .= 'CREATE TABLE ' . $table->name . " (\n"; - $create_table .= 'DROP TABLE ' . $table->name . ";\n" if $add_drop_table; - $create_table .= "CREATE TABLE " . $table->name . " (\n"; - - my $columns = $table->columns; - foreach my $cname (keys %$columns) { - my $column = $columns->{$cname}; - $create_table .= ' ' . $column->name . ' ' . $column->data_type; - $create_table .= '(' . $column->size . ')' if $column->size; - $create_table .= ' NOT NULL' unless $column->is_nullable; - $create_table .= ",\n"; - } - $create_table =~ s/,$//; - $create_table .= ");"; + push @column_defs, $self->_create_column($_) for values %{$table->columns}; + $create_table .= join(",\n", map { ' ' . $_ } @column_defs ) . "\n)"; print $create_table . "\n"; } +sub _create_column { + my $self = shift; + my $column = shift; + + my $column_def; + $column_def = $column->name . ' ' . $column->data_type; + $column_def .= '(' . $column->size . ')' if $column->size; + $column_def .= ' NOT NULL' unless $column->is_nullable; + $column_def; +} + __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/SQL/Translator/Producer/SQLite.pm b/lib/SQL/Translator/Producer/SQLite.pm index aa29b8f..56392c0 100644 --- a/lib/SQL/Translator/Producer/SQLite.pm +++ b/lib/SQL/Translator/Producer/SQLite.pm @@ -2,4 +2,39 @@ package SQL::Translator::Producer::SQLite; use namespace::autoclean; use Moose::Role; +sub _create_table { + my $self = shift; + my $table = shift; + + my $no_comments = 0; + my $add_drop_table = 1; + my $sqlite_version = 0; + + my $create_table; + my (@create, @column_defs, @index_defs, @constraint_defs); + + $create_table .= 'DROP TABLE ' . $table->name . ";\n" if $add_drop_table; + $create_table .= 'CREATE TABLE ' . $table->name . " (\n"; + + push @column_defs, $self->_create_column($_) for values %{$table->columns}; + $create_table .= join(",\n", map { ' ' . $_ } @column_defs ) . "\n)"; + + print $create_table . "\n"; + return (@create, $create_table, @index_defs, @constraint_defs ); +} + +sub _create_column { + my $self = shift; + my $column = shift; + + my $size = $column->data_type =~ /^(timestamp)/i ? undef : $column->size; + + my $column_def; + $column_def = $column->name . ' ' . $column->data_type; + $column_def .= '(' . $column->size . ')' if $size; + $column_def .= ' NOT NULL' unless $column->is_nullable; + $column_def .= ' DEFAULT ' . $column->default_value if $column->default_value; + $column_def; +} + 1;