aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTablesList.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2011-03-19 15:05:23 +0000
committerstuconnolly <stuart02@gmail.com>2011-03-19 15:05:23 +0000
commit6d3f21336846d7745e795202c99390832c4220c8 (patch)
tree6195dafeeb1871afc5e41f6f17a917dc8047d44a /Source/SPTablesList.m
parentb2a0af91eae18b6490ddeafd2708d256b0d53cb3 (diff)
downloadsequelpro-6d3f21336846d7745e795202c99390832c4220c8.tar.gz
sequelpro-6d3f21336846d7745e795202c99390832c4220c8.tar.bz2
sequelpro-6d3f21336846d7745e795202c99390832c4220c8.zip
Bring outline view branch up to date with trunk (r3235:r3245), which should resolve all warnings.
Diffstat (limited to 'Source/SPTablesList.m')
-rw-r--r--Source/SPTablesList.m128
1 files changed, 64 insertions, 64 deletions
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m
index 3d87fcc7..9c1a1d0c 100644
--- a/Source/SPTablesList.m
+++ b/Source/SPTablesList.m
@@ -48,8 +48,6 @@
- (void)addTable;
- (void)copyTable;
- (void)renameTableOfType:(SPTableType)tableType from:(NSString *)oldTableName to:(NSString *)newTableName;
-- (BOOL)isTableNameValid:(NSString *)tableName forType:(SPTableType)tableType;
-- (BOOL)isTableNameValid:(NSString *)tableName forType:(SPTableType)tableType ignoringSelectedTable:(BOOL)ignoreSelectedTable;
@end
@@ -1266,6 +1264,70 @@
}
#pragma mark -
+#pragma mark Data validation
+
+/**
+ * Check tableName for length and if the tableName doesn't match
+ * against current database table/view names (case-insensitive).
+ */
+- (BOOL)isTableNameValid:(NSString *)tableName forType:(SPTableType)tableType
+{
+ return [self isTableNameValid:tableName forType:tableType ignoringSelectedTable:NO];
+}
+
+/**
+ * Check tableName for length and if the tableName doesn't match
+ * against current database table/view names (case-insensitive).
+ */
+- (BOOL)isTableNameValid:(NSString *)tableName forType:(SPTableType)tableType ignoringSelectedTable:(BOOL)ignoreSelectedTable
+{
+ BOOL isValid = YES;
+
+ // delete trailing whitespaces since 'foo ' or ' ' are not valid table names
+ NSString *fieldStr = [tableName stringByMatching:@"(.*?)\\s*$" capture:1];
+ NSString *lowercaseFieldStr = [fieldStr lowercaseString];
+
+ // If table name has trailing whitespaces return 'no valid'
+ if([fieldStr length] != [tableName length]) return NO;
+
+ // empty table names are invalid
+ if([fieldStr length] == 0) return NO;
+
+
+ NSArray *similarTables;
+ switch (tableType) {
+ case SPTableTypeView:
+ case SPTableTypeTable:
+ similarTables = [self allTableAndViewNames];
+ break;
+ case SPTableTypeProc:
+ similarTables = [self allProcedureNames];
+ break;
+ case SPTableTypeFunc:
+ similarTables = [self allFunctionNames];
+ break;
+ default:
+ // if some other table type is given, just return yes
+ // better a mysql error than not being able to change something at all
+ return YES;
+ }
+
+ for(id table in similarTables) {
+ //compare case insensitive here
+ if([lowercaseFieldStr isEqualToString:[table lowercaseString]]) {
+ if (ignoreSelectedTable) {
+ // if table is the selectedTable, ignore it
+ // we must compare CASE SENSITIVE here!
+ if ([table isEqualToString:selectedTableName]) continue;
+ }
+ isValid = NO;
+ break;
+ }
+ }
+ return isValid;
+}
+
+#pragma mark -
#pragma mark Datasource methods
/**
@@ -2377,66 +2439,4 @@
[NSException raise:@"Object of unknown type" format:NSLocalizedString(@"An error occured while renaming. '%@' is of an unknown type.", @"rename error - don't know what type the renamed thing is"), oldTableName];
}
-
-/**
- * Check tableName for length and if the tableName doesn't match
- * against current database table/view names (case-insensitive).
- */
-- (BOOL)isTableNameValid:(NSString *)tableName forType:(SPTableType)tableType
-{
- return [self isTableNameValid:tableName forType:tableType ignoringSelectedTable:NO];
-}
-
-/**
- * Check tableName for length and if the tableName doesn't match
- * against current database table/view names (case-insensitive).
- */
-- (BOOL)isTableNameValid:(NSString *)tableName forType:(SPTableType)tableType ignoringSelectedTable:(BOOL)ignoreSelectedTable
-{
- BOOL isValid = YES;
-
- // delete trailing whitespaces since 'foo ' or ' ' are not valid table names
- NSString *fieldStr = [tableName stringByMatching:@"(.*?)\\s*$" capture:1];
- NSString *lowercaseFieldStr = [fieldStr lowercaseString];
-
- // If table name has trailing whitespaces return 'no valid'
- if([fieldStr length] != [tableName length]) return NO;
-
- // empty table names are invalid
- if([fieldStr length] == 0) return NO;
-
-
- NSArray *similarTables;
- switch (tableType) {
- case SPTableTypeView:
- case SPTableTypeTable:
- similarTables = [self allTableAndViewNames];
- break;
- case SPTableTypeProc:
- similarTables = [self allProcedureNames];
- break;
- case SPTableTypeFunc:
- similarTables = [self allFunctionNames];
- break;
- default:
- // if some other table type is given, just return yes
- // better a mysql error than not being able to change something at all
- return YES;
- }
-
- for(id table in similarTables) {
- //compare case insensitive here
- if([lowercaseFieldStr isEqualToString:[table lowercaseString]]) {
- if (ignoreSelectedTable) {
- // if table is the selectedTable, ignore it
- // we must compare CASE SENSITIVE here!
- if ([table isEqualToString:selectedTableName]) continue;
- }
- isValid = NO;
- break;
- }
- }
- return isValid;
-}
-
@end