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');
     dbsteward::$quote_all_names = true;
     mysql5::$swap_function_delimiters = TRUE;
     mysql5::$use_auto_increment_table_options = FALSE;
     mysql5::$use_schema_name_prefix = FALSE;
 }
예제 #3
0
 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::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();
 }
    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);
    }
    public function testCreateTable()
    {
        $xml = <<<XML
<schema name="public" owner="NOBODY">
  <table name="test" primaryKey="id" owner="NOBODY" description="test description">
    <tableOption sqlFormat="mysql5" name="auto_increment" value="5"/>
    <tableOption sqlFormat="mysql5" name="engine" value="InnoDB"/>
    <tableOption sqlFormat="pgsql8" name="inherits" value="other"/>
    <column name="id" type="int"/>
    <column name="foo" type="int"/>
  </table>
</schema>
XML;
        $schema = new SimpleXMLElement($xml);
        mysql5::$use_auto_increment_table_options = TRUE;
        $expected = <<<SQL
CREATE TABLE `test` (
  `id` int,
  `foo` int
)
AUTO_INCREMENT=5
ENGINE=InnoDB
COMMENT 'test description';
SQL;
        $actual = mysql5_table::get_creation_sql($schema, $schema->table);
        $this->assertEquals($expected, $actual);
        mysql5::$use_auto_increment_table_options = FALSE;
        $expected = <<<SQL
CREATE TABLE `test` (
  `id` int,
  `foo` int
)
ENGINE=InnoDB
COMMENT 'test description';
SQL;
        $actual = mysql5_table::get_creation_sql($schema, $schema->table);
        $this->assertEquals($expected, $actual);
    }
예제 #7
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;
 }
    public function testDropAddAlter()
    {
        $old = <<<XML
<schema name="public" owner="NOBODY">
  <table name="test" primaryKey="a" owner="NOBODY">
    <tableOption sqlFormat="mysql5" name="engine" value="InnoDB"/>
    <tableOption sqlFormat="mysql5" name="auto_increment" value="5"/>
    <column name="a" type="int"/>
  </table>
</schema>
XML;
        $new = <<<XML
<schema name="public" owner="NOBODY">
  <table name="test" primaryKey="a" owner="NOBODY">
    <tableOption sqlFormat="mysql5" name="auto_increment" value="10"/>
    <tableOption sqlFormat="mysql5" name="row_format" value="compressed"/>
    <column name="a" type="int"/>
  </table>
</schema>
XML;
        mysql5::$use_auto_increment_table_options = TRUE;
        $expected = <<<SQL
-- Table `test` must be recreated to drop options: engine
CREATE TABLE `test_DBSTEWARD_MIGRATION`
AUTO_INCREMENT=10
ROW_FORMAT=compressed
SELECT * FROM `test`;
DROP TABLE `test`;
RENAME TABLE `test_DBSTEWARD_MIGRATION` TO `test`;
SQL;
        $this->common($old, $new, $expected);
        mysql5::$use_auto_increment_table_options = FALSE;
        $expected = <<<SQL
-- Table `test` must be recreated to drop options: engine
CREATE TABLE `test_DBSTEWARD_MIGRATION`
ROW_FORMAT=compressed
SELECT * FROM `test`;
DROP TABLE `test`;
RENAME TABLE `test_DBSTEWARD_MIGRATION` TO `test`;
SQL;
        $this->common($old, $new, $expected);
    }
 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;
 }