aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPCustomQuery.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-07-29 00:57:11 +0000
committerrowanbeentje <rowan@beent.je>2010-07-29 00:57:11 +0000
commit67bebbe2f9e6222c0a33be77c2d04495026f2437 (patch)
tree5ce673e3c9307a78686195d054f80205ac6c02a9 /Source/SPCustomQuery.m
parent550c112216171aa81487b32c41d7aa64adc2ec7f (diff)
downloadsequelpro-67bebbe2f9e6222c0a33be77c2d04495026f2437.tar.gz
sequelpro-67bebbe2f9e6222c0a33be77c2d04495026f2437.tar.bz2
sequelpro-67bebbe2f9e6222c0a33be77c2d04495026f2437.zip
- Add support for automatically converting \r and \r\n linebreaks in query syntax to \n. This addresses Issue #652.
- Clean up SPSQLParser, and use a few more CFString methods to avoid obj-c messaging in loops - When importing SQL using autodetect, perform a manual SET NAMES if possible to cope with poorly-exported files.
Diffstat (limited to 'Source/SPCustomQuery.m')
-rw-r--r--Source/SPCustomQuery.m28
1 files changed, 25 insertions, 3 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 520370d2..ec5f8347 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -72,11 +72,23 @@
queryParser = [[SPSQLParser alloc] initWithString:[textView string]];
[queryParser setDelimiterSupport:YES];
queries = [queryParser splitStringByCharacter:';'];
+
+ // If carriage returns were found, normalise the queries
+ if ([queryParser containsCarriageReturns]) {
+ NSMutableArray *normalisedQueries = [NSMutableArray arrayWithCapacity:[queries count]];
+ for (NSString *query in queries) {
+ [normalisedQueries addObject:[SPSQLParser normaliseQueryForExecution:query]];
+ }
+ queries = normalisedQueries;
+ }
+
[queryParser release];
oldThreadedQueryRange = [textView selectedRange];
- // Unselect a selection if given to avoid interferring with error highlighting
+
+ // Unselect a selection if given to avoid interfering with error highlighting
[textView setSelectedRange:NSMakeRange(oldThreadedQueryRange.location, 0)];
+
// Reset queryStartPosition
queryStartPosition = 0;
@@ -132,7 +144,7 @@
NSBeep();
return;
}
- queries = [NSArray arrayWithObject:query];
+ queries = [NSArray arrayWithObject:[SPSQLParser normaliseQueryForExecution:query]];
// Remember query start position for error highlighting
queryTextViewStartPosition = currentQueryRange.location;
@@ -142,6 +154,16 @@
queryParser = [[SPSQLParser alloc] initWithString:[[textView string] substringWithRange:selectedRange]];
[queryParser setDelimiterSupport:YES];
queries = [queryParser splitStringByCharacter:';'];
+
+ // If carriage returns were found, normalise the queries
+ if ([queryParser containsCarriageReturns]) {
+ NSMutableArray *normalisedQueries = [NSMutableArray arrayWithCapacity:[queries count]];
+ for (NSString *query in queries) {
+ [normalisedQueries addObject:[SPSQLParser normaliseQueryForExecution:query]];
+ }
+ queries = normalisedQueries;
+ }
+
[queryParser release];
// Remember query start position for error highlighting
@@ -551,7 +573,7 @@
if (i > 0) {
NSString *taskString = [NSString stringWithFormat:NSLocalizedString(@"Running query %ld of %lu...", @"Running multiple queries string"), (long)(i+1), (unsigned long)queryCount];
- [tableDocumentInstance setTaskDescription:taskString];
+ [[tableDocumentInstance onMainThread] setTaskDescription:taskString];
[[errorText onMainThread] setStringValue:taskString];
}