From a23bb9169015b21191bf072a7da6c668991907df Mon Sep 17 00:00:00 2001 From: jakob Date: Tue, 24 Mar 2009 18:43:58 +0000 Subject: - fixed issue #203 (backticks in identifiers not supported) - added a backtickQuotedString: method to SPStringAdditions - created the file SPArrayAdditions for a componentsJoinedAndBacktickQuoted: method In the future, we should use backtickQuotedString: to quote identifiers like this: [NSString stringWithFormat:@"SELECT * FROM %@", [tableName backtickQuotedString]] --- Source/SPStringAdditions.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Source/SPStringAdditions.m') diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m index ad6972ce..ef595dcc 100644 --- a/Source/SPStringAdditions.m +++ b/Source/SPStringAdditions.m @@ -111,6 +111,18 @@ } +// ------------------------------------------------------------------------------- +// backtickQuotedString +// +// Returns the string quoted with backticks as required for MySQL identifiers +// eg.: tablename => `tablename` +// my`table => `my``table` +// ------------------------------------------------------------------------------- +- (NSString *)backtickQuotedString +{ + return [NSString stringWithFormat: @"`%@`", [self stringByReplacingOccurrencesOfString: @"`" withString: @"``"] ]; +} + #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 // ------------------------------------------------------------------------------- // componentsSeparatedByCharactersInSet: -- cgit v1.2.3