aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormtvee <emptyvee@gmail.com>2009-05-15 04:38:33 +0000
committermtvee <emptyvee@gmail.com>2009-05-15 04:38:33 +0000
commitfa7f9811fbbbbee702acb1a5592f69fa7592f5c7 (patch)
treec75d20aeb6d8da8de49fcb5bb6278d77e981c907
parentc271a152b7856fa04de00ba74e221904ae2c0c4c (diff)
downloadsequelpro-fa7f9811fbbbbee702acb1a5592f69fa7592f5c7.tar.gz
sequelpro-fa7f9811fbbbbee702acb1a5592f69fa7592f5c7.tar.bz2
sequelpro-fa7f9811fbbbbee702acb1a5592f69fa7592f5c7.zip
fixed #254 and an unreported bug in the constraint parser
-rw-r--r--Source/SPStringAdditions.h3
-rw-r--r--Source/SPStringAdditions.m36
-rw-r--r--Source/SPTableData.m4
-rw-r--r--Source/TablesList.m19
4 files changed, 54 insertions, 8 deletions
diff --git a/Source/SPStringAdditions.h b/Source/SPStringAdditions.h
index 1b16dfd9..a422bdef 100644
--- a/Source/SPStringAdditions.h
+++ b/Source/SPStringAdditions.h
@@ -31,6 +31,9 @@
- (NSArray *)lineRangesForRange:(NSRange)aRange;
- (NSString *)createViewSyntaxPrettifier;
+- (NSString *) stringByRemovingCharactersInSet:(NSCharacterSet*) charSet options:(unsigned) mask;
+- (NSString *) stringByRemovingCharactersInSet:(NSCharacterSet*) charSet;
+
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
- (NSArray *)componentsSeparatedByCharactersInSet:(NSCharacterSet *)set;
#endif
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m
index fdad0cff..573c9c73 100644
--- a/Source/SPStringAdditions.m
+++ b/Source/SPStringAdditions.m
@@ -255,4 +255,40 @@
}
#endif
+
+- (NSString *) stringByRemovingCharactersInSet:(NSCharacterSet*) charSet options:(unsigned) mask
+{
+ NSRange range;
+ NSMutableString* newString = [NSMutableString string];
+ unsigned len = [self length];
+
+ mask &= ~NSBackwardsSearch;
+ range = NSMakeRange (0, len);
+
+ while (range.length)
+ {
+ NSRange substringRange;
+ unsigned pos = range.location;
+
+ range = [self rangeOfCharacterFromSet:charSet options:mask range:range];
+ if (range.location == NSNotFound)
+ range = NSMakeRange (len, 0);
+
+ substringRange = NSMakeRange (pos, range.location - pos);
+ [newString appendString:[self
+ substringWithRange:substringRange]];
+
+ range.location += range.length;
+ range.length = len - range.location;
+ }
+
+ return newString;
+}
+
+
+- (NSString *) stringByRemovingCharactersInSet:(NSCharacterSet*) charSet
+{
+ return [self stringByRemovingCharactersInSet:charSet options:0];
+}
+
@end
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index 57421d0e..6b40eb99 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -364,11 +364,11 @@
*/
[constraintDetails setObject:[[parts objectAtIndex:1] stringByTrimmingCharactersInSet:junk]
forKey:@"name"];
- [constraintDetails setObject:[[parts objectAtIndex:4] stringByTrimmingCharactersInSet:junk]
+ [constraintDetails setObject:[[parts objectAtIndex:4] stringByRemovingCharactersInSet:junk]
forKey:@"columns"];
[constraintDetails setObject:[[parts objectAtIndex:6] stringByTrimmingCharactersInSet:junk]
forKey:@"ref_table"];
- [constraintDetails setObject:[[parts objectAtIndex:7] stringByTrimmingCharactersInSet:junk]
+ [constraintDetails setObject:[[parts objectAtIndex:7] stringByRemovingCharactersInSet:junk]
forKey:@"ref_columns"];
int nextOffs = 12;
diff --git a/Source/TablesList.m b/Source/TablesList.m
index bd5a65e9..d8291598 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -521,11 +521,10 @@
while (currentIndex != NSNotFound)
{
- if([[tableTypes objectAtIndex:currentIndex] intValue] == SP_TABLETYPE_VIEW)
- {
+ if([[tableTypes objectAtIndex:currentIndex] intValue] == SP_TABLETYPE_VIEW) {
[mySQLConnection queryString: [NSString stringWithFormat: @"DROP VIEW %@",
- [[tables objectAtIndex:currentIndex] backtickQuotedString]
- ]];
+ [[tables objectAtIndex:currentIndex] backtickQuotedString]
+ ]];
} else if([[tableTypes objectAtIndex:currentIndex] intValue] == SP_TABLETYPE_TABLE) {
[mySQLConnection queryString: [NSString stringWithFormat: @"DROP TABLE %@",
[[tables objectAtIndex:currentIndex] backtickQuotedString]
@@ -563,9 +562,17 @@
// set window title
[tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", [tableDocumentInstance mySQLVersion],
[tableDocumentInstance name], [tableDocumentInstance database]]];
- if ( error )
+
+ if ( error ) {
+ /* the first sheet is not closed and we try and run this
NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
- [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove table.\nMySQL said: %@", @"message of panel when table cannot be removed"), errorText]);
+ [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove table.\nMySQL said: %@", @"message of panel when table cannot be removed"), errorText]);
+ */
+ NSRunAlertPanel(NSLocalizedString(@"Error", @"error"),
+ [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove table.\nMySQL said: %@", @"message of panel when table cannot be removed"), errorText],
+ NSLocalizedString(@"OK", @"OK button"), nil, nil, nil );
+ }
+
}
/**