Added "tables" and "options" methods to Schema::View
[dbsrgits/SQL-Translator.git] / t / 02mysql-parser.t
index 46f3277..dbcde4e 100644 (file)
@@ -508,7 +508,7 @@ BEGIN {
 #    charset table option
 #
 {
-    my $tr = SQL::Translator->new(parser_args => {mysql_parser_version => 50003});
+    my $tr = SQL::Translator->new(parser_args => {mysql_parser_version => 50013});
     my $data = parse($tr,
         q[
             DELIMITER ;;
@@ -527,6 +527,7 @@ BEGIN {
 
             /*!50001 CREATE ALGORITHM=UNDEFINED */
             /*!50013 DEFINER=`cmdomain`@`localhost` SQL SECURITY DEFINER */
+            /*!50014 DEFINER=`BOGUS` */
             /*! VIEW `vs_asset` AS
                 select `a`.`asset_id` AS `asset_id`,`a`.`fq_name` AS `fq_name`,
                 `cfgmgmt_mig`.`ap_extract_folder`(`a`.`fq_name`) AS `folder_name`,
@@ -662,7 +663,6 @@ BEGIN {
     is( $view1->name, 'vs_asset', 'Found "vs_asset" view' );
     is( $view2->name, 'vs_asset2', 'Found "vs_asset2" view' );
     is( $view3->name, 'vs_asset3', 'Found "vs_asset3" view' );
-    like($view1->sql, qr/ALGORITHM=UNDEFINED/, "Detected algorithm");
     like($view1->sql, qr/vs_asset/, "Detected view vs_asset");
 
     # KYC - commenting this out as I don't understand why this string
@@ -677,6 +677,18 @@ BEGIN {
         'First view has correct fields'
     );
 
+    my @options = $view1->options;
+
+    is_deeply(
+      \@options,
+      [
+        'ALGORITHM=UNDEFINED',
+        'DEFINER=`cmdomain`@`localhost`',
+        'SQL SECURITY DEFINER',
+      ],
+      'Only version 50013 options parsed',
+    );
+
     my @procs = $schema->get_procedures;
     is( scalar @procs, 2, 'Right number of procedures (2)' );
     my $proc1 = shift @procs;