aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-09-09 13:48:26 +0000
committerBibiko <bibiko@eva.mpg.de>2010-09-09 13:48:26 +0000
commit0e7ab97ce059e054886288401100586e59188ad3 (patch)
treec8c99fba4787fb5f44e91bc2a053a9defa6253ba
parentcc99469638a22d68a01650bf36adc3b99ae817d1 (diff)
downloadsequelpro-0e7ab97ce059e054886288401100586e59188ad3.tar.gz
sequelpro-0e7ab97ce059e054886288401100586e59188ad3.tar.bz2
sequelpro-0e7ab97ce059e054886288401100586e59188ad3.zip
• TableStructure
- changed: field information are retrieved via [SPTableData columns]; mainly to get all infos like comment, encoding, and collation - added the chance to edit encoding, collation, and comment for each field Note: This is work is progress - not yet optimized but fully workable. Due to GUI I simply added these three columns - improvements will follow
-rw-r--r--Interfaces/English.lproj/DBView.xib318
-rw-r--r--Source/SPIndexesController.m206
-rw-r--r--Source/SPTableStructure.h5
-rw-r--r--Source/SPTableStructure.m719
4 files changed, 733 insertions, 515 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib
index 2e29a3a4..6cf1da3c 100644
--- a/Interfaces/English.lproj/DBView.xib
+++ b/Interfaces/English.lproj/DBView.xib
@@ -23,9 +23,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="6225"/>
- <integer value="7168"/>
- <integer value="7467"/>
+ <integer value="673"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -947,7 +945,7 @@
<object class="NSTabViewItem" id="831053945">
<string key="NSIdentifier">source</string>
<object class="NSView" key="NSView" id="461236772">
- <nil key="NSNextResponder"/>
+ <reference key="NSNextResponder" ref="714795046"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1017,9 +1015,9 @@
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="214236344">
- <string key="NSIdentifier">Field</string>
- <double key="NSWidth">99</double>
- <double key="NSMinWidth">40</double>
+ <string key="NSIdentifier">name</string>
+ <double key="NSWidth">60</double>
+ <double key="NSMinWidth">50</double>
<double key="NSMaxWidth">1000</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
@@ -1044,9 +1042,9 @@
<reference key="NSTableView" ref="715508012"/>
</object>
<object class="NSTableColumn" id="45498659">
- <string key="NSIdentifier">Type</string>
+ <string key="NSIdentifier">type</string>
<double key="NSWidth">65</double>
- <double key="NSMinWidth">10</double>
+ <double key="NSMinWidth">65</double>
<double key="NSMaxWidth">1000</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
@@ -1166,9 +1164,9 @@
<reference key="NSTableView" ref="715508012"/>
</object>
<object class="NSTableColumn" id="212523940">
- <string key="NSIdentifier">Length</string>
- <double key="NSWidth">74</double>
- <double key="NSMinWidth">10</double>
+ <string key="NSIdentifier">length</string>
+ <double key="NSWidth">43</double>
+ <double key="NSMinWidth">25</double>
<double key="NSMaxWidth">1000</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
@@ -1194,9 +1192,9 @@
</object>
<object class="NSTableColumn" id="230280632">
<string key="NSIdentifier">unsigned</string>
- <double key="NSWidth">55</double>
- <double key="NSMinWidth">10</double>
- <double key="NSMaxWidth">1000</double>
+ <double key="NSWidth">54</double>
+ <double key="NSMinWidth">14</double>
+ <double key="NSMaxWidth">54</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">2048</int>
@@ -1211,7 +1209,7 @@
<string key="NSContents"/>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="715508012"/>
- <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags">1215582719</int>
<int key="NSButtonFlags2">2</int>
<object class="NSCustomResource" key="NSNormalImage" id="653588312">
<string key="NSClassName">NSImage</string>
@@ -1232,9 +1230,9 @@
</object>
<object class="NSTableColumn" id="554037403">
<string key="NSIdentifier">zerofill</string>
- <double key="NSWidth">55</double>
- <double key="NSMinWidth">10</double>
- <double key="NSMaxWidth">1000</double>
+ <double key="NSWidth">41</double>
+ <double key="NSMinWidth">14</double>
+ <double key="NSMaxWidth">41</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">2048</int>
@@ -1249,7 +1247,7 @@
<string key="NSContents"/>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="715508012"/>
- <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags">1215582719</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="653588312"/>
<reference key="NSAlternateImage" ref="386686735"/>
@@ -1265,9 +1263,9 @@
</object>
<object class="NSTableColumn" id="962294682">
<string key="NSIdentifier">binary</string>
- <double key="NSWidth">55</double>
- <double key="NSMinWidth">10</double>
- <double key="NSMaxWidth">1000</double>
+ <double key="NSWidth">37</double>
+ <double key="NSMinWidth">14</double>
+ <double key="NSMaxWidth">37</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">2048</int>
@@ -1282,7 +1280,7 @@
<string key="NSContents"/>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="715508012"/>
- <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags">1215582719</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="653588312"/>
<reference key="NSAlternateImage" ref="386686735"/>
@@ -1297,10 +1295,10 @@
<reference key="NSTableView" ref="715508012"/>
</object>
<object class="NSTableColumn" id="881882727">
- <string key="NSIdentifier">Null</string>
- <double key="NSWidth">60</double>
- <double key="NSMinWidth">10</double>
- <double key="NSMaxWidth">1000</double>
+ <string key="NSIdentifier">null</string>
+ <double key="NSWidth">57</double>
+ <double key="NSMinWidth">14</double>
+ <double key="NSMaxWidth">57</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">2048</int>
@@ -1315,7 +1313,7 @@
<string key="NSContents"/>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="715508012"/>
- <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags">1215582719</int>
<int key="NSButtonFlags2">2</int>
<reference key="NSNormalImage" ref="653588312"/>
<reference key="NSAlternateImage" ref="386686735"/>
@@ -1331,9 +1329,9 @@
</object>
<object class="NSTableColumn" id="981319728">
<string key="NSIdentifier">Key</string>
- <double key="NSWidth">55</double>
- <double key="NSMinWidth">10</double>
- <double key="NSMaxWidth">1000</double>
+ <double key="NSWidth">26</double>
+ <double key="NSMinWidth">26</double>
+ <double key="NSMaxWidth">26</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
<int key="NSCellFlags2">2048</int>
@@ -1356,9 +1354,9 @@
<reference key="NSTableView" ref="715508012"/>
</object>
<object class="NSTableColumn" id="788521496">
- <string key="NSIdentifier">Default</string>
- <double key="NSWidth">68</double>
- <double key="NSMinWidth">10</double>
+ <string key="NSIdentifier">default</string>
+ <double key="NSWidth">45</double>
+ <double key="NSMinWidth">34</double>
<double key="NSMaxWidth">1000</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
@@ -1384,8 +1382,8 @@
</object>
<object class="NSTableColumn" id="128488500">
<string key="NSIdentifier">Extra</string>
- <double key="NSWidth">78.39794921875</double>
- <double key="NSMinWidth">31.39794921875</double>
+ <double key="NSWidth">60</double>
+ <double key="NSMinWidth">60</double>
<double key="NSMaxWidth">1000</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">
<int key="NSCellFlags">75628096</int>
@@ -1471,6 +1469,121 @@
<bool key="NSIsEditable">YES</bool>
<reference key="NSTableView" ref="715508012"/>
</object>
+ <object class="NSTableColumn" id="325583102">
+ <string key="NSIdentifier">encoding</string>
+ <double key="NSWidth">57</double>
+ <double key="NSMinWidth">10</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Encoding</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSBackgroundColor" ref="299403355"/>
+ <reference key="NSTextColor" ref="222976159"/>
+ </object>
+ <object class="NSPopUpButtonCell" key="NSDataCell" id="309064650">
+ <int key="NSCellFlags">-2076049856</int>
+ <int key="NSCellFlags2">133120</int>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="715508012"/>
+ <int key="NSButtonFlags">100679935</int>
+ <int key="NSButtonFlags2">129</int>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ <nil key="NSMenuItem"/>
+ <bool key="NSMenuItemRespectAlignment">YES</bool>
+ <object class="NSMenu" key="NSMenu" id="326438402">
+ <string key="NSTitle">OtherViews</string>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="NSMenuFont" ref="26"/>
+ </object>
+ <int key="NSSelectedIndex">-1</int>
+ <int key="NSPreferredEdge">3</int>
+ <bool key="NSUsesItemFromMenu">YES</bool>
+ <bool key="NSAltersState">YES</bool>
+ <int key="NSArrowPosition">1</int>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="715508012"/>
+ </object>
+ <object class="NSTableColumn" id="90106305">
+ <string key="NSIdentifier">collation</string>
+ <double key="NSWidth">62</double>
+ <double key="NSMinWidth">10</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Collation</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSBackgroundColor" ref="299403355"/>
+ <reference key="NSTextColor" ref="222976159"/>
+ </object>
+ <object class="NSPopUpButtonCell" key="NSDataCell" id="127254249">
+ <int key="NSCellFlags">-2076049856</int>
+ <int key="NSCellFlags2">133120</int>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="715508012"/>
+ <int key="NSButtonFlags">100679935</int>
+ <int key="NSButtonFlags2">129</int>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ <nil key="NSMenuItem"/>
+ <bool key="NSMenuItemRespectAlignment">YES</bool>
+ <object class="NSMenu" key="NSMenu" id="39043069">
+ <string key="NSTitle">OtherViews</string>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="NSMenuFont" ref="26"/>
+ </object>
+ <int key="NSSelectedIndex">-1</int>
+ <int key="NSPreferredEdge">3</int>
+ <bool key="NSUsesItemFromMenu">YES</bool>
+ <bool key="NSAltersState">YES</bool>
+ <int key="NSArrowPosition">1</int>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="715508012"/>
+ </object>
+ <object class="NSTableColumn" id="977579039">
+ <string key="NSIdentifier">comment</string>
+ <double key="NSWidth">44</double>
+ <double key="NSMinWidth">10</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Comment</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSBackgroundColor" ref="299403355"/>
+ <reference key="NSTextColor" ref="222976159"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="922217819">
+ <int key="NSCellFlags">337772096</int>
+ <int key="NSCellFlags2">133120</int>
+ <string key="NSContents">Text Cell</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="715508012"/>
+ <reference key="NSBackgroundColor" ref="1024678221"/>
+ <reference key="NSTextColor" ref="454249633"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="715508012"/>
+ </object>
</object>
<double key="NSIntercellSpacingWidth">3</double>
<double key="NSIntercellSpacingHeight">2</double>
@@ -1501,17 +1614,18 @@
<reference key="NSSuperview" ref="22340145"/>
<reference key="NSTarget" ref="22340145"/>
<string key="NSAction">_doScroller:</string>
- <double key="NSPercent">0.98586571216583252</double>
+ <double key="NSPercent">0.9480968713760376</double>
</object>
<object class="NSScroller" id="456666876">
<reference key="NSNextResponder" ref="22340145"/>
<int key="NSvFlags">-2147483392</int>
- <string key="NSFrame">{{1, 291}, {673, 15}}</string>
+ <string key="NSFrame">{{1, 291}, {694, 15}}</string>
<reference key="NSSuperview" ref="22340145"/>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="22340145"/>
<string key="NSAction">_doScroller:</string>
- <double key="NSPercent">0.99854862689971924</double>
+ <double key="NSCurValue">1</double>
+ <double key="NSPercent">0.99856114387512207</double>
</object>
<object class="NSClipView" id="639957061">
<reference key="NSNextResponder" ref="22340145"/>
@@ -2233,6 +2347,7 @@
</object>
</object>
<string key="NSFrame">{{10, 7}, {706, 544}}</string>
+ <reference key="NSSuperview" ref="714795046"/>
</object>
<string key="NSLabel">Structure</string>
<reference key="NSColor" ref="62854682"/>
@@ -2989,7 +3104,7 @@
<object class="NSTabViewItem" id="105987292">
<string key="NSIdentifier">customQuery</string>
<object class="NSView" key="NSView" id="746504912">
- <reference key="NSNextResponder" ref="714795046"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -3180,29 +3295,6 @@
<object class="NSTextView" id="793890647">
<reference key="NSNextResponder" ref="888807510"/>
<int key="NSvFlags">6418</int>
- <object class="NSMutableSet" key="NSDragTypes">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="set.sortedObjects">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>Apple HTML pasteboard type</string>
- <string>Apple PDF pasteboard type</string>
- <string>Apple PICT pasteboard type</string>
- <string>Apple PNG pasteboard type</string>
- <string>Apple URL pasteboard type</string>
- <string>CorePasteboardFlavorType 0x6D6F6F76</string>
- <string>NSColor pasteboard type</string>
- <string>NSFilenamesPboardType</string>
- <string>NSStringPboardType</string>
- <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
- <string>NeXT RTFD pasteboard type</string>
- <string>NeXT Rich Text Format v1.0 pasteboard type</string>
- <string>NeXT TIFF v4.0 pasteboard type</string>
- <string>NeXT font pasteboard type</string>
- <string>NeXT ruler pasteboard type</string>
- <string>WebURLsWithTitlesPboardType</string>
- <string>public.url</string>
- </object>
- </object>
<string key="NSFrame">{{0, 2}, {694, 14}}</string>
<reference key="NSSuperview" ref="888807510"/>
<object class="NSTextContainer" key="NSTextContainer" id="845974686">
@@ -4188,7 +4280,6 @@
</object>
</object>
<string key="NSFrame">{{10, 7}, {706, 544}}</string>
- <reference key="NSSuperview" ref="714795046"/>
</object>
<string key="NSLabel">Custom Query</string>
<reference key="NSColor" ref="62854682"/>
@@ -5978,14 +6069,14 @@
<reference key="NSTabView" ref="714795046"/>
</object>
</object>
- <reference key="NSSelectedTabViewItem" ref="105987292"/>
+ <reference key="NSSelectedTabViewItem" ref="831053945"/>
<reference key="NSFont" ref="26"/>
<int key="NSTvFlags">134217731</int>
<bool key="NSAllowTruncatedLabels">YES</bool>
<bool key="NSDrawsBackground">YES</bool>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="746504912"/>
+ <reference ref="461236772"/>
</object>
</object>
</object>
@@ -18581,6 +18672,9 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<reference ref="881882727"/>
<reference ref="45498659"/>
<reference ref="214236344"/>
+ <reference ref="325583102"/>
+ <reference ref="90106305"/>
+ <reference ref="977579039"/>
</object>
<reference key="parent" ref="22340145"/>
</object>
@@ -20603,6 +20697,72 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<reference key="object" ref="726011785"/>
<reference key="parent" ref="527545451"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7484</int>
+ <reference key="object" ref="325583102"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="309064650"/>
+ </object>
+ <reference key="parent" ref="715508012"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7486</int>
+ <reference key="object" ref="90106305"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="127254249"/>
+ </object>
+ <reference key="parent" ref="715508012"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7488</int>
+ <reference key="object" ref="977579039"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="922217819"/>
+ </object>
+ <reference key="parent" ref="715508012"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7489</int>
+ <reference key="object" ref="922217819"/>
+ <reference key="parent" ref="977579039"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7490</int>
+ <reference key="object" ref="309064650"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="326438402"/>
+ </object>
+ <reference key="parent" ref="325583102"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7491</int>
+ <reference key="object" ref="326438402"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="parent" ref="309064650"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7493</int>
+ <reference key="object" ref="127254249"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="39043069"/>
+ </object>
+ <reference key="parent" ref="90106305"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7494</int>
+ <reference key="object" ref="39043069"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="parent" ref="127254249"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -21802,8 +21962,18 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>7473.IBPluginDependency</string>
<string>748.IBPluginDependency</string>
<string>748.ImportedFromIB2</string>
+ <string>7484.IBPluginDependency</string>
+ <string>7486.IBPluginDependency</string>
+ <string>7488.IBPluginDependency</string>
+ <string>7489.IBPluginDependency</string>
<string>749.IBPluginDependency</string>
<string>749.ImportedFromIB2</string>
+ <string>7490.IBPluginDependency</string>
+ <string>7491.IBEditorWindowLastContentRect</string>
+ <string>7491.IBPluginDependency</string>
+ <string>7493.IBPluginDependency</string>
+ <string>7494.IBEditorWindowLastContentRect</string>
+ <string>7494.IBPluginDependency</string>
<string>858.IBPluginDependency</string>
<string>858.ImportedFromIB2</string>
<string>959.IBEditorWindowLastContentRect</string>
@@ -23136,7 +23306,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{0, 249}, {943, 549}}</string>
+ <string>{{125, 253}, {943, 549}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -23438,8 +23608,18 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{339, 775}, {694, 4}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{339, 775}, {694, 4}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{265, 489}, {405, 267}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -23477,7 +23657,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">7483</int>
+ <int key="maxID">7495</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m
index d7a509bd..fdd5b886 100644
--- a/Source/SPIndexesController.m
+++ b/Source/SPIndexesController.m
@@ -47,15 +47,15 @@
- (id)init
{
if ((self = [super initWithWindowNibName:@"IndexesView"])) {
-
+
table = @"";
-
+
fields = [[NSMutableArray alloc] init];
indexes = [[NSMutableArray alloc] init];
-
+
prefs = [NSUserDefaults standardUserDefaults];
}
-
+
return self;
}
@@ -63,18 +63,18 @@
* Nib awakening.
*/
- (void)awakeFromNib
-{
+{
// Set the index tables view's vertical gridlines if required
[indexesTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
-
+
// Set the strutcture and index view's font
BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts];
-
+
for (NSTableColumn *indexColumn in [indexesTableView tableColumns])
{
[[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
}
-
+
[prefs addObserver:self forKeyPath:SPDisplayTableViewVerticalGridlines options:NSKeyValueObservingOptionNew context:NULL];
}
@@ -85,50 +85,50 @@
* Opens the add new index sheet.
*/
- (IBAction)addIndex:(id)sender
-{
+{
// Check whether a save of the current field row is required.
if (![tableStructure saveRowOnDeselect]) return;
-
+
// Set sheet defaults - key type PRIMARY, key name PRIMARY and disabled
[indexTypePopUpButton selectItemAtIndex:0];
[indexNameTextField setEnabled:NO];
[indexNameTextField setStringValue:@"PRIMARY"];
-
+
[[self window] makeFirstResponder:indexedColumnsComboBox];
-
+
// Check to see whether a primary key already exists for the table, and if so select an INDEX instead
- for (NSDictionary *field in fields)
+ for (NSDictionary *field in fields)
{
if ([[field objectForKey:@"Key"] isEqualToString:@"PRI"]) {
[indexTypePopUpButton selectItemAtIndex:1];
[indexNameTextField setEnabled:YES];
[indexNameTextField setStringValue:@""];
-
+
[[self window] makeFirstResponder:indexNameTextField];
-
+
break;
}
}
-
+
// Update the default values array and the indexed column fields control
[indexedColumnsComboBox removeAllItems];
-
- for (NSDictionary *field in fields)
+
+ for (NSDictionary *field in fields)
{
- [indexedColumnsComboBox addItemWithObjectValue:[field objectForKey:@"Field"]];
+ [indexedColumnsComboBox addItemWithObjectValue:[field objectForKey:@"name"]];
}
-
+
// Only show up to ten items in the indexed column fields combo box
[indexedColumnsComboBox setNumberOfVisibleItems:([fields count] < 10) ? [fields count] : 10];
-
+
// Select the first column
[indexedColumnsComboBox selectItemAtIndex:0];
-
+
// Begin the sheet
[NSApp beginSheet:[self window]
- modalForWindow:[dbDocument parentWindow]
+ modalForWindow:[dbDocument parentWindow]
modalDelegate:self
- didEndSelector:@selector(addIndexSheetDidEnd:returnCode:contextInfo:)
+ didEndSelector:@selector(addIndexSheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
@@ -138,20 +138,20 @@
- (IBAction)removeIndex:(id)sender
{
if (![indexesTableView numberOfSelectedRows]) return;
-
+
// Check whether a save of the current fields row is required.
if (![tableStructure saveRowOnDeselect]) return;
-
+
NSInteger index = [indexesTableView selectedRow];
-
+
if ((index == -1) || (index > ([indexes count] - 1))) return;
-
+
NSString *keyName = [[indexes objectAtIndex:index] objectForKey:@"Key_name"];
NSString *columnName = [[indexes objectAtIndex:index] objectForKey:@"Column_name"];
-
+
BOOL hasForeignKey = NO;
NSString *constraintName = @"";
-
+
// Check to see whether the user is attempting to remove an index that a foreign key constraint depends on
// thus would result in an error if not dropped before removing the index.
for (NSDictionary *constraint in [tableData getConstraints])
@@ -165,22 +165,22 @@
}
}
}
-
+
NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Delete index '%@'?", @"delete index message"), keyName]
defaultButton:NSLocalizedString(@"Delete", @"delete button")
alternateButton:NSLocalizedString(@"Cancel", @"cancel button")
- otherButton:nil
+ otherButton:nil
informativeTextWithFormat:(hasForeignKey) ? [NSString stringWithFormat:NSLocalizedString(@"The foreign key relationship '%@' has a dependency on this index. This relationship must be removed before the index can be deleted.\n\nAre you sure you want to continue to delete the relationship and the index? This action cannot be undone.", @"delete index and foreign key informative message"), constraintName] : [NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to delete the index '%@'? This action cannot be undone.", @"delete index informative message"), keyName]];
-
+
[alert setAlertStyle:NSCriticalAlertStyle];
-
+
NSArray *buttons = [alert buttons];
-
+
// Change the alert's cancel button to have the key equivalent of return
[[buttons objectAtIndex:0] setKeyEquivalent:@"d"];
[[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask];
[[buttons objectAtIndex:1] setKeyEquivalent:@"\r"];
-
+
[alert beginSheetModalForWindow:[dbDocument parentWindow] modalDelegate:self didEndSelector:@selector(removeIndexSheetDidEnd:returnCode:contextInfo:) contextInfo:(hasForeignKey) ? @"removeIndexAndForeignKey" : @"removeIndex"];
}
@@ -192,10 +192,10 @@
if ([[indexTypePopUpButton titleOfSelectedItem] isEqualToString:@"PRIMARY KEY"] ) {
[indexNameTextField setEnabled:NO];
[indexNameTextField setStringValue:@"PRIMARY"];
- }
+ }
else {
[indexNameTextField setEnabled:YES];
-
+
if ([[indexNameTextField stringValue] isEqualToString:@"PRIMARY"]) {
[indexNameTextField setStringValue:@""];
}
@@ -221,7 +221,7 @@
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
- return [[indexes objectAtIndex:rowIndex] objectForKey:[tableColumn identifier]];
+ return [[indexes objectAtIndex:rowIndex] objectForKey:[tableColumn identifier]];
}
#pragma mark -
@@ -233,11 +233,11 @@
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
if ([notification object] == indexesTableView) {
-
+
// Check if there is currently an index selected and change button state accordingly
[removeIndexButton setEnabled:([indexesTableView numberOfSelectedRows] > 0 && [tablesList tableType] == SPTableTypeTable)];
}
-
+
}
#pragma mark -
@@ -247,9 +247,9 @@
* Only enable the add button if there is at least one indexed column.
*/
- (void)controlTextDidChange:(NSNotification *)notification
-{
+{
if ([notification object] == indexedColumnsComboBox) {
- [addIndexButton setEnabled:([[[indexedColumnsComboBox stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] > 0)];
+ [addIndexButton setEnabled:([[[indexedColumnsComboBox stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] > 0)];
}
}
@@ -262,7 +262,7 @@
- (void)setFields:(NSArray *)tableFields
{
[fields removeAllObjects];
-
+
[fields setArray:tableFields];
}
@@ -272,7 +272,7 @@
- (void)setIndexes:(NSArray *)tableIndexes
{
[indexes removeAllObjects];
-
+
[indexes setArray:tableIndexes];
}
@@ -282,21 +282,21 @@
- (void)addIndexSheetDidEnd:(NSWindow *)theSheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[theSheet orderOut:nil];
-
+
if (returnCode == NSOKButton) {
[dbDocument startTaskWithDescription:NSLocalizedString(@"Adding index...", @"adding index task status message")];
-
+
NSMutableDictionary *indexDetails = [NSMutableDictionary dictionary];
-
+
[indexDetails setObject:[[indexedColumnsComboBox stringValue] componentsSeparatedByString:@","] forKey:@"IndexedColumns"];
[indexDetails setObject:[indexNameTextField stringValue] forKey:@"IndexName"];
[indexDetails setObject:[indexTypePopUpButton titleOfSelectedItem] forKey:@"IndexType"];
-
+
if ([NSThread isMainThread]) {
[NSThread detachNewThreadSelector:@selector(_addIndexUsingDetails:) toTarget:self withObject:indexDetails];
-
- [dbDocument enableTaskCancellationWithTitle:NSLocalizedString(@"Cancel", @"cancel button") callbackObject:self callbackFunction:NULL];
- }
+
+ [dbDocument enableTaskCancellationWithTitle:NSLocalizedString(@"Cancel", @"cancel button") callbackObject:self callbackFunction:NULL];
+ }
else {
[self _addIndexUsingDetails:indexDetails];
}
@@ -311,20 +311,20 @@
{
// Order out current sheet to suppress overlapping of sheets
[[alert window] orderOut:nil];
-
+
if (returnCode == NSAlertDefaultReturn) {
[dbDocument startTaskWithDescription:NSLocalizedString(@"Removing index...", @"removing index task status message")];
-
+
NSMutableDictionary *indexDetails = [NSMutableDictionary dictionary];
-
+
[indexDetails setObject:[indexes objectAtIndex:[indexesTableView selectedRow]] forKey:@"Index"];
[indexDetails setObject:[NSNumber numberWithBool:[contextInfo hasSuffix:@"AndForeignKey"]] forKey:@"RemoveForeignKey"];
-
+
if ([NSThread isMainThread]) {
[NSThread detachNewThreadSelector:@selector(_removeIndexUsingDeatails:) toTarget:self withObject:indexDetails];
-
+
[dbDocument enableTaskCancellationWithTitle:NSLocalizedString(@"Cancel", @"cancel button") callbackObject:self callbackFunction:NULL];
- }
+ }
else {
[self _removeIndexUsingDeatails:indexDetails];
}
@@ -335,21 +335,21 @@
* This method is called as part of Key Value Observing which is used to watch for preference changes which effect the interface.
*/
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
-{
+{
// Display table veiew vertical gridlines preference changed
if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) {
[indexesTableView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
}
// Use monospaced fonts preference changed
else if ([keyPath isEqualToString:SPUseMonospacedFonts]) {
-
+
BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue];
-
+
for (NSTableColumn *indexColumn in [indexesTableView tableColumns])
{
[[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
}
-
+
[indexesTableView reloadData];
}
}
@@ -358,19 +358,19 @@
* Menu validation
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
-{
+{
// Remove index
if ([menuItem action] == @selector(removeIndex:)) {
return ([indexesTableView numberOfSelectedRows] == 1);
}
-
+
// Reset AUTO_INCREMENT
- if ([menuItem action] == @selector(resetAutoIncrement:)) {
- return ([indexesTableView numberOfSelectedRows] == 1
- && [[indexes objectAtIndex:[indexesTableView selectedRow]] objectForKey:@"Key_name"]
+ if ([menuItem action] == @selector(resetAutoIncrement:)) {
+ return ([indexesTableView numberOfSelectedRows] == 1
+ && [[indexes objectAtIndex:[indexesTableView selectedRow]] objectForKey:@"Key_name"]
&& [[[indexes objectAtIndex:[indexesTableView selectedRow]] objectForKey:@"Key_name"] isEqualToString:@"PRIMARY"]);
}
-
+
return YES;
}
@@ -383,52 +383,52 @@
- (void)_addIndexUsingDetails:(NSDictionary *)indexDetails
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+
// Check whether a save of the current fields row is required.
if (![[tableStructure onMainThread] saveRowOnDeselect]) return;
-
+
NSString *indexName = [indexDetails objectForKey:@"IndexName"];
NSString *indexType = [indexDetails objectForKey:@"IndexType"];
NSArray *indexedColumns = [indexDetails objectForKey:@"IndexedColumns"];
-
+
// Interface validation should prevent this
if ([indexedColumns count] > 0) {
-
+
NSMutableArray *tempIndexedColumns = [[NSMutableArray alloc] init];
-
+
if ([indexName isEqualToString:@"PRIMARY"]) {
indexName = @"";
- }
+ }
else {
indexName = ([indexName isEqualToString:@""]) ? @"" : [indexName backtickQuotedString];
}
-
+
// For each column strip leading and trailing whitespace and add it to the temp array
for (NSString *column in indexedColumns)
- {
+ {
[tempIndexedColumns addObject:[column stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
}
-
+
// Execute the query
[connection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ ADD %@ %@ (%@)", [table backtickQuotedString], indexType, indexName, [tempIndexedColumns componentsJoinedAndBacktickQuoted]]];
-
+
[tempIndexedColumns release];
-
+
// Check for errors, but only if the query wasn't cancelled
if ([connection queryErrored] && ![connection queryCancelled]) {
- SPBeginAlertSheet(NSLocalizedString(@"Unable to add index", @"add index error message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [dbDocument parentWindow], self, nil, nil,
+ SPBeginAlertSheet(NSLocalizedString(@"Unable to add index", @"add index error message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [dbDocument parentWindow], self, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to add the index.\n\nMySQL said: %@", @"add index error informative message"), [connection getLastErrorMessage]]);
}
else {
[tableData resetAllData];
[tablesList setStatusRequiresReload:YES];
-
+
[tableStructure loadTable:table];
}
}
-
+
[dbDocument endTask];
-
+
[pool drain];
}
@@ -438,17 +438,17 @@
- (void)_removeIndexUsingDeatails:(NSDictionary *)indexDetails
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+
NSDictionary *index = [indexDetails objectForKey:@"Index"];
BOOL removeForeignKey = [[indexDetails objectForKey:@"RemoveForeignKey"] boolValue];
-
+
// Remove the foreign key dependency before the index if required
if (removeForeignKey) {
-
+
NSString *columnName = [index objectForKey:@"Column_name"];
-
+
NSString *constraintName = @"";
-
+
// Check to see whether the user is attempting to remove an index that a foreign key constraint depends on
// thus would result in an error if not dropped before removing the index.
for (NSDictionary *constraint in [tableData getConstraints])
@@ -461,20 +461,20 @@
}
}
}
-
+
[connection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ DROP FOREIGN KEY %@", [table backtickQuotedString], [constraintName backtickQuotedString]]];
-
+
// Check for errors, but only if the query wasn't cancelled
if ([connection queryErrored] && ![connection queryCancelled]) {
NSMutableDictionary *errorDictionary = [NSMutableDictionary dictionary];
-
+
[errorDictionary setObject:NSLocalizedString(@"Unable to delete relation", @"error deleting relation message") forKey:@"title"];
[errorDictionary setObject:[NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to delete the relation '%@'.\n\nMySQL said: %@", @"error deleting relation informative message"), constraintName, [connection getLastErrorMessage]] forKey:@"message"];
-
+
[[tableStructure onMainThread] showErrorSheetWith:errorDictionary];
- }
+ }
}
-
+
if ([[index objectForKey:@"Key_name"] isEqualToString:@"PRIMARY"]) {
[connection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ DROP PRIMARY KEY", [table backtickQuotedString]]];
}
@@ -482,25 +482,25 @@
[connection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ DROP INDEX %@",
[table backtickQuotedString], [[index objectForKey:@"Key_name"] backtickQuotedString]]];
}
-
+
// Check for errors, but only if the query wasn't cancelled
if ([connection queryErrored] && ![connection queryCancelled]) {
NSMutableDictionary *errorDictionary = [NSMutableDictionary dictionary];
-
+
[errorDictionary setObject:NSLocalizedString(@"Unable to delete index", @"error deleting index message") forKey:@"title"];
[errorDictionary setObject:[NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to delete the index.\n\nMySQL said: %@", @"error deleting index informative message"), [connection getLastErrorMessage]] forKey:@"message"];
-
+
[[tableStructure onMainThread] showErrorSheetWith:errorDictionary];
- }
+ }
else {
[tableData resetAllData];
[tablesList setStatusRequiresReload:YES];
-
+
[tableStructure loadTable:table];
}
-
+
[dbDocument endTask];
-
+
[pool drain];
}
@@ -510,11 +510,11 @@
* Dealloc.
*/
- (void)dealloc
-{
+{
[table release];
[indexes release];
[fields release];
-
+
[super dealloc];
}
diff --git a/Source/SPTableStructure.h b/Source/SPTableStructure.h
index f81078b1..74905e5e 100644
--- a/Source/SPTableStructure.h
+++ b/Source/SPTableStructure.h
@@ -53,7 +53,9 @@
IBOutlet id indexesTableView;
IBOutlet NSSplitView *tablesIndexesSplitView;
IBOutlet NSButton *indexesShowButton;
-
+
+ id databaseDataInstance;
+
MCPConnection *mySQLConnection;
MCPResult *tableSourceResult;
MCPResult *indexResult;
@@ -65,6 +67,7 @@
BOOL isEditingRow, isEditingNewRow, isSavingRow, alertSheetOpened;
NSInteger currentlyEditingRow;
NSUserDefaults *prefs;
+ NSArray *collations;
}
// Table methods
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index ac490b82..2ec324a7 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -55,14 +55,14 @@
tableFields = [[NSMutableArray alloc] init];
oldRow = [[NSMutableDictionary alloc] init];
enumFields = [[NSMutableDictionary alloc] init];
-
+
currentlyEditingRow = -1;
defaultValues = nil;
selectedTable = nil;
-
+
prefs = [NSUserDefaults standardUserDefaults];
}
-
+
return self;
}
@@ -73,15 +73,17 @@
{
// Set the structure and index view's vertical gridlines if required
[tableSourceView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
-
+
// Set the strutcture and index view's font
BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts];
-
+
for (NSTableColumn *fieldColumn in [tableSourceView tableColumns])
{
[[fieldColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
}
-
+
+ databaseDataInstance = [tableDocumentInstance valueForKeyPath:@"databaseDataInstance"];
+
// Add observers for document task activity
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(startDocumentTaskForTab:)
@@ -100,12 +102,10 @@
*/
- (void)loadTable:(NSString *)aTable
{
- NSArray *theTableFields, *theTableIndexes;
+ NSMutableArray *theTableFields = [NSMutableArray array];
+ NSArray *theTableIndexes;
NSMutableDictionary *theTableEnumLists = [NSMutableDictionary dictionary];
- NSArray *extrasArray;
- NSMutableDictionary *tempDefaultValues;
NSInteger i;
- SPSQLParser *fieldParser;
// Check whether a save of the current row is required.
if ( ![[self onMainThread] saveRowOnDeselect] ) return;
@@ -115,32 +115,10 @@
[[self onMainThread] setTableDetails:nil];
return;
}
-
- // Send the query started/working notification
- [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance];
-
- // Retrieve the column information for this table.
- // TODO: update this and indexes to use TableData at some point - tiny bit more parsing required...
- tableSourceResult = [[mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [aTable backtickQuotedString]]] retain];
-
- // If an error occurred, reset the interface and abort
- if ([mySQLConnection queryErrored]) {
- [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
- [[self onMainThread] setTableDetails:nil];
-
- if ([mySQLConnection isConnected]) {
- SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"),
- nil, nil, [NSApp mainWindow], self, nil, nil,
- [NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"),
- [mySQLConnection getLastErrorMessage]]);
- }
- if (tableSourceResult) [tableSourceResult release];
- return;
- }
- // Process the field names into a local array of dictionaries
- theTableFields = [self fetchResultAsArray:tableSourceResult];
- [tableSourceResult release];
+ // Make a mutable copy out of the cached [tableDataInstance columns] since we're adding infos
+ for(id col in [tableDataInstance columns])
+ [theTableFields addObject:[col mutableCopy]];
// Retrieve the indexes for the table
indexResult = [[mySQLConnection queryString:[NSString stringWithFormat:@"SHOW INDEX FROM %@", [aTable backtickQuotedString]]] retain];
@@ -151,7 +129,7 @@
[[self onMainThread] setTableDetails:nil];
if ([mySQLConnection isConnected]) {
- SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"),
+ SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"),
nil, nil, [NSApp mainWindow], self, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"An error occurred while retrieving information.\nMySQL said: %@", @"message of panel when retrieving information failed"),
[mySQLConnection getLastErrorMessage]]);
@@ -164,72 +142,95 @@
theTableIndexes = [self fetchResultAsArray:indexResult];
[indexResult release];
- // Process all the fields to normalise keys and add additional information
- for (id theField in theTableFields) {
- NSString *type;
- NSString *length;
- NSString *extras;
-
- // Set up the field parser with the type definition
- fieldParser = [[SPSQLParser alloc] initWithString:[theField objectForKey:@"Type"]];
-
- // Pull out the field type; if no brackets are found, this returns nil - in which case simple values can be used.
- type = [fieldParser trimAndReturnStringToCharacter:'(' trimmingInclusively:YES returningInclusively:NO];
- if (!type) {
- type = [NSString stringWithString:fieldParser];
- length = @"";
- extras = @"";
- } else {
-
- // Pull out the length, which may include enum/set values
- length = [fieldParser trimAndReturnStringToCharacter:')' trimmingInclusively:YES returningInclusively:NO];
- if (!length) length = @"";
+ // Set the Key column
+ for(NSDictionary* theIndex in theTableIndexes) {
+ for(id field in theTableFields) {
+ if([[field objectForKey:@"name"] isEqualToString:[theIndex objectForKey:@"Column_name"]]) {
+ if([[theIndex objectForKey:@"Key_name"] isEqualToString:@"PRIMARY"])
+ [field setObject:@"PRI" forKey:@"Key"];
+ else
+ [field setObject:(([[theIndex objectForKey:@"Non_unique"] isEqualToString:@"1"]) ? @"MUL" : @"UNI") forKey:@"Key"];
+ break;
+ }
+ }
+ }
- // Separate any remaining extras
- extras = [NSString stringWithString:fieldParser];
- if (!extras) extras = @"";
+ // Set up the encoding PopUpButtonCell
+ NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings];
+ if (([encodings count] > 0) && ([tableDataInstance tableEncoding])) {
+ NSString *selectedTitle = @"";
+ [[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] removeAllItems];
+ [[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] addItemWithTitle:@""];
+ // Populate encoding popup button
+ for (NSDictionary *encoding in encodings)
+ {
+ NSString *menuItemTitle = (![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]];
+ [[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] addItemWithTitle:menuItemTitle];
}
+ }
+ else {
+ [[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] addItemWithTitle:NSLocalizedString(@"Not available", @"not available label")];
+ }
- [fieldParser release];
+ // Process all the fields to normalise keys and add additional information
+ for (id theField in theTableFields) {
- // Get possible values if the field is an enum or a set
- if ([type isEqualToString:@"enum"] || [type isEqualToString:@"set"]) {
- SPSQLParser *valueParser = [[SPSQLParser alloc] initWithString:length];
- NSMutableArray *possibleValues = [[NSMutableArray alloc] initWithArray:[valueParser splitStringByCharacter:',']];
- for (i = 0; i < [possibleValues count]; i++) {
- [valueParser setString:[possibleValues objectAtIndex:i]];
- [possibleValues replaceObjectAtIndex:i withObject:[valueParser unquotedString]];
+ // Select and re-map encoding and collation since [self dataSource] stores the choice as NSNumbers
+ NSString *fieldEncoding = @"";
+ NSInteger selectedIndex = 0;
+ if([theField objectForKey:@"encoding"]) {
+ for(id enc in encodings) {
+ if([[enc objectForKey:@"CHARACTER_SET_NAME"] isEqualToString:[theField objectForKey:@"encoding"]]) {
+ fieldEncoding = [theField objectForKey:@"encoding"];
+ break;
+ }
+ selectedIndex++;
}
- [theTableEnumLists setObject:[NSArray arrayWithArray:possibleValues] forKey:[theField objectForKey:@"Field"]];
- [possibleValues release];
- [valueParser release];
+ selectedIndex++; // due to leading @"" in popup list
}
-
- // For timestamps check to see whether "on update CURRENT_TIMESTAMP" - not returned
- // by SHOW COLUMNS - should be set from the table data store
- if ([type isEqualToString:@"timestamp"]
- && [[[tableDataInstance columnWithName:[theField objectForKey:@"Field"]] objectForKey:@"onupdatetimestamp"] integerValue])
- {
- [theField setObject:@"on update CURRENT_TIMESTAMP" forKey:@"Extra"];
+ [theField setObject:[NSNumber numberWithInt:selectedIndex] forKey:@"encoding"];
+ selectedIndex = 0;
+ if([fieldEncoding length] && [theField objectForKey:@"collation"]) {
+ NSArray *theCollations = [databaseDataInstance getDatabaseCollationsForEncoding:fieldEncoding];
+ for(id col in theCollations) {
+ if([[col objectForKey:@"COLLATION_NAME"] isEqualToString:[theField objectForKey:@"collation"]]) {
+ break;
+ }
+ selectedIndex++;
+ }
+ selectedIndex++; // due to leading @"" in popup list
}
+ [theField setObject:[NSNumber numberWithInt:selectedIndex] forKey:@"collation"];
- // Scan extras for values like unsigned, zerofill, binary
- extrasArray = [extras componentsSeparatedByString:@" "];
- for (id extra in extrasArray) {
- if ([extra isEqualToString:@"unsigned"]) {
- [theField setObject:@"1" forKey:@"unsigned"];
- } else if ([extra isEqualToString:@"zerofill"]) {
- [theField setObject:@"1" forKey:@"zerofill"];
- } else if ([extra isEqualToString:@"binary"]) {
- [theField setObject:@"1" forKey:@"binary"];
- } else {
- if (![extra isEqualToString:@""])
- NSLog(@"ERROR: unknown option in field definition: %@", extra);
- }
+ NSString *type = [[theField objectForKey:@"type"] uppercaseString];
+
+ // Get possible values if the field is an enum or a set
+ if (([type isEqualToString:@"ENUM"] || [type isEqualToString:@"SET"]) && [theField objectForKey:@"values"]) {
+ [theTableEnumLists setObject:[NSArray arrayWithArray:[theField objectForKey:@"values"]] forKey:[theField objectForKey:@"name"]];
+ [theField setObject:[NSString stringWithFormat:@"'%@'", [[theField objectForKey:@"values"] componentsJoinedByString:@"','"]] forKey:@"length"];
}
- [theField setObject:type forKey:@"Type"];
- [theField setObject:length forKey:@"Length"];
+ // Join length and decimals if any
+ if ([theField objectForKey:@"decimals"])
+ [theField setObject:[NSString stringWithFormat:@"%@,%@", [theField objectForKey:@"length"], [theField objectForKey:@"decimals"]] forKey:@"length"];
+
+ // Normalize default
+ if(![theField objectForKey:@"default"])
+ [theField setObject:@"" forKey:@"default"];
+ else if([[theField objectForKey:@"default"] isKindOfClass:[NSNull class]])
+ [theField setObject:[prefs stringForKey:SPNullValue] forKey:@"default"];
+
+ // Init Extra field
+ [theField setObject:@"None" forKey:@"Extra"];
+
+ // Check for auto_increment and set Extra accordingly
+ if([[theField objectForKey:@"autoincrement"] integerValue])
+ [theField setObject:@"auto_increment" forKey:@"Extra"];
+
+ // For timestamps check to see whether "on update CURRENT_TIMESTAMP" and set Extra accordingly
+ else if ([type isEqualToString:@"TIMESTAMP"] && [[theField objectForKey:@"onupdatetimestamp"] integerValue])
+ [theField setObject:@"on update CURRENT_TIMESTAMP" forKey:@"Extra"];
+
}
// Set up the table details for the new table, and request an data/interface update
@@ -243,7 +244,7 @@
// Send the query finished/work complete notification
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
-
+
}
/**
@@ -274,7 +275,7 @@
// Update the selected table name
if (selectedTable) [selectedTable release], selectedTable = nil;
if (newTableName) selectedTable = [[NSString alloc] initWithString:newTableName];
-
+
[indexesController setTable:selectedTable];
// Reset the table store and display
@@ -301,27 +302,25 @@
// Update the fields and indexes stores
[tableFields setArray:[tableDetails objectForKey:@"tableFields"]];
-
+
[indexesController setFields:tableFields];
[indexesController setIndexes:[tableDetails objectForKey:@"tableIndexes"]];
-
+
if (defaultValues) [defaultValues release], defaultValues = nil;
-
+
newDefaultValues = [NSMutableDictionary dictionaryWithCapacity:[tableFields count]];
-
- for (id theField in tableFields)
- {
- [newDefaultValues setObject:[theField objectForKey:@"Default"] forKey:[theField objectForKey:@"Field"]];
- }
-
+
+ for (id theField in tableFields)
+ [newDefaultValues setObject:[theField objectForKey:@"default"] forKey:[theField objectForKey:@"name"]];
+
defaultValues = [[NSDictionary dictionaryWithDictionary:newDefaultValues] retain];
-
+
// Enable the edit table button
[editTableButton setEnabled:enableInteraction];
// If a view is selected, disable the buttons; otherwise enable.
BOOL editingEnabled = ([tablesListInstance tableType] == SPTableTypeTable) && enableInteraction;
-
+
[addFieldButton setEnabled:editingEnabled];
[addIndexButton setEnabled:editingEnabled];
@@ -342,10 +341,10 @@
if ( ![self saveRowOnDeselect] ) return;
NSInteger insertIndex = ([tableSourceView numberOfSelectedRows] == 0 ? [tableSourceView numberOfRows] : [tableSourceView selectedRow] + 1);
-
- [tableFields insertObject:[NSMutableDictionary
- dictionaryWithObjects:[NSArray arrayWithObjects:@"", @"int", @"", @"0", @"0", @"0", ([prefs boolForKey:SPNewFieldsAllowNulls]) ? @"1" : @"0", @"", [prefs stringForKey:SPNullValue], @"None", nil]
- forKeys:[NSArray arrayWithObjects:@"Field", @"Type", @"Length", @"unsigned", @"zerofill", @"binary", @"Null", @"Key", @"Default", @"Extra", nil]]
+
+ [tableFields insertObject:[NSMutableDictionary
+ dictionaryWithObjects:[NSArray arrayWithObjects:@"", @"INT", @"", @"0", @"0", @"0", ([prefs boolForKey:SPNewFieldsAllowNulls]) ? @"1" : @"0", @"", [prefs stringForKey:SPNullValue], @"None", @"", @"", @"", nil]
+ forKeys:[NSArray arrayWithObjects:@"name", @"type", @"length", @"unsigned", @"zerofill", @"binary", @"null", @"Key", @"default", @"Extra", @"comment", @"encoding", @"collation", nil]]
atIndex:insertIndex];
[tableSourceView reloadData];
@@ -373,10 +372,10 @@
// Check whether a save of the current row is required.
if ( ![self saveRowOnDeselect] ) return;
-
+
//add copy of selected row and go in edit mode
tempRow = [NSMutableDictionary dictionaryWithDictionary:[tableFields objectAtIndex:rowToCopy]];
- [tempRow setObject:[[tempRow objectForKey:@"Field"] stringByAppendingString:@"Copy"] forKey:@"Field"];
+ [tempRow setObject:[[tempRow objectForKey:@"name"] stringByAppendingString:@"Copy"] forKey:@"name"];
[tempRow setObject:@"" forKey:@"Key"];
[tempRow setObject:@"None" forKey:@"Extra"];
[tableFields addObject:tempRow];
@@ -397,31 +396,31 @@
// Check whether a save of the current row is required.
if (![self saveRowOnDeselect]) return;
-
+
NSInteger index = [tableSourceView selectedRow];
-
+
if ((index == -1) || (index > ([tableFields count] - 1))) return;
// Check if the user tries to delete the last defined field in table
// Note that because of better menu item validation, this check will now never evaluate to true.
if ([tableSourceView numberOfRows] < 2) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error while deleting field", @"Error while deleting field")
- defaultButton:NSLocalizedString(@"OK", @"OK button")
- alternateButton:nil
- otherButton:nil
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
informativeTextWithFormat:NSLocalizedString(@"You cannot delete the last field in a table. Delete the table instead.", @"You cannot delete the last field in a table. Delete the table instead.")];
[alert setAlertStyle:NSCriticalAlertStyle];
[alert beginSheetModalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"cannotremovefield"];
-
+
}
-
- NSString *field = [[tableFields objectAtIndex:index] objectForKey:@"Field"];
-
+
+ NSString *field = [[tableFields objectAtIndex:index] objectForKey:@"name"];
+
BOOL hasForeignKey = NO;
NSString *referencedTable = @"";
-
+
// Check to see whether the user is attempting to remove a field that has foreign key constraints and thus
// would result in an error if not dropped before removing the field.
for (NSDictionary *constraint in [tableDataInstance getConstraints])
@@ -435,22 +434,22 @@
}
}
}
-
+
NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Delete field '%@'?", @"delete field message"), field]
defaultButton:NSLocalizedString(@"Delete", @"delete button")
- alternateButton:NSLocalizedString(@"Cancel", @"cancel button")
- otherButton:nil
+ alternateButton:NSLocalizedString(@"Cancel", @"cancel button")
+ otherButton:nil
informativeTextWithFormat:(hasForeignKey) ? [NSString stringWithFormat:NSLocalizedString(@"This field is part of a foreign key relationship with the table '%@'. This relationship must be removed before the field can be deleted.\n\nAre you sure you want to continue to delete the relationship and the field? This action cannot be undone.", @"delete field and foreign key informative message"), referencedTable] : [NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to delete the field '%@'? This action cannot be undone.", @"delete field informative message"), field]];
-
+
[alert setAlertStyle:NSCriticalAlertStyle];
-
+
NSArray *buttons = [alert buttons];
-
+
// Change the alert's cancel button to have the key equivalent of return
[[buttons objectAtIndex:0] setKeyEquivalent:@"d"];
[[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask];
[[buttons objectAtIndex:1] setKeyEquivalent:@"\r"];
-
+
[alert beginSheetModalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:@selector(removeFieldSheetDidEnd:returnCode:contextInfo:) contextInfo:(hasForeignKey) ? @"removeFieldAndForeignKey" : @"removeField"];
}
@@ -460,19 +459,19 @@
- (IBAction)resetAutoIncrement:(id)sender
{
if ([sender tag] == 1) {
-
+
[resetAutoIncrementLine setHidden:YES];
-
+
if ([[tableDocumentInstance valueForKeyPath:@"tableTabView"] indexOfTabViewItem:[[tableDocumentInstance valueForKeyPath:@"tableTabView"] selectedTabViewItem]] == 0)
[resetAutoIncrementLine setHidden:NO];
-
+
// Begin the sheet
[NSApp beginSheet:resetAutoIncrementSheet
- modalForWindow:[tableDocumentInstance parentWindow]
+ modalForWindow:[tableDocumentInstance parentWindow]
modalDelegate:self
- didEndSelector:@selector(resetAutoincrementSheetDidEnd:returnCode:contextInfo:)
+ didEndSelector:@selector(resetAutoincrementSheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
-
+
[resetAutoIncrementValue setStringValue:@"1"];
}
else if ([sender tag] == 2) {
@@ -487,7 +486,7 @@
{
// Order out current sheet to suppress overlapping of sheets
[theSheet orderOut:nil];
-
+
if (returnCode == NSAlertDefaultReturn) {
[self setAutoIncrementTo:[[resetAutoIncrementValue stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
}
@@ -504,14 +503,14 @@
if (returnCode == NSAlertDefaultReturn) {
[tableDocumentInstance startTaskWithDescription:NSLocalizedString(@"Removing field...", @"removing field task status message")];
-
+
NSNumber *removeKey = [NSNumber numberWithBool:[contextInfo hasSuffix:@"AndForeignKey"]];
-
+
if ([NSThread isMainThread]) {
[NSThread detachNewThreadSelector:@selector(_removeFieldAndForeignKey:) toTarget:self withObject:removeKey];
-
- [tableDocumentInstance enableTaskCancellationWithTitle:NSLocalizedString(@"Cancel", @"cancel button") callbackObject:self callbackFunction:NULL];
- }
+
+ [tableDocumentInstance enableTaskCancellationWithTitle:NSLocalizedString(@"Cancel", @"cancel button") callbackObject:self callbackFunction:NULL];
+ }
else {
[self _removeFieldAndForeignKey:removeKey];
}
@@ -543,12 +542,12 @@ closes the keySheet
#pragma mark Additional methods
/**
- * Sets the connection (received from SPDatabaseDocument) and makes things that have to be done only once
+ * Sets the connection (received from SPDatabaseDocument) and makes things that have to be done only once
*/
- (void)setConnection:(MCPConnection *)theConnection
{
mySQLConnection = theConnection;
-
+
// Set the indexes controller connection
[indexesController setConnection:mySQLConnection];
@@ -586,10 +585,10 @@ closes the keySheet
[mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ AUTO_INCREMENT = %@", [selTable backtickQuotedString], [autoIncValue stringValue]]];
if ([mySQLConnection queryErrored]) {
- SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"),
+ SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"),
NSLocalizedString(@"OK", @"OK button"),
- nil, nil, [NSApp mainWindow], nil, nil, nil,
- [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to reset AUTO_INCREMENT of table '%@'.\n\nMySQL said: %@", @"error resetting auto_increment informative message"),
+ nil, nil, [NSApp mainWindow], nil, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to reset AUTO_INCREMENT of table '%@'.\n\nMySQL said: %@", @"error resetting auto_increment informative message"),
selTable, [mySQLConnection getLastErrorMessage]]);
}
@@ -685,181 +684,196 @@ closes the keySheet
if (!isEditingRow || currentlyEditingRow == -1)
return YES;
-
+
if (alertSheetOpened)
return NO;
theRow = [tableFields objectAtIndex:currentlyEditingRow];
-
+
if (isEditingNewRow) {
// ADD syntax
- if ([[theRow objectForKey:@"Length"] isEqualToString:@""] || ![theRow objectForKey:@"Length"]) {
-
+ if ([[theRow objectForKey:@"length"] isEqualToString:@""] || ![theRow objectForKey:@"length"]) {
+
queryString = [NSMutableString stringWithFormat:@"ALTER TABLE %@ ADD %@ %@",
- [selectedTable backtickQuotedString],
- [[theRow objectForKey:@"Field"] backtickQuotedString],
- [theRow objectForKey:@"Type"]];
- }
+ [selectedTable backtickQuotedString],
+ [[theRow objectForKey:@"name"] backtickQuotedString],
+ [[theRow objectForKey:@"type"] uppercaseString]];
+ }
else {
queryString = [NSMutableString stringWithFormat:@"ALTER TABLE %@ ADD %@ %@(%@)",
- [selectedTable backtickQuotedString],
- [[theRow objectForKey:@"Field"] backtickQuotedString],
- [theRow objectForKey:@"Type"],
- [theRow objectForKey:@"Length"]];
+ [selectedTable backtickQuotedString],
+ [[theRow objectForKey:@"name"] backtickQuotedString],
+ [[theRow objectForKey:@"type"] uppercaseString],
+ [theRow objectForKey:@"length"]];
}
- }
+ }
else {
// CHANGE syntax
- if (([[theRow objectForKey:@"Length"] isEqualToString:@""]) ||
- (![theRow objectForKey:@"Length"]) ||
- ([[theRow objectForKey:@"Type"] isEqualToString:@"datetime"]))
+ if (([[theRow objectForKey:@"length"] isEqualToString:@""]) ||
+ (![theRow objectForKey:@"length"]) ||
+ ([[[theRow objectForKey:@"type"] lowercaseString] isEqualToString:@"datetime"]))
{
- // If the old row and new row dictionaries are equal then the user didn't actually change anything so don't continue
+ // If the old row and new row dictionaries are equal then the user didn't actually change anything so don't continue
if ([oldRow isEqualToDictionary:theRow]) {
isEditingRow = NO;
currentlyEditingRow = -1;
return YES;
}
-
+
queryString = [NSMutableString stringWithFormat:@"ALTER TABLE %@ CHANGE %@ %@ %@",
- [selectedTable backtickQuotedString],
- [[oldRow objectForKey:@"Field"] backtickQuotedString],
- [[theRow objectForKey:@"Field"] backtickQuotedString],
- [theRow objectForKey:@"Type"]];
- }
+ [selectedTable backtickQuotedString],
+ [[oldRow objectForKey:@"name"] backtickQuotedString],
+ [[theRow objectForKey:@"name"] backtickQuotedString],
+ [[theRow objectForKey:@"type"] uppercaseString]];
+ }
else {
- // If the old row and new row dictionaries are equal then the user didn't actually change anything so don't continue
+ // If the old row and new row dictionaries are equal then the user didn't actually change anything so don't continue
if ([oldRow isEqualToDictionary:theRow]) {
isEditingRow = NO;
currentlyEditingRow = -1;
return YES;
}
-
+
queryString = [NSMutableString stringWithFormat:@"ALTER TABLE %@ CHANGE %@ %@ %@(%@)",
- [selectedTable backtickQuotedString],
- [[oldRow objectForKey:@"Field"] backtickQuotedString],
- [[theRow objectForKey:@"Field"] backtickQuotedString],
- [theRow objectForKey:@"Type"],
- [theRow objectForKey:@"Length"]];
+ [selectedTable backtickQuotedString],
+ [[oldRow objectForKey:@"name"] backtickQuotedString],
+ [[theRow objectForKey:@"name"] backtickQuotedString],
+ [[theRow objectForKey:@"type"] uppercaseString],
+ [theRow objectForKey:@"length"]];
}
}
-
+
+ NSString *fieldEncoding = @"";
+ if([[theRow objectForKey:@"encoding"] integerValue] > 0) {
+ NSString *enc = [[[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] itemAtIndex:[[theRow objectForKey:@"encoding"] integerValue]] title];
+ NSInteger start = [enc rangeOfString:@"("].location+1;
+ NSInteger end = [enc length] - start - 1;
+ fieldEncoding = [enc substringWithRange:NSMakeRange(start, end)];
+ [queryString appendFormat:@" CHARACTER SET %@", fieldEncoding];
+ }
+ if(![fieldEncoding length] && [tableDataInstance tableEncoding]) {
+ fieldEncoding = [tableDataInstance tableEncoding];
+ }
+ if([fieldEncoding length] && [[theRow objectForKey:@"collation"] integerValue] > 0) {
+ NSArray *theCollations = [databaseDataInstance getDatabaseCollationsForEncoding:fieldEncoding];
+ NSString *col = [[theCollations objectAtIndex:[[theRow objectForKey:@"collation"] integerValue]-1] objectForKey:@"COLLATION_NAME"];
+ [queryString appendFormat:@" COLLATE %@", col];
+ }
+
+
// Field specification
if ([[theRow objectForKey:@"unsigned"] integerValue] == 1) {
[queryString appendString:@" UNSIGNED"];
}
-
+
if ( [[theRow objectForKey:@"zerofill"] integerValue] == 1) {
[queryString appendString:@" ZEROFILL"];
}
-
+
if ( [[theRow objectForKey:@"binary"] integerValue] == 1) {
[queryString appendString:@" BINARY"];
}
- if ([[theRow objectForKey:@"Null"] integerValue] == 0) {
+ if ([[theRow objectForKey:@"null"] integerValue] == 0) {
[queryString appendString:@" NOT NULL"];
} else {
[queryString appendString:@" NULL"];
}
-
+
// Don't provide any defaults for auto-increment fields
if ([[theRow objectForKey:@"Extra"] isEqualToString:@"auto_increment"]) {
[queryString appendString:@" "];
- }
+ }
else {
// If a NULL value has been specified, and NULL is allowed, specify DEFAULT NULL
- if ([[theRow objectForKey:@"Default"] isEqualToString:[prefs objectForKey:SPNullValue]]) {
- if ([[theRow objectForKey:@"Null"] integerValue] == 1) {
+ if ([[theRow objectForKey:@"default"] isEqualToString:[prefs objectForKey:SPNullValue]]) {
+ if ([[theRow objectForKey:@"null"] integerValue] == 1) {
[queryString appendString:@" DEFAULT NULL "];
}
- }
+ }
// Otherwise, if CURRENT_TIMESTAMP was specified for timestamps, use that
- else if ([[theRow objectForKey:@"Type"] isEqualToString:@"timestamp"] &&
- [[[theRow objectForKey:@"Default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"])
+ else if ([[theRow objectForKey:@"type"] isEqualToString:@"timestamp"] &&
+ [[[theRow objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"])
{
[queryString appendString:@" DEFAULT CURRENT_TIMESTAMP "];
}
// If the field is of type BIT, permit the use of single qoutes and also don't quote the default value.
// For example, use DEFAULT b'1' as opposed to DEFAULT 'b\'1\'' which results in an error.
- else if ([[theRow objectForKey:@"Type"] isEqualToString:@"bit"]) {
- [queryString appendFormat:@" DEFAULT %@ ", [theRow objectForKey:@"Default"]];
+ else if ([[[theRow objectForKey:@"type"] lowercaseString] isEqualToString:@"bit"]) {
+ [queryString appendFormat:@" DEFAULT %@ ", [theRow objectForKey:@"default"]];
}
// Otherwise, use the provided default
else {
- [queryString appendFormat:@" DEFAULT '%@' ", [mySQLConnection prepareString:[theRow objectForKey:@"Default"]]];
+ [queryString appendFormat:@" DEFAULT '%@' ", [mySQLConnection prepareString:[theRow objectForKey:@"default"]]];
}
}
-
+
if (!(
- [[theRow objectForKey:@"Extra"] isEqualToString:@""] ||
+ [[theRow objectForKey:@"Extra"] isEqualToString:@""] ||
[[theRow objectForKey:@"Extra"] isEqualToString:@"None"]
- ) &&
- [theRow objectForKey:@"Extra"] )
+ ) &&
+ [theRow objectForKey:@"Extra"] )
{
[queryString appendString:@" "];
[queryString appendString:[theRow objectForKey:@"Extra"]];
}
-
- if (!isEditingNewRow) {
- // Add details not provided via the SHOW COLUMNS query from the table data cache so column details aren't lost
- NSDictionary *originalColumnDetails = [[tableDataInstance columns] objectAtIndex:currentlyEditingRow];
+ if (!isEditingNewRow) {
// Any column comments
- if ([originalColumnDetails objectForKey:@"comment"] && [(NSString *)[originalColumnDetails objectForKey:@"comment"] length]) {
- [queryString appendFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[originalColumnDetails objectForKey:@"comment"]]];
+ if ([[theRow objectForKey:@"comment"] length]) {
+ [queryString appendFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[theRow objectForKey:@"comment"]]];
}
// Unparsed details - column formats, storage, reference definitions
- if ([originalColumnDetails objectForKey:@"unparsed"]) {
- [queryString appendString:[originalColumnDetails objectForKey:@"unparsed"]];
+ if ([[theRow objectForKey:@"unparsed"] length]) {
+ [queryString appendString:[theRow objectForKey:@"unparsed"]];
}
}
-
+
// Asks the user to add an index to query if auto_increment is set and field isn't indexed
- if ([[theRow objectForKey:@"Extra"] isEqualToString:@"auto_increment"] &&
- ([[theRow objectForKey:@"Key"] isEqualToString:@""] ||
- ![theRow objectForKey:@"Key"]))
+ if ([[theRow objectForKey:@"Extra"] isEqualToString:@"auto_increment"] &&
+ ([[theRow objectForKey:@"Key"] isEqualToString:@""] ||
+ ![theRow objectForKey:@"Key"]))
{
[chooseKeyButton selectItemAtIndex:0];
-
- [NSApp beginSheet:keySheet
- modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self
- didEndSelector:nil
+
+ [NSApp beginSheet:keySheet
+ modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self
+ didEndSelector:nil
contextInfo:nil];
-
+
code = [NSApp runModalForWindow:keySheet];
-
+
[NSApp endSheet:keySheet];
[keySheet orderOut:nil];
-
+
if (code) {
// User wants to add PRIMARY KEY
- if ([chooseKeyButton indexOfSelectedItem] == 0 ) {
+ if ([chooseKeyButton indexOfSelectedItem] == 0 ) {
[queryString appendString:@" PRIMARY KEY"];
-
+
// Add AFTER ... only if the user added a new field
if (isEditingNewRow) {
- [queryString appendFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]];
+ [queryString appendFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"name"] backtickQuotedString]];
}
- }
+ }
else {
// Add AFTER ... only if the user added a new field
if (isEditingNewRow) {
- [queryString appendFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]];
- }
-
- [queryString appendFormat:@", ADD %@ (%@)", [chooseKeyButton titleOfSelectedItem], [[theRow objectForKey:@"Field"] backtickQuotedString]];
+ [queryString appendFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"name"] backtickQuotedString]];
+ }
+
+ [queryString appendFormat:@", ADD %@ (%@)", [chooseKeyButton titleOfSelectedItem], [[theRow objectForKey:@"name"] backtickQuotedString]];
}
}
- }
+ }
// Add AFTER ... only if the user added a new field
else if (isEditingNewRow) {
- [queryString appendFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]];
+ [queryString appendFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"name"] backtickQuotedString]];
}
-
+
// Execute query
[mySQLConnection queryString:queryString];
@@ -867,7 +881,7 @@ closes the keySheet
isEditingRow = NO;
isEditingNewRow = NO;
currentlyEditingRow = -1;
-
+
[tableDataInstance resetAllData];
[tablesListInstance setStatusRequiresReload:YES];
[self loadTable:selectedTable];
@@ -879,14 +893,14 @@ closes the keySheet
[NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", selectedTable, @"affectedItem", [NSNumber numberWithInt:[tablesListInstance tableType]], @"affectedItemType", nil]];
return YES;
- }
+ }
else {
alertSheetOpened = YES;
if([mySQLConnection getLastErrorID] == 1146) { // If the current table doesn't exist anymore
- SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"),
- NSLocalizedString(@"OK", @"OK button"),
- nil, nil, [tableDocumentInstance parentWindow], self, nil, nil,
- [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to alter table '%@'.\n\nMySQL said: %@", @"error while trying to alter table message"),
+ SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"),
+ NSLocalizedString(@"OK", @"OK button"),
+ nil, nil, [tableDocumentInstance parentWindow], self, nil, nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to alter table '%@'.\n\nMySQL said: %@", @"error while trying to alter table message"),
selectedTable, [mySQLConnection getLastErrorMessage]]);
isEditingRow = NO;
@@ -907,20 +921,20 @@ closes the keySheet
}
// Problem: alert sheet doesn't respond to first click
if (isEditingNewRow) {
- SPBeginAlertSheet(NSLocalizedString(@"Error adding field", @"error adding field message"),
- NSLocalizedString(@"Edit row", @"Edit row button"),
- NSLocalizedString(@"Discard changes", @"discard changes button"), nil, [tableDocumentInstance parentWindow], self, @selector(addRowErrorSheetDidEnd:returnCode:contextInfo:), nil,
- [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to add the field '%@'.\n\nMySQL said: %@", @"error adding field informative message"),
- [theRow objectForKey:@"Field"], [mySQLConnection getLastErrorMessage]]);
- }
+ SPBeginAlertSheet(NSLocalizedString(@"Error adding field", @"error adding field message"),
+ NSLocalizedString(@"Edit row", @"Edit row button"),
+ NSLocalizedString(@"Discard changes", @"discard changes button"), nil, [tableDocumentInstance parentWindow], self, @selector(addRowErrorSheetDidEnd:returnCode:contextInfo:), nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to add the field '%@'.\n\nMySQL said: %@", @"error adding field informative message"),
+ [theRow objectForKey:@"name"], [mySQLConnection getLastErrorMessage]]);
+ }
else {
- SPBeginAlertSheet(NSLocalizedString(@"Error changing field", @"error changing field message"),
- NSLocalizedString(@"Edit row", @"Edit row button"),
- NSLocalizedString(@"Discard changes", @"discard changes button"), nil, [tableDocumentInstance parentWindow], self, @selector(addRowErrorSheetDidEnd:returnCode:contextInfo:), nil,
- [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the field '%@'.\n\nMySQL said: %@", @"error changing field informative message"),
- [theRow objectForKey:@"Field"], [mySQLConnection getLastErrorMessage]]);
+ SPBeginAlertSheet(NSLocalizedString(@"Error changing field", @"error changing field message"),
+ NSLocalizedString(@"Edit row", @"Edit row button"),
+ NSLocalizedString(@"Discard changes", @"discard changes button"), nil, [tableDocumentInstance parentWindow], self, @selector(addRowErrorSheetDidEnd:returnCode:contextInfo:), nil,
+ [NSString stringWithFormat:NSLocalizedString(@"An error occurred when trying to change the field '%@'.\n\nMySQL said: %@", @"error changing field informative message"),
+ [theRow objectForKey:@"name"], [mySQLConnection getLastErrorMessage]]);
}
-
+
return NO;
}
}
@@ -950,7 +964,7 @@ closes the keySheet
[tableFields replaceObjectAtIndex:currentlyEditingRow
withObject:[NSMutableDictionary dictionaryWithDictionary:oldRow]];
isEditingRow = NO;
- }
+ }
else {
[tableFields removeObjectAtIndex:currentlyEditingRow];
isEditingRow = NO;
@@ -965,7 +979,7 @@ closes the keySheet
/**
* 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
+ * be called from within an endSheet selector. This should be called on
* the main thread.
*/
-(void)showErrorSheetWith:(NSDictionary *)errorDictionary
@@ -979,9 +993,9 @@ closes the keySheet
[self performSelector:@selector(showErrorSheetWith:) withObject:delayedErrorDictionary afterDelay:0.3];
return;
}
-
+
// Display the error sheet
- SPBeginAlertSheet([errorDictionary objectForKey:@"title"], NSLocalizedString(@"OK", @"OK button"),
+ SPBeginAlertSheet([errorDictionary objectForKey:@"title"], NSLocalizedString(@"OK", @"OK button"),
nil, nil, [tableDocumentInstance parentWindow], self, nil, nil,
[errorDictionary objectForKey:@"message"]);
}
@@ -990,21 +1004,21 @@ closes the keySheet
* This method is called as part of Key Value Observing which is used to watch for preference changes which effect the interface.
*/
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
-{
+{
// Display table veiew vertical gridlines preference changed
if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) {
[tableSourceView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
}
// Use monospaced fonts preference changed
else if ([keyPath isEqualToString:SPUseMonospacedFonts]) {
-
+
BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue];
-
+
for (NSTableColumn *fieldColumn in [tableSourceView tableColumns])
{
[[fieldColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
}
-
+
[tableSourceView reloadData];
}
}
@@ -1018,17 +1032,17 @@ closes the keySheet
if ([menuItem action] == @selector(removeField:)) {
return (([tableSourceView numberOfSelectedRows] == 1) && ([tableSourceView numberOfRows] > 1));
}
-
+
// Duplicate field
if ([menuItem action] == @selector(copyField:)) {
return ([tableSourceView numberOfSelectedRows] == 1);
}
-
+
// Reset AUTO_INCREMENT
if ([menuItem action] == @selector(resetAutoIncrement:)) {
return [indexesController validateMenuItem:menuItem];
}
-
+
return YES;
}
@@ -1059,7 +1073,7 @@ get the default value for a specified field
- (NSString *)defaultValueForField:(NSString *)field
{
if ( ![defaultValues objectForKey:field] ) {
- return [prefs objectForKey:SPNullValue];
+ return [prefs objectForKey:SPNullValue];
} else if ( [[defaultValues objectForKey:field] isMemberOfClass:[NSNull class]] ) {
return [prefs objectForKey:SPNullValue];
} else {
@@ -1075,18 +1089,18 @@ returns an array containing the field names of the selected table
NSMutableArray *tempArray = [NSMutableArray array];
NSEnumerator *enumerator;
id field;
-
+
//load table if not already done
if ( ![tablesListInstance structureLoaded] ) {
[self loadTable:[tablesListInstance tableName]];
}
-
+
//get field names
enumerator = [tableFields objectEnumerator];
while ( (field = [enumerator nextObject]) ) {
- [tempArray addObject:[field objectForKey:@"Field"]];
+ [tempArray addObject:[field objectForKey:@"name"]];
}
-
+
return [NSArray arrayWithArray:tempArray];
}
@@ -1100,42 +1114,42 @@ returns a dictionary containing enum/set field names as key and possible values
/**
* Returns a dictionary describing the source of the table to be used for printing purposes. The object accessible
- * via the key 'structure' is an array of the tables fields, where the first element is always the field names
+ * via the key 'structure' is an array of the tables fields, where the first element is always the field names
* and each subsequent element is the field data. This is also true for the table's indexes, which are accessible
* via the key 'indexes'.
*/
- (NSDictionary *)tableSourceForPrinting
-{
+{
NSInteger i, j;
NSMutableArray *tempResult = [NSMutableArray array];
NSMutableArray *tempResult2 = [NSMutableArray array];
-
+
NSString *nullValue = [prefs stringForKey:SPNullValue];
CFStringRef escapedNullValue = CFXMLCreateStringByEscapingEntities(NULL, ((CFStringRef)nullValue), NULL);
-
+
MCPResult *structureQueryResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [selectedTable backtickQuotedString]]];
MCPResult *indexesQueryResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW INDEXES FROM %@", [selectedTable backtickQuotedString]]];
-
+
[structureQueryResult setReturnDataAsStrings:YES];
[indexesQueryResult setReturnDataAsStrings:YES];
-
+
if ([structureQueryResult numOfRows]) [structureQueryResult dataSeek:0];
if ([indexesQueryResult numOfRows]) [indexesQueryResult dataSeek:0];
-
+
[tempResult addObject:[structureQueryResult fetchFieldNames]];
-
+
NSMutableArray *temp = [[indexesQueryResult fetchFieldNames] mutableCopy];
-
+
// Remove the 'table' column
[temp removeObjectAtIndex:0];
-
+
[tempResult2 addObject:temp];
-
+
[temp release];
-
+
for (i = 0; i < [structureQueryResult numOfRows]; i++) {
NSMutableArray *row = [[structureQueryResult fetchRowAsArray] mutableCopy];
-
+
// For every NULL value replace it with the user's NULL value placeholder so we can actually print it
for (j = 0; j < [row count]; j++)
{
@@ -1143,18 +1157,18 @@ returns a dictionary containing enum/set field names as key and possible values
[row replaceObjectAtIndex:j withObject:(NSString *)escapedNullValue];
}
}
-
+
[tempResult addObject:row];
-
+
[row release];
}
for (i = 0; i < [indexesQueryResult numOfRows]; i++) {
NSMutableArray *index = [[indexesQueryResult fetchRowAsArray] mutableCopy];
-
+
// Remove the 'table' column values
[index removeObjectAtIndex:0];
-
+
// For every NULL value replace it with the user's NULL value placeholder so we can actually print it
for (j = 0; j < [index count]; j++)
{
@@ -1162,9 +1176,9 @@ returns a dictionary containing enum/set field names as key and possible values
[index replaceObjectAtIndex:j withObject:(NSString *)escapedNullValue];
}
}
-
+
[tempResult2 addObject:index];
-
+
[index release];
}
@@ -1189,7 +1203,7 @@ returns a dictionary containing enum/set field names as key and possible values
[copyFieldButton setEnabled:NO];
[reloadFieldsButton setEnabled:NO];
[editTableButton setEnabled:NO];
-
+
[indexesTableView setEnabled:NO];
[addIndexButton setEnabled:NO];
[removeIndexButton setEnabled:NO];
@@ -1205,22 +1219,22 @@ returns a dictionary containing enum/set field names as key and possible values
if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableStructure]) return;
BOOL editingEnabled = ([tablesListInstance tableType] == SPTableTypeTable);
-
+
[tableSourceView setEnabled:YES];
[tableSourceView displayIfNeeded];
[addFieldButton setEnabled:editingEnabled];
-
+
if (editingEnabled && [tableSourceView numberOfSelectedRows] > 0) {
[removeFieldButton setEnabled:YES];
[copyFieldButton setEnabled:YES];
}
-
+
[reloadFieldsButton setEnabled:YES];
[editTableButton setEnabled:YES];
-
+
[indexesTableView setEnabled:YES];
[indexesTableView displayIfNeeded];
-
+
[addIndexButton setEnabled:editingEnabled];
[removeIndexButton setEnabled:(editingEnabled && ([indexesTableView numberOfSelectedRows] > 0))];
[refreshIndexesButton setEnabled:YES];
@@ -1235,10 +1249,34 @@ returns a dictionary containing enum/set field names as key and possible values
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
-{
+{
// Return a placeholder if the table is reloading
if (rowIndex >= [tableFields count]) return @"...";
+ if([[tableColumn identifier] isEqualToString:@"collation"]) {
+ if([[[tableFields objectAtIndex:rowIndex] objectForKey:@"encoding"] integerValue] > 0) {
+ NSString *enc = [[[[[tableSourceView tableColumns] objectAtIndex:10] dataCell] itemAtIndex:[[[tableFields objectAtIndex:rowIndex] objectForKey:@"encoding"] integerValue]] title];
+ NSInteger start = [enc rangeOfString:@"("].location+1;
+ NSInteger end = [enc length] - start - 1;
+ collations = [databaseDataInstance getDatabaseCollationsForEncoding:[enc substringWithRange:NSMakeRange(start, end)]];
+ } else {
+ if([tableDataInstance tableEncoding]) {
+ collations = [databaseDataInstance getDatabaseCollationsForEncoding:[tableDataInstance tableEncoding]];
+ } else {
+ collations = [NSArray array];
+ }
+ }
+
+ [[tableColumn dataCell] removeAllItems];
+
+ if ([collations count] > 0) {
+ [[tableColumn dataCell] addItemWithTitle:@""];
+ // Populate collation popup button
+ for (NSDictionary *collation in collations)
+ [[tableColumn dataCell] addItemWithTitle:[collation objectForKey:@"COLLATION_NAME"]];
+ }
+ }
+
return [[tableFields objectAtIndex:rowIndex] objectForKey:[tableColumn identifier]];
}
@@ -1252,7 +1290,7 @@ returns a dictionary containing enum/set field names as key and possible values
isEditingRow = YES;
currentlyEditingRow = rowIndex;
}
-
+
[[tableFields objectAtIndex:rowIndex] setObject:(anObject) ? anObject : @"" forKey:[aTableColumn identifier]];
}
@@ -1305,11 +1343,11 @@ would result in a position change.
// Ensure the drop is of the correct type
if (operation == NSTableViewDropAbove && row != -1 && [pboardTypes containsObject:@"SequelProPasteboard"]) {
-
+
// Ensure the drag originated within this table
if ([info draggingSource] == tableView) {
originalRow = [[[info draggingPasteboard] stringForType:@"SequelProPasteboard"] integerValue];
-
+
if (row != originalRow && row != (originalRow+1)) {
return NSDragOperationMove;
}
@@ -1339,58 +1377,55 @@ would result in a position change.
// Begin construction of the reordering query
queryString = [NSMutableString stringWithFormat:@"ALTER TABLE %@ MODIFY COLUMN %@ %@", [selectedTable backtickQuotedString],
- [[originalRow objectForKey:@"Field"] backtickQuotedString],
- [originalRow objectForKey:@"Type"]];
+ [[originalRow objectForKey:@"name"] backtickQuotedString],
+ [[originalRow objectForKey:@"type"] uppercaseString]];
// Add the length parameter if necessary
- if ( [originalRow objectForKey:@"Length"] && ![[originalRow objectForKey:@"Length"] isEqualToString:@""]) {
- [queryString appendFormat:@"(%@)", [originalRow objectForKey:@"Length"]];
+ if ( [originalRow objectForKey:@"length"] && ![[originalRow objectForKey:@"length"] isEqualToString:@""]) {
+ [queryString appendFormat:@"(%@)", [originalRow objectForKey:@"length"]];
}
// Add unsigned, zerofill, binary, not null if necessary
- if ([[originalRow objectForKey:@"unsigned"] isEqualToString:@"1"]) {
+ if ([[originalRow objectForKey:@"unsigned"] integerValue]) {
[queryString appendString:@" UNSIGNED"];
}
- if ([[originalRow objectForKey:@"zerofill"] isEqualToString:@"1"]) {
+ if ([[originalRow objectForKey:@"zerofill"] integerValue]) {
[queryString appendString:@" ZEROFILL"];
}
- if ([[originalRow objectForKey:@"binary"] isEqualToString:@"1"]) {
+ if ([[originalRow objectForKey:@"binary"] integerValue]) {
[queryString appendString:@" BINARY"];
}
- if ([[originalRow objectForKey:@"Null"] isEqualToString:@"0"] ) {
+ if (![[originalRow objectForKey:@"null"] integerValue]) {
[queryString appendString:@" NOT NULL"];
}
if (![[originalRow objectForKey:@"Extra"] isEqualToString:@"None"] ) {
[queryString appendString:@" "];
[queryString appendString:[[originalRow objectForKey:@"Extra"] uppercaseString]];
}
-
- BOOL isTimestampType = [[originalRow objectForKey:@"Type"] isEqualToString:@"timestamp"];
+
+ BOOL isTimestampType = [[[originalRow objectForKey:@"type"] lowercaseString] isEqualToString:@"timestamp"];
// Add the default value
- if ([[originalRow objectForKey:@"Default"] isEqualToString:[prefs objectForKey:SPNullValue]]) {
- if ([[originalRow objectForKey:@"Null"] integerValue] == 1) {
+ if ([[originalRow objectForKey:@"default"] isEqualToString:[prefs objectForKey:SPNullValue]]) {
+ if ([[originalRow objectForKey:@"null"] integerValue] == 1) {
[queryString appendString:(isTimestampType) ? @" NULL DEFAULT NULL" : @" DEFAULT NULL"];
}
- }
- else if (isTimestampType && ([[[originalRow objectForKey:@"Default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) ) {
+ }
+ else if (isTimestampType && ([[[originalRow objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) ) {
[queryString appendString:@" DEFAULT CURRENT_TIMESTAMP"];
- }
+ }
else {
- [queryString appendFormat:@" DEFAULT '%@'", [mySQLConnection prepareString:[originalRow objectForKey:@"Default"]]];
+ [queryString appendFormat:@" DEFAULT '%@'", [mySQLConnection prepareString:[originalRow objectForKey:@"default"]]];
}
- // Add details not provided via the SHOW COLUMNS query from the table data cache so column details aren't lost
- NSDictionary *originalColumnDetails = [[tableDataInstance columns] objectAtIndex:originalRowIndex];
-
// Any column comments
- if ([originalColumnDetails objectForKey:@"comment"] && [(NSString *)[originalColumnDetails objectForKey:@"comment"] length]) {
- [queryString appendFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[originalColumnDetails objectForKey:@"comment"]]];
+ if ([[originalRow objectForKey:@"comment"] length]) {
+ [queryString appendFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[originalRow objectForKey:@"comment"]]];
}
// Unparsed details - column formats, storage, reference definitions
- if ([originalColumnDetails objectForKey:@"unparsed"]) {
- [queryString appendString:[originalColumnDetails objectForKey:@"unparsed"]];
+ if ([originalRow objectForKey:@"unparsed"]) {
+ [queryString appendString:[originalRow objectForKey:@"unparsed"]];
}
// Add the new location
@@ -1398,12 +1433,12 @@ would result in a position change.
[queryString appendString:@" FIRST"];
} else {
[queryString appendFormat:@" AFTER %@",
- [[[tableFields objectAtIndex:destinationRowIndex-1] objectForKey:@"Field"] backtickQuotedString]];
+ [[[tableFields objectAtIndex:destinationRowIndex-1] objectForKey:@"name"] backtickQuotedString]];
}
// Run the query; report any errors, or reload the table on success
[mySQLConnection queryString:queryString];
-
+
if ([mySQLConnection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Error moving field", @"error moving field message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to move the field.\n\nMySQL said: %@", @"error moving field informative message"), [mySQLConnection getLastErrorMessage]]);
@@ -1423,7 +1458,7 @@ would result in a position change.
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
-
+
[originalRow release];
return YES;
}
@@ -1437,13 +1472,13 @@ would result in a position change.
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{
id object = [aNotification object];
-
+
// Check for which table view the selection changed
if (object == tableSourceView) {
-
+
// If we are editing a row, attempt to save that row - if saving failed, reselect the edit row.
if (isEditingRow && [tableSourceView selectedRow] != currentlyEditingRow && ![self saveRowOnDeselect]) return;
-
+
[copyFieldButton setEnabled:YES];
// Check if there is currently a field selected and change button state accordingly
@@ -1453,7 +1488,7 @@ would result in a position change.
[removeFieldButton setEnabled:NO];
[copyFieldButton setEnabled:NO];
}
-
+
// If the table only has one field, disable the remove button. This removes the need to check that the user
// is attempting to remove the last field in a table in removeField: above, but leave it in just in case.
if ([tableSourceView numberOfRows] == 1) {
@@ -1495,7 +1530,7 @@ would result in a position change.
}
}
return TRUE;
-
+
// Trap the enter key, triggering a save
}
else if ( [textView methodForSelector:command] == [textView methodForSelector:@selector(insertNewline:)] )
@@ -1503,7 +1538,7 @@ would result in a position change.
[[control window] makeFirstResponder:control];
[self addRowToDB];
return TRUE;
-
+
// Trap escape, aborting the edit and reverting the row
}
else if ( [[control window] methodForSelector:command] == [[control window] methodForSelector:@selector(_cancelKey:)] ||
@@ -1532,7 +1567,7 @@ would result in a position change.
* is uneditable.
*/
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {
-
+
//make sure that the message is from the right table view
if (tableView!=tableSourceView) return;
@@ -1558,7 +1593,7 @@ would result in a position change.
}
- (NSRect)splitView:(NSSplitView *)splitView additionalEffectiveRectOfDividerAtIndex:(NSInteger)dividerIndex
-{
+{
return [structureGrabber convertRect:[structureGrabber bounds] toView:splitView];
}
@@ -1569,7 +1604,7 @@ would result in a position change.
if ([tablesIndexesSplitView isSubviewCollapsed:indexesView]) {
[indexesShowButton setHidden:NO];
} else {
- [indexesShowButton setHidden:YES];
+ [indexesShowButton setHidden:YES];
}
}
}
@@ -1583,18 +1618,18 @@ would result in a position change.
#pragma mark Private API methods
/**
- * Removes a field from the current table and the dependent foreign key if specified.
+ * Removes a field from the current table and the dependent foreign key if specified.
*/
- (void)_removeFieldAndForeignKey:(NSNumber *)removeForeignKey
-{
+{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+
// Remove the foreign key before the field if required
if ([removeForeignKey boolValue]) {
-
+
NSString *relationName = @"";
- NSString *field = [[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"Field"];
-
+ NSString *field = [[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"name"];
+
// Get the foreign key name
for (NSDictionary *constraint in [tableDataInstance getConstraints])
{
@@ -1606,42 +1641,42 @@ would result in a position change.
}
}
}
-
+
[mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ DROP FOREIGN KEY %@", [selectedTable backtickQuotedString], [relationName backtickQuotedString]]];
-
+
// Check for errors, but only if the query wasn't cancelled
if ([mySQLConnection queryErrored] && ![mySQLConnection queryCancelled]) {
NSMutableDictionary *errorDictionary = [NSMutableDictionary dictionary];
[errorDictionary setObject:NSLocalizedString(@"Unable to delete relation", @"error deleting relation message") forKey:@"title"];
[errorDictionary setObject:[NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to delete the relation '%@'.\n\nMySQL said: %@", @"error deleting relation informative message"), relationName, [mySQLConnection getLastErrorMessage]] forKey:@"message"];
[[self onMainThread] showErrorSheetWith:errorDictionary];
- }
+ }
}
-
+
// Remove field
[mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ DROP %@",
- [selectedTable backtickQuotedString], [[[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"Field"] backtickQuotedString]]];
-
+ [selectedTable backtickQuotedString], [[[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"name"] backtickQuotedString]]];
+
// Check for errors, but only if the query wasn't cancelled
if ([mySQLConnection queryErrored] && ![mySQLConnection queryCancelled]) {
NSMutableDictionary *errorDictionary = [NSMutableDictionary dictionary];
[errorDictionary setObject:NSLocalizedString(@"Error", @"error") forKey:@"title"];
[errorDictionary setObject:[NSString stringWithFormat:NSLocalizedString(@"Couldn't delete field %@.\nMySQL said: %@", @"message of panel when field cannot be deleted"),
- [[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"Field"],
+ [[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"name"],
[mySQLConnection getLastErrorMessage]] forKey:@"message"];
[[self onMainThread] showErrorSheetWith:errorDictionary];
- }
+ }
else {
[tableDataInstance resetAllData];
[tablesListInstance setStatusRequiresReload:YES];
[self loadTable:selectedTable];
-
+
// Mark the content table cache for refresh
[tablesListInstance setContentRequiresReload:YES];
}
-
+
[tableDocumentInstance endTask];
-
+
[pool drain];
}
@@ -1651,16 +1686,16 @@ would result in a position change.
* Dealloc.
*/
- (void)dealloc
-{
+{
[[NSNotificationCenter defaultCenter] removeObserver:self];
-
+
[tableFields release];
[oldRow release];
[enumFields release];
-
+
if (defaultValues) [defaultValues release];
if (selectedTable) [selectedTable release];
-
+
[super dealloc];
}
784'>4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164