Permalink
Browse files

Tidy up some parameter naming.

  • Loading branch information...
stuconnolly committed Oct 5, 2018
1 parent 623d40b commit bcb7fb637ca2a18e523c2c3af176fb3ce686e89b
Showing with 37 additions and 42 deletions.
  1. +4 −4 Source/SPCreateDatabaseInfo.h
  2. +3 −7 Source/SPDatabaseAction.h
  3. +4 −5 Source/SPDatabaseAction.m
  4. +12 −12 Source/SPTableCopy.h
  5. +14 −14 Source/SPTableCopy.m
@@ -1,5 +1,5 @@
//
// SPCreateDatabaseInfo.m
// SPCreateDatabaseInfo.h
// sequel-pro
//
// Created by David Rekowski on April 29, 2010.
@@ -35,8 +35,8 @@
NSString *defaultCollation;
}
@property (readwrite, retain) NSString *databaseName;
@property (readwrite, retain) NSString *defaultEncoding;
@property (readwrite, retain) NSString *defaultCollation;
@property (nonnull, readwrite, retain) NSString *databaseName;
@property (nullable, readwrite, retain) NSString *defaultEncoding;
@property (nullable, readwrite, retain) NSString *defaultCollation;
@end
View
@@ -42,17 +42,13 @@
/**
* @property connection References the SPMySQL.framework MySQL connection; it has to be set.
*/
@property (readwrite, assign) SPMySQLConnection *connection;
@property (nonnull, readwrite, assign) SPMySQLConnection *connection;
/**
* @property messageWindow The NSWindow instance to send message sheets to.
*/
@property (readwrite, assign) NSWindow *messageWindow;
/**
* @property tablesList
*/
@property (readwrite, assign) SPTablesList *tablesList;
@property (nonnull, readwrite, assign) SPTablesList *tablesList;
/**
* This method creates a new database.
@@ -63,7 +59,7 @@
*
* @see createDatabase:withEncoding:collation:
*/
- (BOOL)createDatabase:(SPCreateDatabaseInfo *)dbInfo;
- (BOOL)createDatabase:(SPCreateDatabaseInfo *)databaseInfo;
/**
* This method creates a new database.
@@ -38,14 +38,13 @@
@implementation SPDatabaseAction
@synthesize connection;
@synthesize messageWindow;
@synthesize tablesList;
- (BOOL)createDatabase:(SPCreateDatabaseInfo *)dbInfo
- (BOOL)createDatabase:(SPCreateDatabaseInfo *)databaseInfo
{
return [self createDatabase:[dbInfo databaseName]
withEncoding:[dbInfo defaultEncoding]
collation:[dbInfo defaultCollation]];
return [self createDatabase:[databaseInfo databaseName]
withEncoding:[databaseInfo defaultEncoding]
collation:[databaseInfo defaultCollation]];
}
- (BOOL)createDatabase:(NSString *)database withEncoding:(NSString *)encoding collation:(NSString *)collation
View
@@ -39,46 +39,46 @@
* This method copies a table structure from one db to another.
*
* @param name name of the table in the source database
* @param sourceDB name of the source database
* @param targetDB name of the target database
* @param sourceDatabase name of the source database
* @param targetDatabase name of the target database
*
* @return YES on success, NO on any kind of error (unspecified)
*/
- (BOOL)copyTable:(NSString *)name from:(NSString *)sourceDB to:(NSString *)targetDB;
- (BOOL)copyTable:(NSString *)name from:(NSString *)sourceDatabase to:(NSString *)targetDatabase;
/**
* This method moves a table from one db to another.
*
* @param name name of the table in the source database
* @param sourceDB name of the source database
* @param targetDB name of the target database
* @param sourceDatabase name of the source database
* @param targetDatabase name of the target database
*/
- (BOOL)moveTable:(NSString *)name from:(NSString *)sourceDB to:(NSString *)targetDB;
- (BOOL)moveTable:(NSString *)name from:(NSString *)sourceDatabase to:(NSString *)targetDatabase;
/**
* This method copies a table including its data from one db to another.
*
* @param name name of the table in the source database
* @param sourceDB name of the source database
* @param targetDB name of the target database
* @param sourceDatabase name of the source database
* @param targetDatabase name of the target database
* @param copyWithContent whether to copy the content too, otherwise only structure
*
* @return YES on success, NO on any kind of error (unspecified)
*/
- (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDB to: (NSString *)targetDB withContent:(BOOL)copyWithContent;
- (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDatabase to:(NSString *)targetDatabase withContent:(BOOL)copyWithContent;
/**
* This method copies a bunch of tables including their data from one db to another.
*
* @param tableArray array of NSStrings with the table names in the sourceDB
* @param sourceDB name of the source database
* @param targetDB name of the target database
* @param sourceDatabase name of the source database
* @param targetDatabase name of the target database
* @param copyWithContent whether to copy the content too, otherwise only structure
*
* @return YES on success, NO on any kind of error (unspecified)
*
* This method is able to copy InnoDB tables with foreign key constraints.
*/
- (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString *)targetDB withContent:(BOOL)copyWithContent;
- (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDatabase to:(NSString *)targetDatabase withContent:(BOOL)copyWithContent;
@end
View
@@ -34,23 +34,23 @@
@interface SPTableCopy ()
- (NSString *)_createTableStatementFor:(NSString *)tableName inDatabase:(NSString *)sourceDatabase;
- (NSString *)_createTableStatementFor:(NSString *)tableName inDatabase:(NSString *)sourceDatabase;
@end
@implementation SPTableCopy
- (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *)targetDB
- (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDatabase to:(NSString *)targetDatabase
{
NSString *createTableResult = [self _createTableStatementFor:tableName inDatabase:sourceDB];
NSString *createTableResult = [self _createTableStatementFor:tableName inDatabase:sourceDatabase];
if ([createTableResult hasPrefix:@"CREATE TABLE"]) {
NSMutableString *createTableStatement = [[NSMutableString alloc] initWithString:createTableResult];
// Add the target DB name and the separator dot after "CREATE TABLE ".
[createTableStatement insertString:@"." atIndex:13];
[createTableStatement insertString:[targetDB backtickQuotedString] atIndex:13];
[createTableStatement insertString:[targetDatabase backtickQuotedString] atIndex:13];
[connection queryString:createTableStatement];
@@ -62,18 +62,18 @@ - (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *
return NO;
}
- (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *)targetDB withContent:(BOOL)copyWithContent
- (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDatabase to:(NSString *)targetDatabase withContent:(BOOL)copyWithContent
{
// Copy the table structure
BOOL structureCopySuccess = [self copyTable:tableName from:sourceDB to:targetDB];
BOOL structureCopySuccess = [self copyTable:tableName from:sourceDatabase to:targetDatabase];
// Optionally copy the table data using an insert select
if (structureCopySuccess && copyWithContent) {
NSString *copyDataStatement = [NSString stringWithFormat:@"INSERT INTO %@.%@ SELECT * FROM %@.%@",
[targetDB backtickQuotedString],
[targetDatabase backtickQuotedString],
[tableName backtickQuotedString],
[sourceDB backtickQuotedString],
[sourceDatabase backtickQuotedString],
[tableName backtickQuotedString]
];
@@ -85,7 +85,7 @@ - (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *
return structureCopySuccess;
}
- (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString *)targetDB withContent:(BOOL)copyWithContent
- (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDatabase to:(NSString *)targetDatabase withContent:(BOOL)copyWithContent
{
BOOL success = YES;
@@ -105,7 +105,7 @@ - (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString
for (NSString *tableName in tablesArray)
{
if (![self copyTable:tableName from:sourceDB to:targetDB withContent:copyWithContent]) {
if (![self copyTable:tableName from:sourceDatabase to:targetDatabase withContent:copyWithContent]) {
success = NO;
}
}
@@ -127,12 +127,12 @@ - (BOOL)copyTables:(NSArray *)tablesArray from:(NSString *)sourceDB to:(NSString
return success;
}
- (BOOL)moveTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *)targetDB
- (BOOL)moveTable:(NSString *)tableName from:(NSString *)sourceDatabase to:(NSString *)targetDatabase
{
NSString *moveStatement = [NSString stringWithFormat:@"RENAME TABLE %@.%@ TO %@.%@",
[sourceDB backtickQuotedString],
[sourceDatabase backtickQuotedString],
[tableName backtickQuotedString],
[targetDB backtickQuotedString],
[targetDatabase backtickQuotedString],
[tableName backtickQuotedString]];
[connection queryString:moveStatement];
@@ -143,7 +143,7 @@ - (BOOL)moveTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *
#pragma mark -
#pragma mark Private API
- (NSString *)_createTableStatementFor:(NSString *)tableName inDatabase:(NSString *)sourceDatabase
- (NSString *)_createTableStatementFor:(NSString *)tableName inDatabase:(NSString *)sourceDatabase
{
NSString *showCreateTableStatment = [NSString stringWithFormat:@"SHOW CREATE TABLE %@.%@", [sourceDatabase backtickQuotedString], [tableName backtickQuotedString]];

0 comments on commit bcb7fb6

Please sign in to comment.