public function setUp()
    {
        $this->testHandler = new Monolog\Handler\TestHandler();
        dbsteward::get_logger()->pushHandler($this->testHandler);
        // format doesn't really matter
        dbsteward::set_sql_format('pgsql8');
        dbsteward::$quote_schema_names = TRUE;
        dbsteward::$quote_table_names = TRUE;
        dbsteward::$quote_column_names = TRUE;
        dbsteward::$quote_function_names = TRUE;
        dbsteward::$quote_object_names = TRUE;
        $xml = <<<XML
<dbsteward>
  <database>
    <host>db-host</host>
    <name>dbsteward</name>
    <role>
      <application>dbsteward_phpunit_app</application>
      <owner>deployment</owner>
      <replication/>
      <readonly/>
      <customRole>custom</customRole>
    </role>
  </database>
</dbsteward>
XML;
        $this->dbdoc = new SimpleXMLElement($xml);
    }
    public function setUp()
    {
        dbsteward::set_sql_format('pgsql8');
        dbsteward::$quote_schema_names = TRUE;
        dbsteward::$quote_table_names = TRUE;
        dbsteward::$quote_column_names = TRUE;
        dbsteward::$quote_function_names = TRUE;
        dbsteward::$quote_object_names = TRUE;
        $xml = <<<XML
<dbsteward>
  <database>
    <host>db-host</host>
    <name>dbsteward</name>
    <role>
      <application>dbsteward_phpunit_app</application>
      <owner>deployment</owner>
      <replication/>
      <readonly/>
    </role>
  </database>
</dbsteward>
XML;
        $db = new SimpleXMLElement($xml);
        dbsteward::$new_database = $db;
        dbsteward::$old_database = $db;
    }
    public function setUp()
    {
        dbsteward::set_sql_format('mysql5');
        dbsteward::$quote_schema_names = TRUE;
        dbsteward::$quote_table_names = TRUE;
        dbsteward::$quote_column_names = TRUE;
        dbsteward::$quote_function_names = TRUE;
        dbsteward::$quote_object_names = TRUE;
        mysql5::$use_auto_increment_table_options = FALSE;
        mysql5::$use_schema_name_prefix = FALSE;
        $xml = <<<XML
<dbsteward>
  <database>
    <host>db-host</host>
    <name>dbsteward</name>
    <role>
      <application>dbsteward_phpunit_app</application>
      <owner>deployment</owner>
      <replication/>
      <readonly/>
    </role>
  </database>
</dbsteward>
XML;
        $this->dbdoc = new SimpleXMLElement($xml);
    }
 public function setUp()
 {
     dbsteward::set_sql_format('mysql5');
     // define_sql_format_default_values sets these like this
     dbsteward::$quote_schema_names = TRUE;
     dbsteward::$quote_table_names = TRUE;
     dbsteward::$quote_column_names = TRUE;
 }
 public function setUp()
 {
     dbsteward::$quote_schema_names = TRUE;
     dbsteward::$quote_table_names = TRUE;
     dbsteward::$quote_column_names = TRUE;
     dbsteward::$quote_function_names = TRUE;
     dbsteward::$quote_object_names = TRUE;
 }
 public function setUp()
 {
     dbsteward::set_sql_format('pgsql8');
     dbsteward::$quote_schema_names = TRUE;
     dbsteward::$quote_table_names = TRUE;
     dbsteward::$quote_column_names = TRUE;
     dbsteward::$quote_function_names = TRUE;
     dbsteward::$quote_object_names = TRUE;
 }
 public function setUp()
 {
     dbsteward::set_sql_format('mysql5');
     dbsteward::$quote_schema_names = TRUE;
     dbsteward::$quote_table_names = TRUE;
     dbsteward::$quote_column_names = TRUE;
     mysql5::$use_auto_increment_table_options = FALSE;
     mysql5::$use_schema_name_prefix = FALSE;
 }
 public function setUp()
 {
     dbsteward::$quote_all_names = FALSE;
     dbsteward::$quote_schema_names = FALSE;
     dbsteward::$quote_table_names = FALSE;
     dbsteward::$quote_column_names = FALSE;
     dbsteward::$quote_function_names = FALSE;
     dbsteward::$quote_object_names = FALSE;
     dbsteward::$quote_illegal_identifiers = FALSE;
     dbsteward::$quote_reserved_identifiers = FALSE;
 }
 public function setUp()
 {
     dbsteward::set_sql_format('mysql5');
     dbsteward::$quote_schema_names = TRUE;
     dbsteward::$quote_table_names = TRUE;
     dbsteward::$quote_column_names = TRUE;
     mysql5::$swap_function_delimiters = FALSE;
     mysql5::$use_auto_increment_table_options = FALSE;
     mysql5::$use_schema_name_prefix = FALSE;
     $this->config = $GLOBALS['db_config']->mysql5_config;
     $this->connect();
     $this->setup_shim();
 }
示例#10
0
    public function testColumnCaseChange()
    {
        $lower = <<<XML
<schema name="test0" owner="NOBODY">
  <table name="table" owner="NOBODY">
    <column name="column" type="int" />
  </table>
</schema>
XML;
        $upper_with_oldname = <<<XML
<schema name="test0" owner="NOBODY">
  <table name="table" owner="NOBODY">
    <column name="CoLuMn" type="int" oldColumnName="column" />
  </table>
</schema>
XML;
        $upper_without_oldname = <<<XML
<schema name="test0" owner="NOBODY">
  <table name="table" owner="NOBODY">
    <column name="CoLuMn" type="int" />
  </table>
</schema>
XML;
        // when quoting is off, a change in case is a no-op
        dbsteward::$quote_all_names = FALSE;
        dbsteward::$quote_column_names = FALSE;
        $this->common_diff($lower, $upper_without_oldname, '', '');
        // when quoting is on, a change in case results in a rename
        dbsteward::$quote_all_names = TRUE;
        dbsteward::$quote_column_names = TRUE;
        $this->common_diff($lower, $upper_with_oldname, "-- column rename from oldColumnName specification\nALTER TABLE \"test0\".\"table\" RENAME COLUMN \"column\" TO \"CoLuMn\";", '');
        // but, if oldColumnName is not given when doing case sensitive renames, it should throw
        try {
            $this->common_diff($lower, $upper_without_oldname, 'NO EXPECTED OUTPUT', 'NO EXPECTED OUTPUT');
        } catch (Exception $e) {
            $this->assertContains('ambiguous operation', strtolower($e->getMessage()));
            return;
        }
        $this->fail("Expected an 'ambiguous operation' exception due to column case change, got nothing.");
    }
    public function setUp()
    {
        dbsteward::set_sql_format('mysql5');
        dbsteward::$quote_schema_names = TRUE;
        dbsteward::$quote_table_names = TRUE;
        dbsteward::$quote_column_names = TRUE;
        dbsteward::$quote_function_names = TRUE;
        mysql5::$swap_function_delimiters = FALSE;
        mysql5::$use_auto_increment_table_options = FALSE;
        mysql5::$use_schema_name_prefix = FALSE;
        $db_doc_xml = <<<XML
<dbsteward>
  <database>
    <role>
      <owner>the_owner</owner>
      <customRole>SOMEBODY</customRole>
    </role>
  </database>
</dbsteward>
XML;
        dbsteward::$new_database = new SimpleXMLElement($db_doc_xml);
    }
 protected function setup_mysql5()
 {
     $base_xml = '';
     $strict_overlay_xml = '';
     $new_table_xml = '';
     $this->setup_definition_xml($base_xml, $strict_overlay_xml, $new_table_xml);
     $this->xml_file_a = dirname(__FILE__) . '/../testdata/mysql5_unit_test_xml_a.xml';
     $this->xml_file_b = dirname(__FILE__) . '/../testdata/mysql5_unit_test_xml_b.xml';
     $this->xml_file_c = dirname(__FILE__) . '/../testdata/mysql5_unit_test_xml_c.xml';
     $this->set_xml_content_a($base_xml);
     $this->set_xml_content_b($strict_overlay_xml);
     $this->set_xml_content_c($new_table_xml);
     $this->output_prefix = dirname(__FILE__) . '/../testdata/mysql5_unit_test_column_nulls';
     dbsteward::$quote_column_names = TRUE;
     dbsteward::$single_stage_upgrade = TRUE;
 }
示例#13
0
 protected static function define_sql_format_default_values($sql_format, $options)
 {
     ///// sql_format-specific default options
     $dbport = FALSE;
     if (strcasecmp($sql_format, 'pgsql8') == 0) {
         dbsteward::$create_languages = TRUE;
         dbsteward::$quote_schema_names = FALSE;
         dbsteward::$quote_table_names = FALSE;
         dbsteward::$quote_column_names = FALSE;
         $dbport = '5432';
     } else {
         if (strcasecmp($sql_format, 'mssql10') == 0) {
             // needed for MSSQL keyword-named-columns like system_user
             dbsteward::$quote_table_names = TRUE;
             dbsteward::$quote_column_names = TRUE;
             $dbport = '1433';
         } else {
             if (strcasecmp($sql_format, 'mysql5') == 0) {
                 dbsteward::$quote_schema_names = TRUE;
                 dbsteward::$quote_table_names = TRUE;
                 dbsteward::$quote_column_names = TRUE;
                 $dbport = '3306';
                 if (isset($options['useautoincrementoptions'])) {
                     mysql5::$use_auto_increment_table_options = TRUE;
                 }
                 if (isset($options['useschemaprefix'])) {
                     mysql5::$use_schema_name_prefix = TRUE;
                 }
             }
         }
     }
     if (strcasecmp($sql_format, 'pgsql8') != 0) {
         if (isset($options['pgdataxml'])) {
             dbsteward::error("pgdataxml parameter is not supported by " . dbsteward::get_sql_format() . " driver");
             exit(1);
         }
     }
     return $dbport;
 }
示例#14
0
    public function testCompositeForeignKeyReferentialConstraints()
    {
        dbsteward::$quote_all_names = false;
        dbsteward::$quote_schema_names = false;
        dbsteward::$quote_table_names = false;
        dbsteward::$quote_column_names = false;
        dbsteward::$quote_function_names = false;
        dbsteward::$quote_object_names = false;
        $sql = <<<SQL
CREATE TABLE dummy (foo int, bar varchar(32), PRIMARY KEY (foo, bar));
CREATE TABLE test (
  id int PRIMARY KEY,
  foo int,
  bar varchar(32),
  FOREIGN KEY (foo, bar) REFERENCES dummy (foo, bar)
    ON UPDATE NO ACTION
    ON DELETE SET NULL
);
SQL;
        $schemaname = __CLASS__;
        $expected = <<<XML
<foreignKey
  columns="foo, bar"
  foreignSchema="{$schemaname}"
  foreignTable="dummy"
  foreignColumns="foo, bar"
  constraintName="test_foo_fkey"
  onUpdate="NO_ACTION"
  onDelete="SET_NULL"/>
XML;
        $schema = $this->extract($sql);
        foreach ($schema->table as $table) {
            if ((string) $table['name'] == 'test') {
                $this->assertEquals(simplexml_load_string($expected), $table->foreignKey);
                return;
            }
        }
    }
 protected function apply_options_mysql5()
 {
     dbsteward::set_sql_format('mysql5');
     dbsteward::$quote_schema_names = TRUE;
     dbsteward::$quote_table_names = TRUE;
     dbsteward::$quote_column_names = TRUE;
     dbsteward::$quote_all_names = TRUE;
     mysql5::$swap_function_delimiters = TRUE;
     mysql5::$use_auto_increment_table_options = FALSE;
     mysql5::$use_schema_name_prefix = FALSE;
 }