Permalink
Browse files

#2636: Fix display of indexes against geometry columns.

  • Loading branch information...
stuconnolly committed Oct 3, 2018
1 parent 3f24d5d commit 2710611d669c1654193fe3b444bb4d68ebfe4e2c
Showing with 17 additions and 49 deletions.
  1. +17 −49 Source/SPTableStructure.m
View
@@ -56,10 +56,12 @@
static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey";
@interface SPFieldTypeHelp ()
@property(copy,readwrite) NSString *typeName;
@property(copy,readwrite) NSString *typeDefinition;
@property(copy,readwrite) NSString *typeRange;
@property(copy,readwrite) NSString *typeDescription;
@end
@implementation SPFieldTypeHelp
@@ -505,17 +507,17 @@ - (IBAction)removeField:(id)sender
}
/**
*
* Resets the auto increment value of a table.
*/
- (IBAction)resetAutoIncrement:(id)sender
{
#ifndef SP_CODA
if ([sender tag] == 1) {
[resetAutoIncrementLine setHidden:YES];
if ([tableDocumentInstance currentlySelectedView] == SPTableViewStructure)
if ([tableDocumentInstance currentlySelectedView] == SPTableViewStructure){
[resetAutoIncrementLine setHidden:NO];
}
// Begin the sheet
[NSApp beginSheet:resetAutoIncrementSheet
@@ -529,31 +531,30 @@ - (IBAction)resetAutoIncrement:(id)sender
else if ([sender tag] == 2) {
[self setAutoIncrementTo:@1];
}
#endif
}
/**
* Process the autoincrement sheet closing, resetting if the user confirmed the action.
*/
- (void)resetAutoincrementSheetDidEnd:(NSWindow *)theSheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
#ifndef SP_CODA
// Order out current sheet to suppress overlapping of sheets
[theSheet orderOut:nil];
if (returnCode == NSAlertDefaultReturn) {
[self takeAutoIncrementFrom:resetAutoIncrementValue];
}
#endif
}
- (void)takeAutoIncrementFrom:(NSTextField *)field
{
id obj = [field objectValue];
//nil is handled by -setAutoIncrementTo:
if(obj && ![obj isKindOfClass:[NSNumber class]]) {
if (obj && ![obj isKindOfClass:[NSNumber class]]) {
[NSException raise:NSInternalInconsistencyException format:@"[$field objectValue] should return NSNumber *, but was %@",[obj class]];
}
[self setAutoIncrementTo:(NSNumber *)obj];
}
@@ -728,7 +729,6 @@ - (NSArray *)convertIndexResultToArray:(SPMySQLResult *)theResult
return tempResult;
}
/**
* A method to be called whenever the selection changes or the table would be reloaded
* or altered; checks whether the current row is being edited, and if so attempts to save
@@ -1062,40 +1062,6 @@ - (NSString *)_buildPartialColumnDefinitionString:(NSDictionary *)theRow
return queryString;
}
#ifdef SP_CODA /* glue */
- (void)setDatabaseDocument:(SPDatabaseDocument*)doc
{
tableDocumentInstance = doc;
}
- (void)setTableListInstance:(SPTablesList*)list
{
tablesListInstance = list;
}
- (void)setTableDataInstance:(SPTableData*)data
{
tableDataInstance = data;
}
- (void)setDatabaseDataInstance:(SPDatabaseData*)data
{
databaseDataInstance = data;
}
- (void)setTableSourceView:(SPTableView*)tv
{
tableSourceView = tv;
}
- (void)setEncodingPopupCell:(NSPopUpButtonCell*)cell
{
encodingPopupCell = cell;
}
#endif
/**
* A method to show an error sheet after a short delay, so that it can
* be called from within an endSheet selector. This should be called on
@@ -1555,23 +1521,25 @@ - (void)loadTable:(NSString *)aTable
}
// Process the indexes into a local array of dictionaries
NSArray *theTableIndexes = [self convertIndexResultToArray:indexResult];
NSArray *tableIndexes = [self convertIndexResultToArray:indexResult];
// Set the Key column
for (NSDictionary* theIndex in theTableIndexes)
for (NSDictionary *index in tableIndexes)
{
for (id field in theTableFields)
{
if ([[field objectForKey:@"name"] isEqualToString:[theIndex objectForKey:@"Column_name"]]) {
if ([[theIndex objectForKey:@"Key_name"] isEqualToString:@"PRIMARY"]) {
if ([[field objectForKey:@"name"] isEqualToString:[index objectForKey:@"Column_name"]]) {
if ([[index objectForKey:@"Key_name"] isEqualToString:@"PRIMARY"]) {
[field setObject:@"PRI" forKey:@"Key"];
}
else {
if ([[field objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) {
if ([[field objectForKey:@"typegrouping"] isEqualToString:@"geometry"] &&
[[index objectForKey:@"Index_type"] isEqualToString:@"SPATIAL"]
![field objectForKey:@"Key"]) {
[field setObject:@"SPA" forKey:@"Key"];
}
else {
[field setObject:(([[theIndex objectForKey:@"Non_unique"] isEqualToString:@"1"]) ? @"MUL" : @"UNI") forKey:@"Key"];
[field setObject:[[index objectForKey:@"Non_unique"] isEqualToString:@"1"] ? @"MUL" : @"UNI" forKey:@"Key"];
}
}
@@ -1716,7 +1684,7 @@ - (void)loadTable:(NSString *)aTable
NSDictionary *tableDetails = [NSDictionary dictionaryWithObjectsAndKeys:
aTable, @"name",
theTableFields, @"tableFields",
theTableIndexes, @"tableIndexes",
tableIndexes, @"tableIndexes",
theTableEnumLists, @"enumLists",
nil];

0 comments on commit 2710611

Please sign in to comment.