diff --git a/README.md b/README.md index bc455f9..423e834 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ $ pip install git+https://github.com/mimesis-inria/SimulationSimpleDatabase.git # Option 2 (DEVS): install as editable $ git clone https://github.com/mimesis-inria/SimulationSimpleDatabase.git -$ cd SimRender +$ cd SimulationSimpleDatabase $ pip install -e . ``` diff --git a/docs/src/install.rst b/docs/src/install.rst index d4243f6..ca22217 100644 --- a/docs/src/install.rst +++ b/docs/src/install.rst @@ -35,7 +35,7 @@ Install with *pip* .. code-block:: bash - $ pip install git+https://github.com/mimesis-inria/SimulationSimpleDatabase.git + pip install git+https://github.com/mimesis-inria/SimulationSimpleDatabase.git Then, you should be able to run: diff --git a/src/SSD/core/database.py b/src/SSD/core/database.py index b16aace..8d246ca 100644 --- a/src/SSD/core/database.py +++ b/src/SSD/core/database.py @@ -253,13 +253,14 @@ def __new_fields(self, field_name, field_type = field[0], field[1] field_default = '_null_' if len(field) == 2 else field[2] - # As peewee.Model creates a new attribute named field_name, check that this attribute does not exist - if field_name in [m[0] for m in getmembers(table)]: - raise ValueError(f"Tried to create a field '{field_name}' in the Table '{table_name}'. " - f"You are not allowed to create a field with this name, please rename it.") - # Extend the Table if field_name not in table.fields(): + + # As peewee.Model creates a new attribute named field_name, check that this attribute does not exist + if field_name in [m[0] for m in getmembers(table)]: + raise ValueError(f"Tried to create a field '{field_name}' in the Table '{table_name}'. " + f"You are not allowed to create a field with this name, please rename it.") + # FK if type(field_type) == str: if (fk_table_name := self.make_name(field_type)) not in self.__tables.keys(): @@ -267,6 +268,8 @@ def __new_fields(self, f"exists. Created Tables so far: {self.__tables.keys()}") table.extend_fk(self.__tables[fk_table_name], field_name) self.__fk[table_name][field_name] = fk_table_name + + # Standard field else: table.extend(field_name, field_type, field_default)