-
Notifications
You must be signed in to change notification settings - Fork 0
/
DamnWidget_mamba.sql
11 lines (11 loc) · 4.01 KB
/
DamnWidget_mamba.sql
1
2
3
4
5
6
7
8
9
10
11
CREATE TABLE {} (\n'.format(( 'IF NOT EXISTS {}'.format(self.model.__storm_table__) if ( config.Database().create_table_behaviours.get( 'create_table_if_not_exists')) else self.model.__storm_table__ )) primary_keys = self.get_primary_key_columns() if primary_keys is not None: for pk in primary_keys: query += ' {},\n'.format(self.parse_column(pk)) for column, property_ in self.get_storm_columns(): if property_.primary == 1 or self.is_compound_key(property_.name): continue query += ' {},\n'.format(self.parse_column(column)) query += '{}'.format( '{},'.format(self.detect_uniques()) if self.detect_uniques() else '' ) query += ' {}'.format(self.detect_primary_key()) query += '{}'.format( ', {}\n'.format(self.parse_references()) if self.parse_references() else '' ) query += '\n)
CREATE TABLE IF NOT EXISTS `dummy` (' ' id INTEGER PRIMARY KEY, name TEXT' ')
CREATE TABLE IF NOT EXISTS `dummy` (' ' id INTEGER PRIMARY KEY, name TEXT' ')
CREATE INDEX third_id_ind_dummy_seven ON dummy_seven (third_id)' in script ) @common_config(engine='postgres:') def test_model_dump_table_with_postgres_compound_index_field(self): dummy = DummyModelEight() script = dummy.dump_table() + dummy.dump_indexes() self.assertTrue('
CREATE INDEX third_id_ind ON dummy_seven (third_id)' in script ) @common_config(engine='sqlite:') def test_model_dump_table_with_sqlite_compound_index_field(self): dummy = DummyModelEight() script = dummy.dump_table() + dummy.dump_indexes() self.assertTrue('id integer' in script) self.assertTrue('second_id integer,' in script) self.assertTrue('fourth_id integer,' in script) self.assertTrue(( '
CREATE TABLE IF NOT EXISTS stubing (\n' in sql) self.assertTrue(' id integer,\n' in sql) self.assertTrue(' name varchar NOT NULL,\n' in sql) self.assertTrue(' PRIMARY KEY(id)\n)
CREATE INDEX second_id_fourth_id_ind_dummy_eight ON' ' dummy_eight (second_id, fourth_id)') in script ) @common_config(engine='postgres:') def test_model_dump_table_with_postgres_compound_unique_field(self): dummy = DummyModelEight() script = dummy.dump_table() self.assertTrue('
CREATE TABLE IF NOT EXISTS `dummy` (' ' id INTEGER PRIMARY KEY, name TEXT' ')
CREATE TABLE IF NOT EXISTS dummy (\n' in sql) self.assertTrue(' name varchar NOT NULL,\n' in sql) self.assertTrue(' id integer,\n' in sql) self.assertTrue(' PRIMARY KEY(id)\n)
CREATE TABLE {} (\n'.format(( 'IF NOT EXISTS `{}`'.format(self.model.__storm_table__) if ( config.Database().create_table_behaviours.get( 'create_table_if_not_exists')) else '`' + self.model.__storm_table__ + '`' )) primary_keys = self.get_primary_key_columns() if primary_keys is not None: for pk in primary_keys: query += ' {},\n'.format(self.parse_column(pk)) for column, property_ in self.get_storm_columns(): if property_.primary == 1 or self.is_compound_key(property_.name): continue if column.variable_class is not NativeEnumVariable: query += ' {},\n'.format(self.parse_column(column)) else: query += ' {},\n'.format(self.parse_enum(column)) query += ' {}\n'.format(self.detect_primary_key()) query += '{}'.format( ', {}'.format(self.detect_uniques()) if self.detect_uniques() else '' ) query += '{}'.format( ', {}'.format(self.detect_indexes()) if self.detect_indexes() else '' ) query += '{}'.format( ', {}'.format(self.parse_references()) if self.parse_references() else '' ) query += '\n)
CREATE TABLE {} (\n'.format(( 'IF NOT EXISTS {}'.format(self.model.__storm_table__) if ( config.Database().create_table_behaviours.get( 'create_table_if_not_exists')) else self.model.__storm_table__ )) primary_keys = self.get_primary_key_columns() if primary_keys is not None: for pk in primary_keys: query += ' {},\n'.format(self.parse_column(pk)) for column, property_ in self.get_storm_columns(): if property_.primary == 1 or self.is_compound_key(property_.name): continue if column.variable_class is not NativeEnumVariable: query += ' {},\n'.format(self.parse_column(column)) else: enums.append(self.parse_enum(column)) query += ' {},\n'.format(self.parse_column(column)) query += '{}'.format( '{},'.format(self.detect_uniques()) if self.detect_uniques() else '' ) query += ' {}\n)