aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableData.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-10-09 10:13:42 +0000
committerBibiko <bibiko@eva.mpg.de>2009-10-09 10:13:42 +0000
commit0e9df92aef86421374ca1756ff3cbfa4c386c822 (patch)
tree778ccf801f614de0da69c1d1e298c2783861b6d5 /Source/SPTableData.m
parent5759187115c2aaa2db5f528a02bee80ba0980c39 (diff)
downloadsequelpro-0e9df92aef86421374ca1756ff3cbfa4c386c822.tar.gz
sequelpro-0e9df92aef86421374ca1756ff3cbfa4c386c822.tar.bz2
sequelpro-0e9df92aef86421374ca1756ff3cbfa4c386c822.zip
• fixed bug while parsing the CREATE TABLE syntax if a column name contains a '#' or '/*'
- this fixes issue 431 - furthermore if the parsing process fails for some other reasons, i.e. a table name is NULL or empty SP alerts the user about it instead of stalling
Diffstat (limited to 'Source/SPTableData.m')
-rw-r--r--Source/SPTableData.m14
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index 66224529..ec02c301 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -380,11 +380,24 @@
quoteCharacter = [fieldsParser characterAtIndex:0];
// Capture the area between the two backticks as the name
+ // Set the parser to ignoreCommentStrings since a field name can contain # or /*
+ [fieldsParser setIgnoringCommentStrings:YES];
NSString *fieldName = [fieldsParser trimAndReturnStringFromCharacter: quoteCharacter
toCharacter: quoteCharacter
trimmingInclusively: YES
returningInclusively: NO
ignoringQuotedStrings: NO];
+ if(fieldName == nil || [fieldName length] == 0) {
+ NSBeep();
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button")];
+ [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"“%@” couldn't be parsed. You can edit the column setup but the column will not be shown in the Content view; please report this issue to the Sequel Pro team using the Help menu item.", @"“%@” couldn't be parsed. You can edit the column setup but the column will not be shown in the Content view; please report this issue to the Sequel Pro team using the Help menu item."), fieldsParser]];
+ [alert setMessageText:NSLocalizedString(@"Error while parsing CREATE TABLE syntax",@"error while parsing CREATE TABLE syntax")];
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ [alert runModal];
+ [alert release];
+ continue;
+ }
//if the next character is again a backtick, we stumbled across an escaped backtick. we have to continue parsing.
while ([fieldsParser characterAtIndex:0] == quoteCharacter) {
fieldName = [fieldName stringByAppendingFormat: @"`%@",
@@ -395,6 +408,7 @@
ignoringQuotedStrings: NO]
];
}
+ [fieldsParser setIgnoringCommentStrings:NO];
[tableColumn setObject:[NSNumber numberWithInt:[tableColumns count]] forKey:@"datacolumnindex"];
[tableColumn setObject:fieldName forKey:@"name"];