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()
    {
        $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('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();
 }
    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);
    }
Exemple #11
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 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;
 }