def test_transform_table_ddl_without_double_quote_around_schema_nor_table_name( self): ddl = 'CREATE TABLE IF NOT EXISTS public.test ( "id""ea" INTEGER ENCODE lzo)DISTSTYLE EVEN;' transformed_ddl = DDLTransformer.get_ddl_for_different_relation( ddl, new_table_name='b') expected = 'CREATE TABLE IF NOT EXISTS public.b( "id""ea" INTEGER ENCODE lzo)DISTSTYLE EVEN;' self.assertEquals(transformed_ddl, expected)
def clone_structure_from(self, other): ddl = other.get_create_sql(generate=True) if self.get_schema() != other.get_schema(): ddl = DDLTransformer.get_ddl_for_different_relation( ddl, new_schema_name=self.get_schema() ) self.set_create_sql(ddl)
def clone_structure_from(self, other): ddl = other.get_create_sql(generate=True) if self.get_db() != other.get_db(): ddl = DDLTransformer.get_ddl_for_different_database( ddl, new_database_name=self.get_db() ) self.set_create_sql(ddl)
def test_get_ddl_for_different_database_name(self): ddl_string = ' CREATE DATABASE {db} WITH CONNECTION LIMIT UNLIMITED;' test_string = ddl_string.format(db='"my""data"') new_db_name = '"ab"""' expected_string = ddl_string.format(db=new_db_name) self.assertEquals( expected_string, DDLTransformer.get_ddl_for_different_database( test_string, new_db_name))
def clone_structure_from(self, other): ddl = other.get_create_sql(generate=True) if self.get_schema() != other.get_schema() or self.get_table( ) != other.get_table(): ddl = DDLTransformer.get_ddl_for_different_relation( ddl, new_table_name=self.get_table(), new_schema_name=self.get_schema()) self.set_create_sql(ddl) self.parent.clone_structure_from(other.parent)
def clone_structure_from(self, other): ddl = other.get_create_sql(generate=True) if self.get_db() != other.get_db(): ddl = DDLTransformer.get_ddl_for_different_database( ddl, new_database_name=self.get_db()) self.set_create_sql(ddl)
def test_transform_table_ddl(self): ddl = 'CREATE TABLE IF NOT EXISTS "public"."test_""_quote" ( "id""ea" INTEGER ENCODE lzo)DISTSTYLE EVEN;' transformed_ddl = DDLTransformer.get_ddl_for_different_relation( ddl, new_table_name='b') expected = 'CREATE TABLE IF NOT EXISTS public.b( "id""ea" INTEGER ENCODE lzo)DISTSTYLE EVEN;' self.assertEquals(transformed_ddl, expected)