+* Fix Producer::Oracle generation of too long unique constraint names
+* Producer::Oracle tests now use Test::Differences
* Prettify output of SQLite producer (less bogus newlines)
* Augment SQLite and Pg producers to accept a perl-formatted
(%d.%03d%03d) *_version producer args (to facilitate direct
if ($name) {
# Force prepend of table_name as ORACLE doesn't allow duplicate
# CONSTRAINT names even for different tables (ORA-02264)
- $name = "${table_name}_$name" unless $name =~ /^$table_name/;
+ $name = mk_name( "${table_name}_$name", 'u' ) unless $name =~ /^$table_name/;
}
else {
$name = mk_name( $table_name, 'u' );
#=============================================================================
BEGIN {
- maybe_plan(224, 'SQL::Translator::Parser::XML::SQLFairy');
+ maybe_plan(238, 'SQL::Translator::Parser::XML::SQLFairy');
}
my $testschema = "$Bin/data/xml/schema.xml";
is_nullable => 0,
default_value => "hello",
size => 100,
+ is_unique => 1,
},
{
name => "description",
fields => ["email"],
},
{
+ name => 'very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms',
+ type => UNIQUE,
+ fields => ["title"],
+ },
+ {
type => FOREIGN_KEY,
fields => ["another_id"],
reference_table => "Another",
is_nullable: 0
default_value: hello
is_primary_key: 0
- is_unique: 0
+ is_unique: 1
is_auto_increment: 0
is_foreign_key: 0
foreign_key_reference:
options:
is_valid: 1
+ very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms
+ type: UNIQUE
+ fields: title
+ expression:
+ match_type:
+ reference_fields:
+ reference_table:
+ deferrable: 1
+ on_delete:
+ on_update:
+ options:
+ is_valid: 1
+
?
type: FOREIGN KEY
fields: another_id
another_id INTEGER DEFAULT 2,
timest TIMESTAMP,
PRIMARY KEY (id),
- CONSTRAINT emailuniqueindex UNIQUE (email)
+ CONSTRAINT emailuniqueindex UNIQUE (email),
+ CONSTRAINT very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms UNIQUE (title)
);
DROP TABLE Another;
another_id INTEGER DEFAULT 2,
timest TIMESTAMP,
PRIMARY KEY (id),
- CONSTRAINT emailuniqueindex UNIQUE (email)
+ CONSTRAINT emailuniqueindex UNIQUE (email),
+ CONSTRAINT very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms UNIQUE (title)
);|,
'DROP TABLE Another;',
"another_id" integer DEFAULT '2',
"timest" timestamp,
PRIMARY KEY ("id"),
- CONSTRAINT "emailuniqueindex" UNIQUE ("email")
+ CONSTRAINT "emailuniqueindex" UNIQUE ("email"),
+ CONSTRAINT "very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms" UNIQUE ("title")
);
CREATE INDEX "titleindex" on "Basic" ("title");
CREATE UNIQUE INDEX emailuniqueindex ON Basic (email);
+CREATE UNIQUE INDEX very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms ON Basic (title);
+
DROP TABLE Another;
CREATE TABLE Another (
)',
'CREATE INDEX titleindex ON Basic (title)',
'CREATE UNIQUE INDEX emailuniqueindex ON Basic (email)',
+ 'CREATE UNIQUE INDEX very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms ON Basic (title)',
'DROP TABLE Another',
'CREATE TABLE Another (
id INTEGER PRIMARY KEY NOT NULL,
use Test::More;
use Test::SQL::Translator;
use Test::Exception;
+use Test::Differences;
use Data::Dumper;
use SQL::Translator;
use SQL::Translator::Schema::Constants;
another_id number(10) DEFAULT \'2\',
timest date,
PRIMARY KEY (id),
- CONSTRAINT Basic_emailuniqueindex UNIQUE (email)
+ CONSTRAINT u_Basic_emailuniqueindex UNIQUE (email),
+ CONSTRAINT u_Basic_very_long_index_name_o UNIQUE (title)
)',
'DROP TABLE Another CASCADE CONSTRAINTS',
'DROP SEQUENCE sq_Another_id',
is_deeply(\@sql, $want, 'Got correct Oracle statements in list context');
-is($sql_string, q|DROP TABLE Basic CASCADE CONSTRAINTS;
+eq_or_diff($sql_string, q|DROP TABLE Basic CASCADE CONSTRAINTS;
DROP SEQUENCE sq_Basic_id01;
another_id number(10) DEFAULT '2',
timest date,
PRIMARY KEY (id),
- CONSTRAINT Basic_emailuniqueindex UNIQUE (email)
+ CONSTRAINT u_Basic_emailuniqueindex01 UNIQUE (email),
+ CONSTRAINT u_Basic_very_long_index_name01 UNIQUE (title)
);
DROP TABLE Another CASCADE CONSTRAINTS;
use Test::More;
use Test::SQL::Translator;
use Test::Exception;
+use Test::Differences;
use Data::Dumper;
use SQL::Translator;
use SQL::Translator::Schema::Constants;
"another_id" number(10) DEFAULT \'2\',
"timest" date,
PRIMARY KEY ("id"),
- CONSTRAINT "Basic_emailuniqueindex" UNIQUE ("email")
+ CONSTRAINT "u_Basic_emailuniqueindex" UNIQUE ("email"),
+ CONSTRAINT "u_Basic_very_long_index_name_o" UNIQUE ("title")
)',
'DROP TABLE "Another" CASCADE CONSTRAINTS',
'DROP SEQUENCE "sq_Another_id"',
is_deeply(\@sql, $want, 'Got correct Oracle statements in list context');
-is($sql_string, q|DROP TABLE "Basic" CASCADE CONSTRAINTS;
+eq_or_diff($sql_string, q|DROP TABLE "Basic" CASCADE CONSTRAINTS;
DROP SEQUENCE "sq_Basic_id01";
"another_id" number(10) DEFAULT '2',
"timest" date,
PRIMARY KEY ("id"),
- CONSTRAINT "Basic_emailuniqueindex" UNIQUE ("email")
+ CONSTRAINT "u_Basic_emailuniqueindex01" UNIQUE ("email"),
+ CONSTRAINT "u_Basic_very_long_index_name01" UNIQUE ("title")
);
DROP TABLE "Another" CASCADE CONSTRAINTS;
<extra foo="bar" hello="world" bar="baz" />
</constraint>
<constraint name="emailuniqueindex" type="UNIQUE" fields="email" />
+ <constraint name="very_long_index_name_on_title_field_which_should_be_truncated_for_various_rdbms" type="UNIQUE" fields="title" />
<constraint name="" type="FOREIGN KEY" fields="another_id"
reference_table="Another" options="" deferrable="1" match_type=""
expression="" on_update="" on_delete="">