aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableData.m
diff options
context:
space:
mode:
authorbamse16 <marius@marius.me.uk>2010-01-31 18:56:25 +0000
committerbamse16 <marius@marius.me.uk>2010-01-31 18:56:25 +0000
commit223dd9139ae61d9319ea5f719a1a08feb63bfeb4 (patch)
tree378bf3a8440de007df8b8c76d0847abe845fa848 /Source/SPTableData.m
parent890247960876e8dd987dd44ec98da4300b6a0fd3 (diff)
downloadsequelpro-223dd9139ae61d9319ea5f719a1a08feb63bfeb4.tar.gz
sequelpro-223dd9139ae61d9319ea5f719a1a08feb63bfeb4.tar.bz2
sequelpro-223dd9139ae61d9319ea5f719a1a08feb63bfeb4.zip
Added preliminary support for triggers. You can access the tab via the
menu item View > Table Triggers (apple-6). Heavily copied from Relations tab, lots of functionality missing. Just lists the triggers for the table now. M Source/SPTableData.m M Source/SPConstants.h M Source/SPConstants.m A Source/SPTableTriggers.h A Source/SPTableTriggers.m M Source/TableDocument.h M Source/TableDocument.m M Source/SPTableData.h M Interfaces/English.lproj/MainMenu.xib M Interfaces/English.lproj/DBView.xib M sequel-pro.xcodeproj/project.pbxproj
Diffstat (limited to 'Source/SPTableData.m')
-rw-r--r--Source/SPTableData.m33
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index a0a4d860..1c00758a 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -44,6 +44,7 @@
columnNames = [[NSMutableArray alloc] init];
constraints = [[NSMutableArray alloc] init];
status = [[NSMutableDictionary alloc] init];
+ triggers = [[NSMutableArray alloc] init];
tableEncoding = nil;
tableCreateSyntax = nil;
@@ -117,6 +118,11 @@
return constraints;
}
+- (NSArray *) triggers
+{
+ return (NSArray *)triggers;
+}
+
/*
* Retrieve a column with a specified name, using or refreshing the cache as appropriate.
*/
@@ -558,6 +564,31 @@
[createTableParser release];
[fieldParser release];
+
+ // Triggers
+ theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"/*!50003 SHOW TRIGGERS WHERE `Table` = %@ */;",
+ [tableName tickQuotedString]]];
+ [theResult setReturnDataAsStrings:YES];
+
+ // Check for any errors, but only display them if a connection still exists
+ if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection isConnected]) {
+ SPBeginAlertSheet(NSLocalizedString(@"Error retrieving table information", @"error retrieving table information message"), NSLocalizedString(@"OK", @"OK button"),
+ nil, nil, [NSApp mainWindow], self, nil, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving the information for table '%@'. Please try again.\n\nMySQL said: %@", @"error retrieving table information informative message"),
+ tableName, [mySQLConnection getLastErrorMessage]]);
+ }
+
+ return nil;
+ }
+
+ [triggers removeAllObjects];
+ if( [theResult numOfRows] ) {
+ for(int i=0; i<[theResult numOfRows]; i++){
+ [triggers addObject:[theResult fetchRowAsDictionary]];
+ }
+ }
+
tableData = [NSMutableDictionary dictionary];
// this will be 'Table' or 'View'
@@ -565,6 +596,7 @@
[tableData setObject:[NSString stringWithString:encodingString] forKey:@"encoding"];
[tableData setObject:[NSArray arrayWithArray:tableColumns] forKey:@"columns"];
[tableData setObject:[NSArray arrayWithArray:constraints] forKey:@"constraints"];
+ [tableData setObject:[NSArray arrayWithArray:triggers] forKey:@"triggers"];
[encodingString release];
[tableColumns release];
@@ -1030,6 +1062,7 @@
[columns release];
[columnNames release];
[constraints release];
+ [triggers release];
[status release];
if (tableEncoding) [tableEncoding release];