aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-10-19 20:39:35 +0000
committerstuconnolly <stuart02@gmail.com>2010-10-19 20:39:35 +0000
commitee085902c3312eb623fbafaca2d59b3260385e72 (patch)
treea74203022e03efea229d10670f0f7b9f74a8f065 /Source
parent68e90d59bbb8660751e9fb74cd6553c4b32bcfa5 (diff)
downloadsequelpro-ee085902c3312eb623fbafaca2d59b3260385e72.tar.gz
sequelpro-ee085902c3312eb623fbafaca2d59b3260385e72.tar.bz2
sequelpro-ee085902c3312eb623fbafaca2d59b3260385e72.zip
Replace use of hardcoded strings with constants when working with trigger data.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTableTriggers.h11
-rw-r--r--Source/SPTableTriggers.m54
2 files changed, 44 insertions, 21 deletions
diff --git a/Source/SPTableTriggers.h b/Source/SPTableTriggers.h
index b7bd61fd..c6178310 100644
--- a/Source/SPTableTriggers.h
+++ b/Source/SPTableTriggers.h
@@ -25,6 +25,16 @@
#import <MCPKit/MCPKit.h>
+// Constants
+/*extern NSString *SPTriggerName;
+extern NSString *SPTriggerTableName;
+extern NSString *SPTriggerEvent;
+extern NSString *SPTriggerActionTime;
+extern NSString *SPTriggerStatement;
+extern NSString *SPTriggerDefiner;
+extern NSString *SPTriggerCreated;
+extern NSString *SPTriggerSQLMode;*/
+
@interface SPTableTriggers : NSObject
{
IBOutlet id tableDocumentInstance;
@@ -54,6 +64,7 @@
BOOL isEdit;
+ // Cache vars
NSString *editTriggerName;
NSString *editTriggerEvent;
NSString *editTriggerTableName;
diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m
index a934f450..329b0f8c 100644
--- a/Source/SPTableTriggers.m
+++ b/Source/SPTableTriggers.m
@@ -32,6 +32,16 @@
#import "SPAlertSheets.h"
#import "SPServerSupport.h"
+// Constants
+static const NSString *SPTriggerName = @"TriggerName";
+static const NSString *SPTriggerTableName = @"TriggerTableName";
+static const NSString *SPTriggerEvent = @"TriggerEvent";
+static const NSString *SPTriggerActionTime = @"TriggerActionTime";
+static const NSString *SPTriggerStatement = @"TriggerStatement";
+static const NSString *SPTriggerDefiner = @"TriggerDefiner";
+static const NSString *SPTriggerCreated = @"TriggerCreated";
+static const NSString *SPTriggerSQLMode = @"TriggerSQLMode";
+
@interface SPTableTriggers (PrivateAPI)
- (void)_editTriggerAtIndex:(NSInteger)index;
@@ -48,7 +58,7 @@
#pragma mark Initialization
/**
- * init
+ * Init
*/
- (id)init
{
@@ -493,13 +503,13 @@
{
NSMutableArray *temp = [[NSMutableArray alloc] init];
- [temp addObject:[trigger objectForKey:@"trigger"]];
- [temp addObject:[trigger objectForKey:@"event"]];
- [temp addObject:[trigger objectForKey:@"timing"]];
- [temp addObject:[trigger objectForKey:@"statement"]];
- [temp addObject:[trigger objectForKey:@"definer"]];
- [temp addObject:([trigger objectForKey:@"created"]) ? [trigger objectForKey:@"created"] : @""];
- [temp addObject:[trigger objectForKey:@"sql_mode"]];
+ [temp addObject:[trigger objectForKey:SPTriggerName]];
+ [temp addObject:[trigger objectForKey:SPTriggerEvent]];
+ [temp addObject:[trigger objectForKey:SPTriggerActionTime]];
+ [temp addObject:[trigger objectForKey:SPTriggerStatement]];
+ [temp addObject:[trigger objectForKey:SPTriggerDefiner]];
+ [temp addObject:([trigger objectForKey:SPTriggerCreated]) ? [trigger objectForKey:SPTriggerCreated] : @""];
+ [temp addObject:[trigger objectForKey:SPTriggerSQLMode]];
[data addObject:temp];
@@ -534,11 +544,11 @@
// Cache the original trigger's name and statement in the event that the editing process fails and
// we need to recreate it.
- editTriggerName = [trigger objectForKey:@"trigger"];
- editTriggerStatement = [trigger objectForKey:@"statement"];
- editTriggerTableName = [trigger objectForKey:@"table"];
- editTriggerEvent = [trigger objectForKey:@"event"];
- editTriggerActionTime = [trigger objectForKey:@"timing"];
+ editTriggerName = [trigger objectForKey:SPTriggerName];
+ editTriggerStatement = [trigger objectForKey:SPTriggerStatement];
+ editTriggerTableName = [trigger objectForKey:SPTriggerTableName];
+ editTriggerEvent = [trigger objectForKey:SPTriggerEvent];
+ editTriggerActionTime = [trigger objectForKey:SPTriggerActionTime];
[triggerNameTextField setStringValue:editTriggerName];
[triggerStatementTextView setString:editTriggerStatement];
@@ -584,6 +594,8 @@
/**
* Refresh the displayed trigger, optionally forcing a refresh of the underlying cache.
+ *
+ * @param classAllCaches Indicates whether all the caches should be refreshed
*/
- (void)_refreshTriggerDataForcingCacheRefresh:(BOOL)clearAllCaches
{
@@ -601,14 +613,14 @@
for (NSDictionary *trigger in triggers)
{
[triggerData addObject:[NSDictionary dictionaryWithObjectsAndKeys:
- [trigger objectForKey:@"Table"], @"table",
- [trigger objectForKey:@"Trigger"], @"trigger",
- [trigger objectForKey:@"Event"], @"event",
- [trigger objectForKey:@"Timing"], @"timing",
- [trigger objectForKey:@"Statement"], @"statement",
- [trigger objectForKey:@"Definer"], @"definer",
- [trigger objectForKey:@"Created"], @"created",
- [trigger objectForKey:@"sql_mode"], @"sql_mode",
+ [trigger objectForKey:@"Table"], SPTriggerTableName,
+ [trigger objectForKey:@"Trigger"], SPTriggerName,
+ [trigger objectForKey:@"Event"], SPTriggerEvent,
+ [trigger objectForKey:@"Timing"], SPTriggerActionTime,
+ [trigger objectForKey:@"Statement"], SPTriggerStatement,
+ [trigger objectForKey:@"Definer"], SPTriggerDefiner,
+ [trigger objectForKey:@"Created"], SPTriggerCreated,
+ [trigger objectForKey:@"sql_mode"], SPTriggerSQLMode,
nil]];
}