X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F48xml-to-sqlite.t;h=21e8ad355adc4b5653a961c3592e506c1b88a071;hb=HEAD;hp=c1dba06078ac6dee4b128fbc99f2921a5f5f185d;hpb=f9c96971577d9e276783e98920b3c6346f24f20e;p=dbsrgits%2FSQL-Translator.git diff --git a/t/48xml-to-sqlite.t b/t/48xml-to-sqlite.t index c1dba06..21e8ad3 100644 --- a/t/48xml-to-sqlite.t +++ b/t/48xml-to-sqlite.t @@ -20,8 +20,9 @@ my $xmlfile = "$Bin/data/xml/schema.xml"; my $sqlt; $sqlt = SQL::Translator->new( + quote_identifiers => 1, no_comments => 1, - show_warnings => 1, + show_warnings => 0, add_drop_table => 1, ); @@ -34,42 +35,53 @@ my $sql = $sqlt->translate( ) or die $sqlt->error; eq_or_diff($sql, << "SQL"); - - BEGIN TRANSACTION; -DROP TABLE Basic; +DROP TABLE "Basic"; -CREATE TABLE Basic ( - id INTEGER PRIMARY KEY NOT NULL, - title varchar(100) NOT NULL DEFAULT 'hello', - description text DEFAULT '', - email varchar(255), - explicitnulldef varchar, - explicitemptystring varchar DEFAULT '', +CREATE TABLE "Basic" ( + "id" INTEGER PRIMARY KEY NOT NULL, + "title" varchar(100) NOT NULL DEFAULT 'hello', + "description" text DEFAULT '', + "email" varchar(500), + "explicitnulldef" varchar, + "explicitemptystring" varchar DEFAULT '', -- Hello emptytagdef - emptytagdef varchar DEFAULT '', - another_id int(10) DEFAULT '2', - timest timestamp + "emptytagdef" varchar DEFAULT '', + "another_id" int(10) DEFAULT 2, + "timest" timestamp, + FOREIGN KEY ("another_id") REFERENCES "Another"("id") ); -CREATE INDEX titleindex_Basic ON Basic (title); +CREATE INDEX "titleindex" ON "Basic" ("title"); + +CREATE UNIQUE INDEX "emailuniqueindex" ON "Basic" ("email"); -CREATE UNIQUE INDEX emailuniqueindex_Basic 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; +DROP TABLE "Another"; -CREATE TABLE Another ( - id INTEGER PRIMARY KEY NOT NULL +CREATE TABLE "Another" ( + "id" INTEGER PRIMARY KEY NOT NULL, + "num" numeric(10,2) ); -DROP VIEW IF EXISTS email_list; -CREATE VIEW email_list AS - SELECT email FROM Basic WHERE email IS NOT NULL; +DROP VIEW IF EXISTS "email_list"; + +CREATE VIEW "email_list" AS + SELECT email FROM Basic WHERE (email IS NOT NULL); + +DROP TRIGGER IF EXISTS "foo_trigger"; -DROP TRIGGER IF EXISTS foo_trigger; +CREATE TRIGGER "foo_trigger" after insert on "Basic" BEGIN update modified=timestamp(); END; -CREATE TRIGGER foo_trigger after insert on Basic BEGIN update modified=timestamp(); END; +DROP TRIGGER IF EXISTS "bar_trigger_insert"; + +CREATE TRIGGER "bar_trigger_insert" before insert on "Basic" BEGIN update modified2=timestamp(); END; + +DROP TRIGGER IF EXISTS "bar_trigger_update"; + +CREATE TRIGGER "bar_trigger_update" before update on "Basic" BEGIN update modified2=timestamp(); END; COMMIT; SQL @@ -81,34 +93,42 @@ my @sql = $sqlt->translate( filename => $xmlfile, ) or die $sqlt->error; -eq_or_diff(\@sql, +eq_or_diff(\@sql, [ - "\n\nBEGIN TRANSACTION", - 'DROP TABLE Basic', - 'CREATE TABLE Basic ( - id INTEGER PRIMARY KEY NOT NULL, - title varchar(100) NOT NULL DEFAULT \'hello\', - description text DEFAULT \'\', - email varchar(255), - explicitnulldef varchar, - explicitemptystring varchar DEFAULT \'\', + 'BEGIN TRANSACTION', + q, + q, + q, + q, + q, + q, + q, + q, + q, + q, + q, + q, + q, + q, + q, + 'COMMIT', + ], 'SQLite translate in list context matches');