diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-25 10:44:00 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-25 10:44:00 +0200 |
| commit | 7056ad696ad5397ba763a70808b379e213e529f9 (patch) | |
| tree | 07b50f89a0167ad2e666f5ed00607e8a93205ae9 /opendc/models/model.py | |
| parent | afeae8c5cd413dfda8836e1fec6f3ed1b00ce6aa (diff) | |
Fix rack to tile add endpoint
Diffstat (limited to 'opendc/models/model.py')
| -rw-r--r-- | opendc/models/model.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/opendc/models/model.py b/opendc/models/model.py index 2507a287..18ea61f4 100644 --- a/opendc/models/model.py +++ b/opendc/models/model.py @@ -278,7 +278,7 @@ class Model(object): self.insert_with_id() - def insert_with_id(self): + def insert_with_id(self, is_auto_generated=True): """Insert this Model into the database without removing its id.""" statement = 'INSERT INTO {} ({}) VALUES ({})'.format( @@ -296,7 +296,8 @@ class Model(object): raise exceptions.ForeignKeyError(e.message) if 'id' in self.COLUMNS_PRIMARY_KEY: - setattr(self, 'id', last_row_id) + if is_auto_generated: + setattr(self, 'id', last_row_id) self.read() def read(self): |
