diff options
4 files changed, 58 insertions, 2 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 3d0ee5ab..c6bf48ea 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -34,8 +34,7 @@ #import "MCPConnectionProxy.h" #import "MCPConnectionDelegate.h" #import "MCPStringAdditions.h" -#import "SPStringAdditions.h" -#import "RegexKitLite.h" +#import "RegexKitLite.h" // TODO: Remove along with queryDbStructureWithUserInfo #import "NSNotificationAdditions.h" #include <unistd.h> diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.h b/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.h index 36693703..bf57b789 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.h @@ -40,4 +40,7 @@ static inline NSData *NSStringDataUsingLossyEncoding(NSString *self, NSInteger e @interface NSString (MCPStringAdditions) +- (NSString *)backtickQuotedString; +- (NSString *)tickQuotedString; + @end diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.m new file mode 100644 index 00000000..bd5b06cd --- /dev/null +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStringAdditions.m @@ -0,0 +1,50 @@ +// +// $Id$ +// +// MCPStringAdditions.m +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on March 25, 2010 +// Copyright (c) 2010 Stuart Connolly. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://code.google.com/p/sequel-pro/> + + + +@implementation NSString (MCPStringAdditions) + +/** + * 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:@"``"]]; +} + +/** + * Returns the string quoted with ticks as required for MySQL identifiers + * eg.: tablename => 'tablename' + * my'table => 'my''table' + */ +- (NSString *)tickQuotedString +{ + return [NSString stringWithFormat: @"'%@'", [self stringByReplacingOccurrencesOfString:@"'" withString:@"''"]]; +} + +@end diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index e0d063ed..921c59b3 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -201,6 +201,7 @@ 4DECC3370EC2A170008D359E /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DECC3340EC2A170008D359E /* Growl.framework */; }; 4DECC48F0EC2B436008D359E /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 4DECC3320EC2A170008D359E /* Sparkle.framework */; }; 4DECC4910EC2B436008D359E /* Growl.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 4DECC3340EC2A170008D359E /* Growl.framework */; }; + 580316CF13AE7BB300235317 /* MCPStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 580316CE13AE7BB300235317 /* MCPStringAdditions.m */; }; 5806B76411A991EC00813A88 /* SPDocumentController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5806B76311A991EC00813A88 /* SPDocumentController.m */; }; 580E8DB711EA774B000D8427 /* SequelProTabClose_Pressed.png in Resources */ = {isa = PBXBuildFile; fileRef = 580E8DAB11EA772C000D8427 /* SequelProTabClose_Pressed.png */; }; 580E8DB811EA774B000D8427 /* SequelProTabClose_Rollover.png in Resources */ = {isa = PBXBuildFile; fileRef = 580E8DAC11EA772C000D8427 /* SequelProTabClose_Rollover.png */; }; @@ -918,6 +919,7 @@ 4D90B7A1101E0D1500D116A1 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/UserManagerView.xib; sourceTree = "<group>"; }; 4DECC3320EC2A170008D359E /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = Frameworks/Sparkle.framework; sourceTree = "<group>"; }; 4DECC3340EC2A170008D359E /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Growl.framework; path = Frameworks/Growl.framework; sourceTree = "<group>"; }; + 580316CE13AE7BB300235317 /* MCPStringAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MCPStringAdditions.m; sourceTree = "<group>"; }; 5806B76211A991EC00813A88 /* SPDocumentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDocumentController.h; sourceTree = "<group>"; }; 5806B76311A991EC00813A88 /* SPDocumentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDocumentController.m; sourceTree = "<group>"; }; 580E8DAB11EA772C000D8427 /* SequelProTabClose_Pressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SequelProTabClose_Pressed.png; sourceTree = "<group>"; }; @@ -1742,6 +1744,7 @@ 583B779710386B0200B21F7E /* MCPStreamingResult.h */, 583B779810386B0200B21F7E /* MCPStreamingResult.m */, 17DCC5C5115C202700F89A00 /* MCPStringAdditions.h */, + 580316CE13AE7BB300235317 /* MCPStringAdditions.m */, BCE97AEC125DC4EC0091ED3C /* MCPGeometryData.h */, BCE97AED125DC4EC0091ED3C /* MCPGeometryData.m */, 17DC8E73126F4A8000E9AAEC /* Protocols */, @@ -3127,6 +3130,7 @@ 583B77D4103870C800B21F7E /* MCPStreamingResult.m in Sources */, 58587B5B11B4437C00D129ED /* NSNotificationAdditions.m in Sources */, BCE97AEF125DC4EC0091ED3C /* MCPGeometryData.m in Sources */, + 580316CF13AE7BB300235317 /* MCPStringAdditions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; |