From e516badf6b875c27ce095c9987aaa4004b98844e Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 25 Mar 2012 19:36:35 +0000 Subject: QueryKit: add clear method so query instances can be reused. --- Frameworks/QueryKit/Source/QKQuery.h | 1 + Frameworks/QueryKit/Source/QKQuery.m | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Frameworks/QueryKit/Source/QKQuery.h b/Frameworks/QueryKit/Source/QKQuery.h index 2132a158..c0f925bb 100644 --- a/Frameworks/QueryKit/Source/QKQuery.h +++ b/Frameworks/QueryKit/Source/QKQuery.h @@ -100,6 +100,7 @@ - (id)initWithTable:(NSString *)table; - (NSString *)query; +- (void)clear; - (void)addField:(NSString *)field; - (void)addFields:(NSArray *)fields; diff --git a/Frameworks/QueryKit/Source/QKQuery.m b/Frameworks/QueryKit/Source/QKQuery.m index d26b9f72..4be29ae2 100644 --- a/Frameworks/QueryKit/Source/QKQuery.m +++ b/Frameworks/QueryKit/Source/QKQuery.m @@ -100,11 +100,32 @@ static NSString *QKNoQueryTableException = @"QKNoQueryTable"; #pragma mark - #pragma mark Public API +/** + * Requests that the query be built. + * + * @return The generated query. + */ - (NSString *)query { return _query ? [self _buildQuery] : @""; } +/** + * Clears anything this instance should know about the query it's building. + */ +- (void)clear +{ + [self setTable:nil]; + [self setDatabase:nil]; + [self setQueryType:(QKQueryType)-1]; + + [_fields removeAllObjects]; + [_parameters removeAllObjects]; + [_updateParameters removeAllObjects]; + [_groupByFields removeAllObjects]; + [_orderByFields removeAllObjects]; +} + #pragma mark - #pragma mark Fields -- cgit v1.2.3