File: 03mysql-to-oracle.t

package info (click to toggle)
libsql-translator-perl 0.11011-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 15,380 kB
  • sloc: perl: 251,748; sql: 3,805; xml: 233; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/local/bin/perl
# vim: set ft=perl:

use strict;
use Test::More;
use SQL::Translator;
use Test::SQL::Translator qw(maybe_plan);

my $create = q|
CREATE TABLE random (
    id int auto_increment PRIMARY KEY,
    foo varchar(255) not null default '',
    updated timestamp
);
CREATE UNIQUE INDEX random_foo_update ON random(foo,updated);
CREATE INDEX random_foo ON random(foo);

|;

BEGIN {
    maybe_plan(3,
        'SQL::Translator::Parser::MySQL',
        'SQL::Translator::Producer::Oracle');
}

my $tr       = SQL::Translator->new(
    parser   => "MySQL",
    producer => "Oracle",
    quote_table_names => 0,
    quote_field_names => 0,
);

my $output = $tr->translate(\$create);

ok( $output, 'Translate MySQL to Oracle' );
ok( $output =~ /CREATE INDEX random_foo /, 'Normal index definition translated.');
ok( $output =~ /CREATE UNIQUE INDEX random_foo_update /, 'Unique index definition translated.');