def get_database_name_out_of_ddl(ddl):
     clean_ddl = SQLTextHelper.get_sql_without_commands_newlines_and_whitespace(ddl)
     if clean_ddl.upper().startswith('CREATE DATABASE "'):
         return SQLTextHelper.get_first_double_quoted_identifier(clean_ddl)
     elif clean_ddl.upper().startswith('CREATE DATABASE '):
         database_name = clean_ddl.split(' ')[2]
     else:
         raise DDLTransformer.UnsupportedDDLForTransformationException(clean_ddl)
     return database_name
Ejemplo n.º 2
0
 def get_database_name_out_of_ddl(ddl):
     clean_ddl = SQLTextHelper.get_sql_without_commands_newlines_and_whitespace(
         ddl)
     if clean_ddl.upper().startswith('CREATE DATABASE "'):
         return SQLTextHelper.get_first_double_quoted_identifier(clean_ddl)
     elif clean_ddl.upper().startswith('CREATE DATABASE '):
         database_name = clean_ddl.split(' ')[2]
     else:
         raise DDLTransformer.UnsupportedDDLForTransformationException(
             clean_ddl)
     return database_name
Ejemplo n.º 3
0
 def test_extract_first_double_quoted_identifier_from_string_with_escaped_double_quotes_at_end(
         self):
     test_string = 'CREATE DATABASE "test"""'
     self.assertEquals(
         '"test"""',
         SQLTextHelper.get_first_double_quoted_identifier(test_string))