IonSystems / tiberius-robot

Repository for all software modules used by Heriot-Watt University's Tiberius Robot.
1 stars 0 forks source link

Incorrect delete() implementation in sqlite_database.py #30

Closed camieac closed 8 years ago

camieac commented 8 years ago

sqlite_database.py can be found here: https://github.com/IonSystems/tiberius-robot/blob/master/tiberius/database/sqlite_database.py

The bit that we need to fix is here:

def delete(self, table_name, conditions=None):
        self.c.execute(self.__generate_delete(table_name, conditions))
        self.conn.commit()
        return

and here:

def __generate_delete(self, table_name, conditions):
        query = SqlClauses.DELETE.value + " "
        query += SqlClauses.FROM.value + " "
        query += table_name
        if not conditions:
            return query
        else:
            query += " " + self.__generate_conditions(conditions)
            return query

If there are no conditions given, then the following output is generated `DELETE FROM test_table' which doesn't actually do anything...

For now, if no conditions are given, then the following SQL statement should be generated: DELETE * FROM table_name which is what you would expect the behaviour to be with no conditions.

camieac commented 8 years ago

Ok, sqlite actually uses the format that we already have implemented (`DELETE FROM test_table'), so there is actually no issue there.

It turns out some of the tests were written incorrectly.