X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F02mysql-parser.t;h=36cef3c4e5a6941655b14633108e04f4eb2a83e2;hb=5b7d1de74d72f3946dc4454806ece831a16f3031;hp=d419584348ebc877bc44e68c1464d951d8e2ca91;hpb=7dcf6bc28426bba6fead19845635ee445c76a44a;p=dbsrgits%2FSQL-Translator-2.0-ish.git diff --git a/t/02mysql-parser.t b/t/02mysql-parser.t index d419584..36cef3c 100644 --- a/t/02mysql-parser.t +++ b/t/02mysql-parser.t @@ -36,7 +36,7 @@ use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants); is( $f2->name, 'a_session', 'Second field name is "a_session"' ); is( $f2->data_type, 'text', 'Type is "text"' ); - is( $f2->size, 65_535, 'Size is "65,535"' ); + is( $f2->size, 0, 'Size is "0"' ); is( $f2->is_nullable, 1, 'Field can be null' ); is( $f2->default_value, undef, 'Default value is undefined' ); is( $f2->is_primary_key, 0, 'Field is not PK' ); @@ -129,7 +129,7 @@ use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants); my $f5 = shift @fields; is( $f5->name, 's1', 'Fifth field name is "s1"' ); is( $f5->data_type, 'set', 'Type is "set"' ); - is( $f5->size, 1, 'Size is "1"' ); + is( $f5->size, 0, 'Size is "0"' ); is( $f5->is_nullable, 1, 'Field can be null' ); is( $f5->default_value, 'b', 'Default value is "b"' ); is( $f5->is_primary_key, 0, 'Field is not PK' ); @@ -139,7 +139,7 @@ use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants); my $f6 = shift @fields; is( $f6->name, 'e1', 'Sixth field name is "e1"' ); is( $f6->data_type, 'enum', 'Type is "enum"' ); - is( $f6->size, 1, 'Size is "1"' ); + is( $f6->size, 0, 'Size is "0"' ); is( $f6->is_nullable, 1, 'Field can be null' ); is( $f6->default_value, 'c', 'Default value is "c"' ); is( $f6->is_primary_key, 0, 'Field is not PK' ); @@ -157,7 +157,7 @@ use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants); my $f8 = shift @fields; is( $f8->name, 'foo_type', 'Eighth field name is "foo_type"' ); is( $f8->data_type, 'enum', 'Type is "enum"' ); - is( $f8->size, 2, 'Size is "2"' ); + is( $f8->size, 0, 'Size is "0"' ); is( $f8->is_nullable, 0, 'Field cannot be null' ); is( $f8->default_value, 'vk', 'Default value is "vk"' ); is( $f8->is_primary_key, 0, 'Field is not PK' ); @@ -196,7 +196,7 @@ use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants); my $i3 = shift @indices; is( $i3->name, 'name_idx', 'Name is "name_idx"' ); is( $i3->type, NORMAL, 'Normal index' ); - is( join(',', $i3->fields ), 'name(10)', 'Index is on field "name(10)"' ); + is( join(',', $i3->fields ), 'name', 'Index is on field "name(10)"' ); ## FIX ME my @constraints = $table->get_constraints; is( scalar @constraints, 2, 'Right number of constraints (2)' ); @@ -263,8 +263,8 @@ use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants); my $f1 = shift @fields; is( $f1->name, 'order_id', 'First field name is "order_id"' ); - is( $f1->data_type, 'int', 'Type is "int"' ); - is( $f1->size, 11, 'Size is "11"' ); + is( $f1->data_type, 'integer', 'Type is "integer"' ); + is( $f1->size, 0, 'Size is "0"' ); is( $f1->is_nullable, 0, 'Field cannot be null' ); is( $f1->default_value, undef, 'Default value is undefined' ); is( $f1->is_primary_key, 1, 'Field is PK' ); @@ -282,23 +282,23 @@ use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants); is( $f3->name, 'billing_address_id', 'Third field name is "billing_address_id"' ); is( $f3->data_type, 'int', 'Type is "int"' ); - is( $f3->size, 11, 'Size is "11"' ); + is( $f3->size, 0, 'Size is "0"' ); my $f4 = shift @fields; is( $f4->name, 'shipping_address_id', 'Fourth field name is "shipping_address_id"' ); is( $f4->data_type, 'int', 'Type is "int"' ); - is( $f4->size, 11, 'Size is "11"' ); + is( $f4->size, 0, 'Size is "0"' ); my $f5 = shift @fields; is( $f5->name, 'credit_card_id', 'Fifth field name is "credit_card_id"' ); is( $f5->data_type, 'int', 'Type is "int"' ); - is( $f5->size, 11, 'Size is "11"' ); + is( $f5->size, 0, 'Size is "0"' ); my $f6 = shift @fields; is( $f6->name, 'status', 'Sixth field name is "status"' ); is( $f6->data_type, 'smallint', 'Type is "smallint"' ); - is( $f6->size, 6, 'Size is "6"' ); + is( $f6->size, 0, 'Size is "0"' ); is( $f6->is_nullable, 0, 'Field cannot be null' ); my $f7 = shift @fields; @@ -308,7 +308,7 @@ use SQL::Translator::Constants qw(:sqlt_types :sqlt_constants); is( $f7->is_nullable, 0, 'Field cannot be null' ); is( $f7->is_foreign_key, 1, 'Field is a FK' ); my $fk_ref = $f7->foreign_key_reference; - isa_ok( $fk_ref, 'SQL::Translator::Schema::Constraint', 'FK' ); + isa_ok( $fk_ref, 'SQL::Translator::Object::Constraint', 'FK' ); is( $fk_ref->reference_table, 'store', 'FK is to "store" table' ); my $f8 = shift @fields; @@ -673,10 +673,11 @@ my $parse_as = { }, }; +my $tr = SQL::Translator->new; for my $target (keys %$parse_as) { for my $str (keys %{$parse_as->{$target}}) { cmp_ok ( - SQL::Translator::Utils::parse_mysql_version ($str, $target), + $tr->engine_version($str, $target), '==', $parse_as->{$target}{$str}, "'$str' parsed as $target version '$parse_as->{$target}{$str}'", @@ -684,11 +685,11 @@ for my $target (keys %$parse_as) { } } -eval { SQL::Translator::Utils::parse_mysql_version ('bogus5.1') }; +eval { $tr->engine_version ('bogus5.1') }; ok ($@, 'Exception thrown on invalid version string'); { - my $tr = SQL::Translator->new; + my $tr = SQL::Translator->new({ from => 'MySQL' }); my $data = q|create table merge_example ( id int(11) NOT NULL auto_increment, shape_field geometry NOT NULL, @@ -840,3 +841,5 @@ ok ($@, 'Exception thrown on invalid version string'); is( $f3->default_value, "test single quotes escaped like you\\'re", "Single quote in default value is escaped properly" ); is( $f3->is_primary_key, 0, 'Field is not PK' ); } + +done_testing;