56
56
static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey";
57
57
58
58
@interface SPFieldTypeHelp ()
59
+
59
60
@property(copy,readwrite) NSString *typeName;
60
61
@property(copy,readwrite) NSString *typeDefinition;
61
62
@property(copy,readwrite) NSString *typeRange;
62
63
@property(copy,readwrite) NSString *typeDescription;
64
+
63
65
@end
64
66
65
67
@implementation SPFieldTypeHelp
@@ -505,17 +507,17 @@ - (IBAction)removeField:(id)sender
505
507
}
506
508
507
509
/**
508
- *
510
+ * Resets the auto increment value of a table.
509
511
*/
510
512
- (IBAction)resetAutoIncrement:(id)sender
511
513
{
512
- #ifndef SP_CODA
513
514
if ([sender tag] == 1) {
514
515
515
516
[resetAutoIncrementLine setHidden:YES];
516
517
517
- if ([tableDocumentInstance currentlySelectedView] == SPTableViewStructure)
518
+ if ([tableDocumentInstance currentlySelectedView] == SPTableViewStructure){
518
519
[resetAutoIncrementLine setHidden:NO];
520
+ }
519
521
520
522
// Begin the sheet
521
523
[NSApp beginSheet:resetAutoIncrementSheet
@@ -529,31 +531,30 @@ - (IBAction)resetAutoIncrement:(id)sender
529
531
else if ([sender tag] == 2) {
530
532
[self setAutoIncrementTo:@1];
531
533
}
532
- #endif
533
534
}
534
535
535
536
/**
536
537
* Process the autoincrement sheet closing, resetting if the user confirmed the action.
537
538
*/
538
539
- (void)resetAutoincrementSheetDidEnd:(NSWindow *)theSheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
539
540
{
540
- #ifndef SP_CODA
541
541
// Order out current sheet to suppress overlapping of sheets
542
542
[theSheet orderOut:nil];
543
543
544
544
if (returnCode == NSAlertDefaultReturn) {
545
545
[self takeAutoIncrementFrom:resetAutoIncrementValue];
546
546
}
547
- #endif
548
547
}
549
548
550
549
- (void)takeAutoIncrementFrom:(NSTextField *)field
551
550
{
552
551
id obj = [field objectValue];
552
+
553
553
//nil is handled by -setAutoIncrementTo:
554
- if(obj && ![obj isKindOfClass:[NSNumber class]]) {
554
+ if (obj && ![obj isKindOfClass:[NSNumber class]]) {
555
555
[NSException raise:NSInternalInconsistencyException format:@"[$field objectValue] should return NSNumber *, but was %@",[obj class]];
556
556
}
557
+
557
558
[self setAutoIncrementTo:(NSNumber *)obj];
558
559
}
559
560
@@ -728,7 +729,6 @@ - (NSArray *)convertIndexResultToArray:(SPMySQLResult *)theResult
728
729
return tempResult;
729
730
}
730
731
731
-
732
732
/**
733
733
* A method to be called whenever the selection changes or the table would be reloaded
734
734
* or altered; checks whether the current row is being edited, and if so attempts to save
@@ -1062,40 +1062,6 @@ - (NSString *)_buildPartialColumnDefinitionString:(NSDictionary *)theRow
1062
1062
return queryString;
1063
1063
}
1064
1064
1065
- #ifdef SP_CODA /* glue */
1066
-
1067
- - (void)setDatabaseDocument:(SPDatabaseDocument*)doc
1068
- {
1069
- tableDocumentInstance = doc;
1070
- }
1071
-
1072
- - (void)setTableListInstance:(SPTablesList*)list
1073
- {
1074
- tablesListInstance = list;
1075
- }
1076
-
1077
- - (void)setTableDataInstance:(SPTableData*)data
1078
- {
1079
- tableDataInstance = data;
1080
- }
1081
-
1082
- - (void)setDatabaseDataInstance:(SPDatabaseData*)data
1083
- {
1084
- databaseDataInstance = data;
1085
- }
1086
-
1087
- - (void)setTableSourceView:(SPTableView*)tv
1088
- {
1089
- tableSourceView = tv;
1090
- }
1091
-
1092
- - (void)setEncodingPopupCell:(NSPopUpButtonCell*)cell
1093
- {
1094
- encodingPopupCell = cell;
1095
- }
1096
-
1097
- #endif
1098
-
1099
1065
/**
1100
1066
* A method to show an error sheet after a short delay, so that it can
1101
1067
* be called from within an endSheet selector. This should be called on
@@ -1555,23 +1521,25 @@ - (void)loadTable:(NSString *)aTable
1555
1521
}
1556
1522
1557
1523
// Process the indexes into a local array of dictionaries
1558
- NSArray *theTableIndexes = [self convertIndexResultToArray:indexResult];
1524
+ NSArray *tableIndexes = [self convertIndexResultToArray:indexResult];
1559
1525
1560
1526
// Set the Key column
1561
- for (NSDictionary* theIndex in theTableIndexes )
1527
+ for (NSDictionary *index in tableIndexes )
1562
1528
{
1563
1529
for (id field in theTableFields)
1564
1530
{
1565
- if ([[field objectForKey:@"name"] isEqualToString:[theIndex objectForKey:@"Column_name"]]) {
1566
- if ([[theIndex objectForKey:@"Key_name"] isEqualToString:@"PRIMARY"]) {
1531
+ if ([[field objectForKey:@"name"] isEqualToString:[index objectForKey:@"Column_name"]]) {
1532
+ if ([[index objectForKey:@"Key_name"] isEqualToString:@"PRIMARY"]) {
1567
1533
[field setObject:@"PRI" forKey:@"Key"];
1568
1534
}
1569
1535
else {
1570
- if ([[field objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) {
1536
+ if ([[field objectForKey:@"typegrouping"] isEqualToString:@"geometry"] &&
1537
+ [[index objectForKey:@"Index_type"] isEqualToString:@"SPATIAL"]
1538
+ ![field objectForKey:@"Key"]) {
1571
1539
[field setObject:@"SPA" forKey:@"Key"];
1572
1540
}
1573
1541
else {
1574
- [field setObject:(([[theIndex objectForKey:@"Non_unique"] isEqualToString:@"1"]) ? @"MUL" : @"UNI") forKey:@"Key"];
1542
+ [field setObject:[[index objectForKey:@"Non_unique"] isEqualToString:@"1"] ? @"MUL" : @"UNI" forKey:@"Key"];
1575
1543
}
1576
1544
}
1577
1545
@@ -1716,7 +1684,7 @@ - (void)loadTable:(NSString *)aTable
1716
1684
NSDictionary *tableDetails = [NSDictionary dictionaryWithObjectsAndKeys:
1717
1685
aTable, @"name",
1718
1686
theTableFields, @"tableFields",
1719
- theTableIndexes , @"tableIndexes",
1687
+ tableIndexes , @"tableIndexes",
1720
1688
theTableEnumLists, @"enumLists",
1721
1689
nil];
1722
1690
0 commit comments