From 537a96297f236e2c41dd6d18ae317d2211a334a5 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 29 Mar 2012 23:55:09 +0000 Subject: - Fix SPMySQL warnings about delegate and proxy methods mixing synthesized getters and manually overridden setters - Fix autoincrement ID retrieval in SPMySQL, addressing issues previewing rows when the setting for "Reload Table After: Adding a row" is not being used --- .../Delegate & Proxy.h | 8 +++++++ .../Delegate & Proxy.m | 28 ++++++++++++++++++---- .../Querying & Preparation.m | 5 ++++ .../SPMySQLFramework/Source/SPMySQLConnection.h | 3 --- .../SPMySQLFramework/Source/SPMySQLConnection.m | 3 +-- 5 files changed, 37 insertions(+), 10 deletions(-) (limited to 'Frameworks/SPMySQLFramework/Source') diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.h index cf132fcf..9fa930c5 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.h @@ -33,4 +33,12 @@ @interface SPMySQLConnection (Delegate_and_Proxy) +// Connection delegage +- (void)setDelegate:(NSObject *)aDelegate; +- (NSObject *)delegate; + +// Connection proxy +- (void)setProxy:(NSObject *)aProxy; +- (NSObject *)proxy; + @end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m index 3ac013cc..59e78c35 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m @@ -39,8 +39,8 @@ #pragma mark Connection delegate /** - * Override the synthesized delegate setter, to allow optimisations to oft-made - * checks by precacheing availability. + * Set the delegate of the connection object, precaching availability of + * oft-called methods to allow optimisation. */ - (void)setDelegate:(NSObject *)aDelegate { @@ -51,12 +51,22 @@ delegateSupportsConnectionLost = [delegate respondsToSelector:@selector(connectionLost:)]; } +/** + * Return the current instance delegate. + */ +- (NSObject *)delegate +{ + return delegate; +} + #pragma mark - #pragma mark Connection proxy /** - * Override the synthesized proxy setter, to record the initial state and to - * set the state change selector. + * Set the connection proxy, used by the class to set up a connection pre-requisite, and + * monitored for state changes. This allows the MySQL connection to be routed over + * another helper class providing a port or socket. This method also records the initial + * state and sets the state change selector. */ - (void)setProxy:(NSObject *)aProxy { @@ -64,7 +74,15 @@ previousProxyState = [aProxy state]; [proxy setConnectionStateChangeSelector:@selector(_proxyStateChange:) delegate:self]; -} +} + +/** + * Return the current instance proxy. + */ +- (NSObject *)proxy +{ + return proxy; +} @end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m index 9b54029c..686be183 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m @@ -330,6 +330,11 @@ NSString *theErrorMessage = [self _stringForCString:mysql_error(mySQLConnection)]; NSUInteger theErrorID = mysql_errno(mySQLConnection); + // Update the connection's stored insert ID if available + if (mySQLConnection->insert_id) { + lastQueryInsertID = mySQLConnection->insert_id; + } + // If the query was cancelled, override the error state if (lastQueryWasCancelled) { theErrorMessage = NSLocalizedString(@"Query cancelled.", @"Query cancelled error"); diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h index 8f3b7f9f..8ed01ec6 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h @@ -131,9 +131,6 @@ #pragma mark - #pragma mark Synthesized properties -@property (readwrite, assign, nonatomic) NSObject *delegate; -@property (readwrite, assign, nonatomic) NSObject *proxy; - @property (readwrite, retain) NSString *host; @property (readwrite, retain) NSString *username; @property (readwrite, retain) NSString *password; diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m index 17acaf1b..800157ca 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m @@ -54,8 +54,6 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS #pragma mark - #pragma mark Synthesized properties -@synthesize delegate; -@synthesize proxy; @synthesize host; @synthesize username; @synthesize password; @@ -124,6 +122,7 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS previousEncodingUsesLatin1Transport = NO; // Initialise default delegate settings + delegate = nil; delegateSupportsWillQueryString = NO; delegateSupportsConnectionLost = NO; delegateQueryLogging = YES; -- cgit v1.2.3