updateQuery method
Implementation
@override
Future<int?> updateQuery(String sql) async {
if (_conn == null)
throw ArgumentError("connect() must be called before updateQuery");
try {
Results results = await _conn!.query(sql);
return results.affectedRows;
} catch (e) {
if (getErrorCode(e.toString()) == 1050) {
throw SqlException(SqlExceptionEnum.TABLE_ALREADY_EXISTS,
cause: e.toString());
} else if (getErrorCode(e.toString()) == 1051) {
throw SqlException(SqlExceptionEnum.TABLE_NOT_FOUND,
cause: e.toString());
} else if (getErrorCode(e.toString()) == 1146) {
throw SqlException(SqlExceptionEnum.TABLE_NOT_FOUND,
cause: e.toString());
} else if (e
.toString()
.startsWith("Bad state: Cannot write to socket, it is closed")) {
throw SqlException(SqlExceptionEnum.SOCKET_CLOSED,
cause: e.toString());
} else {
print(e.toString());
throw SqlException(SqlExceptionEnum.SQL_SYNTAX_ERROR,
cause: e.toString());
}
}
}