diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-10-23 22:18:53 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-10-23 22:18:53 +0000 |
commit | c965b60b6ec45f56aa406296b5c35f48360f175a (patch) | |
tree | 68570c4682d74094247970ff6b1513bd07cefd95 | |
parent | a24ef7bf96e86d8e9ad7ee3ac9147dfca5cb810d (diff) | |
download | sequelpro-c965b60b6ec45f56aa406296b5c35f48360f175a.tar.gz sequelpro-c965b60b6ec45f56aa406296b5c35f48360f175a.tar.bz2 sequelpro-c965b60b6ec45f56aa406296b5c35f48360f175a.zip |
• CSV Import Field Mapper Sheet
- added the possibility to apply any sql function while importing set via "Add value or expression" sheet eg concat('$2', '$1', length('$3')) whereby $1 $2 $3 are the placeholder for the csv file columns 1 2 3 [first column starts with 1]
• fixed ' escaping issue in MCPConnection
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 2 | ||||
-rw-r--r-- | Interfaces/English.lproj/DataMigrationDialog.xib | 679 | ||||
-rw-r--r-- | Source/SPConstants.h | 1 | ||||
-rw-r--r-- | Source/SPConstants.m | 1 | ||||
-rw-r--r-- | Source/SPDataImport.m | 92 | ||||
-rw-r--r-- | Source/SPFieldMapperController.h | 4 | ||||
-rw-r--r-- | Source/SPFieldMapperController.m | 84 |
7 files changed, 839 insertions, 24 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index f503db55..48509969 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -2551,7 +2551,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) if (mysql_real_query(structConnection, queryCString, queryCStringLength) == 0) { // Query for procedures and functions - query = [NSString stringWithFormat:@"SELECT * FROM `information_schema`.`ROUTINES` WHERE `information_schema`.`ROUTINES`.`ROUTINE_SCHEMA` = '%@'", [currentDatabase stringByReplacingOccurrencesOfString:@"'" withString:@"\'"]]; + query = [NSString stringWithFormat:@"SELECT * FROM `information_schema`.`ROUTINES` WHERE `information_schema`.`ROUTINES`.`ROUTINE_SCHEMA` = '%@'", [currentDatabase stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]; encodedQueryData = NSStringDataUsingLossyEncoding(query, theConnectionEncoding, 1); queryCString = [encodedQueryData bytes]; queryCStringLength = [encodedQueryData length]; diff --git a/Interfaces/English.lproj/DataMigrationDialog.xib b/Interfaces/English.lproj/DataMigrationDialog.xib index 7d51439d..e5a56ef5 100644 --- a/Interfaces/English.lproj/DataMigrationDialog.xib +++ b/Interfaces/English.lproj/DataMigrationDialog.xib @@ -12,9 +12,7 @@ </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="422"/> - <integer value="12"/> - <integer value="508"/> + <integer value="516"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -53,7 +51,7 @@ <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{522, 348}</string> <object class="NSView" key="NSWindowView" id="78582513"> - <reference key="NSNextResponder"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">274</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1534,7 +1532,6 @@ </object> </object> <string key="NSFrameSize">{522, 348}</string> - <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1280, 778}}</string> <string key="NSMinSize">{522, 370}</string> @@ -1905,10 +1902,37 @@ <string key="NSAction">_popUpItemAction:</string> <reference key="NSTarget" ref="514571508"/> </object> + <object class="NSMenuItem" id="761836725"> + <reference key="NSMenu" ref="861436087"/> + <string key="NSTitle">Recent</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="884724275"/> + <reference key="NSMixedImage" ref="1071040955"/> + <string key="NSAction">submenuAction:</string> + <object class="NSMenu" key="NSSubmenu" id="786945285"> + <string key="NSTitle">Recent</string> + <object class="NSMutableArray" key="NSMenuItems"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + </object> + <object class="NSMenuItem" id="13254203"> + <reference key="NSMenu" ref="861436087"/> + <bool key="NSIsDisabled">YES</bool> + <bool key="NSIsSeparator">YES</bool> + <string key="NSTitle"/> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="884724275"/> + <reference key="NSMixedImage" ref="1071040955"/> + <string key="NSAction">_popUpItemAction:</string> + <reference key="NSTarget" ref="514571508"/> + </object> </object> <reference key="NSMenuFont" ref="388072550"/> </object> - <int key="NSSelectedIndex">2</int> + <int key="NSSelectedIndex">3</int> <bool key="NSPullDown">YES</bool> <int key="NSPreferredEdge">1</int> <bool key="NSUsesItemFromMenu">YES</bool> @@ -2967,6 +2991,30 @@ </object> <int key="connectionID">513</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">insertPullDownButton</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="813795773"/> + </object> + <int key="connectionID">514</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">recentGlobalValueMenu</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="786945285"/> + </object> + <int key="connectionID">519</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">insertPulldownValue:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="813795773"/> + </object> + <int key="connectionID">520</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -4186,6 +4234,8 @@ <reference ref="801605181"/> <reference ref="790556163"/> <reference ref="804071412"/> + <reference ref="761836725"/> + <reference ref="13254203"/> </object> <reference key="parent" ref="514571508"/> </object> @@ -4204,6 +4254,28 @@ <reference key="object" ref="804071412"/> <reference key="parent" ref="861436087"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">515</int> + <reference key="object" ref="761836725"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="786945285"/> + </object> + <reference key="parent" ref="861436087"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">516</int> + <reference key="object" ref="786945285"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <reference key="parent" ref="761836725"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">518</int> + <reference key="object" ref="13254203"/> + <reference key="parent" ref="861436087"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -4433,6 +4505,10 @@ <string>510.IBAttributePlaceholdersKey</string> <string>510.IBPluginDependency</string> <string>512.IBPluginDependency</string> + <string>515.IBPluginDependency</string> + <string>516.IBEditorWindowLastContentRect</string> + <string>516.IBPluginDependency</string> + <string>518.IBPluginDependency</string> <string>56.IBPluginDependency</string> <string>57.IBPluginDependency</string> <string>89.IBPluginDependency</string> @@ -4693,7 +4769,7 @@ <string>SPTableView</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="1"/> - <string>{{329, 527}, {303, 93}}</string> + <string>{{244, 372}, {303, 93}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -4782,7 +4858,7 @@ </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{119, 550}, {105, 47}}</string> + <string>{{119, 523}, {105, 74}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSMutableDictionary"> @@ -4796,9 +4872,13 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>{{224, 547}, {64, 6}}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{169, 564}, {465, 20}}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>{{446, 319}, {522, 20}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -4827,7 +4907,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">513</int> + <int key="maxID">520</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -7640,6 +7720,585 @@ </object> </object> </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">SPFieldMapperController</string> + <string key="superclassName">NSWindowController</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addGlobalSourceVariable:</string> + <string>addGlobalValue:</string> + <string>addNewColumn:</string> + <string>advancedCheckboxValidation:</string> + <string>changeFieldAlignment:</string> + <string>changeHasHeaderCheckbox:</string> + <string>changeImportMethod:</string> + <string>changeTableTarget:</string> + <string>closeGlobalValuesSheet:</string> + <string>closeInfoSheet:</string> + <string>closeSheet:</string> + <string>goBackToFileChooser:</string> + <string>insertNULLValue:</string> + <string>insertPulldownValue:</string> + <string>newTable:</string> + <string>newTableInfo:</string> + <string>openAdvancedSheet:</string> + <string>removeGlobalValue:</string> + <string>removeNewColumn:</string> + <string>setAllTypesTo:</string> + <string>stepRow:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="actionInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addGlobalSourceVariable:</string> + <string>addGlobalValue:</string> + <string>addNewColumn:</string> + <string>advancedCheckboxValidation:</string> + <string>changeFieldAlignment:</string> + <string>changeHasHeaderCheckbox:</string> + <string>changeImportMethod:</string> + <string>changeTableTarget:</string> + <string>closeGlobalValuesSheet:</string> + <string>closeInfoSheet:</string> + <string>closeSheet:</string> + <string>goBackToFileChooser:</string> + <string>insertNULLValue:</string> + <string>insertPulldownValue:</string> + <string>newTable:</string> + <string>newTableInfo:</string> + <string>openAdvancedSheet:</string> + <string>removeGlobalValue:</string> + <string>removeNewColumn:</string> + <string>setAllTypesTo:</string> + <string>stepRow:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBActionInfo"> + <string key="name">addGlobalSourceVariable:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">addGlobalValue:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">addNewColumn:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">advancedCheckboxValidation:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">changeFieldAlignment:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">changeHasHeaderCheckbox:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">changeImportMethod:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">changeTableTarget:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">closeGlobalValuesSheet:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">closeInfoSheet:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">closeSheet:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">goBackToFileChooser:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">insertNULLValue:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">insertPulldownValue:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">newTable:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">newTableInfo:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">openAdvancedSheet:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">removeGlobalValue:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">removeNewColumn:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">setAllTypesTo:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">stepRow:</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addGlobalValueButton</string> + <string>addNewColumnMenuItem</string> + <string>addRemainingDataSwitch</string> + <string>advancedBox</string> + <string>advancedButton</string> + <string>advancedInsertView</string> + <string>advancedLabel</string> + <string>advancedReplaceView</string> + <string>advancedUpdateView</string> + <string>alignByPopup</string> + <string>alignByPopupLabel</string> + <string>customQueryInstance</string> + <string>databaseDataInstance</string> + <string>delayedCheckBox</string> + <string>delayedReplaceCheckBox</string> + <string>fieldMapperTableScrollView</string> + <string>fieldMapperTableView</string> + <string>fieldMappingImportArray</string> + <string>fileSourcePath</string> + <string>globalValuesSheet</string> + <string>globalValuesTableView</string> + <string>highPriorityCheckBox</string> + <string>ignoreCheckBox</string> + <string>ignoreUpdateCheckBox</string> + <string>importButton</string> + <string>importFieldNamesHeaderSwitch</string> + <string>importMethodLabel</string> + <string>importMethodPopup</string> + <string>insertNULLValueButton</string> + <string>insertPullDownButton</string> + <string>lowPriorityCheckBox</string> + <string>lowPriorityReplaceCheckBox</string> + <string>lowPriorityUpdateCheckBox</string> + <string>matchingNameMenuItem</string> + <string>newTableButton</string> + <string>newTableInfoEncodingPopup</string> + <string>newTableInfoEnginePopup</string> + <string>newTableInfoWindow</string> + <string>newTableNameInfoButton</string> + <string>newTableNameLabel</string> + <string>newTableNameTextField</string> + <string>onupdateCheckBox</string> + <string>onupdateTextView</string> + <string>recentGlobalValueMenu</string> + <string>recordCountLabel</string> + <string>removeGlobalValueButton</string> + <string>replaceAfterSavingCheckBox</string> + <string>rowDownButton</string> + <string>rowUpButton</string> + <string>setAllTypesToMenuItem</string> + <string>skipexistingRowsCheckBox</string> + <string>tableTargetPopup</string> + <string>tablesListInstance</string> + <string>theDelegate</string> + <string>typeComboxBox</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSButton</string> + <string>NSMenuItem</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSPopUpButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>SPTableView</string> + <string>id</string> + <string>NSPathControl</string> + <string>id</string> + <string>NSTableView</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSPopUpButton</string> + <string>NSButton</string> + <string>NSPopUpButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSMenuItem</string> + <string>NSButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSButton</string> + <string>NSTextField</string> + <string>NSTextField</string> + <string>id</string> + <string>SPTextView</string> + <string>NSMenu</string> + <string>id</string> + <string>NSButton</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>NSMenuItem</string> + <string>id</string> + <string>NSPopUpButton</string> + <string>id</string> + <string>id</string> + <string>NSComboBoxCell</string> + </object> + </object> + <object class="NSMutableDictionary" key="toOneOutletInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>addGlobalValueButton</string> + <string>addNewColumnMenuItem</string> + <string>addRemainingDataSwitch</string> + <string>advancedBox</string> + <string>advancedButton</string> + <string>advancedInsertView</string> + <string>advancedLabel</string> + <string>advancedReplaceView</string> + <string>advancedUpdateView</string> + <string>alignByPopup</string> + <string>alignByPopupLabel</string> + <string>customQueryInstance</string> + <string>databaseDataInstance</string> + <string>delayedCheckBox</string> + <string>delayedReplaceCheckBox</string> + <string>fieldMapperTableScrollView</string> + <string>fieldMapperTableView</string> + <string>fieldMappingImportArray</string> + <string>fileSourcePath</string> + <string>globalValuesSheet</string> + <string>globalValuesTableView</string> + <string>highPriorityCheckBox</string> + <string>ignoreCheckBox</string> + <string>ignoreUpdateCheckBox</string> + <string>importButton</string> + <string>importFieldNamesHeaderSwitch</string> + <string>importMethodLabel</string> + <string>importMethodPopup</string> + <string>insertNULLValueButton</string> + <string>insertPullDownButton</string> + <string>lowPriorityCheckBox</string> + <string>lowPriorityReplaceCheckBox</string> + <string>lowPriorityUpdateCheckBox</string> + <string>matchingNameMenuItem</string> + <string>newTableButton</string> + <string>newTableInfoEncodingPopup</string> + <string>newTableInfoEnginePopup</string> + <string>newTableInfoWindow</string> + <string>newTableNameInfoButton</string> + <string>newTableNameLabel</string> + <string>newTableNameTextField</string> + <string>onupdateCheckBox</string> + <string>onupdateTextView</string> + <string>recentGlobalValueMenu</string> + <string>recordCountLabel</string> + <string>removeGlobalValueButton</string> + <string>replaceAfterSavingCheckBox</string> + <string>rowDownButton</string> + <string>rowUpButton</string> + <string>setAllTypesToMenuItem</string> + <string>skipexistingRowsCheckBox</string> + <string>tableTargetPopup</string> + <string>tablesListInstance</string> + <string>theDelegate</string> + <string>typeComboxBox</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBToOneOutletInfo"> + <string key="name">addGlobalValueButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">addNewColumnMenuItem</string> + <string key="candidateClassName">NSMenuItem</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">addRemainingDataSwitch</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedInsertView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedLabel</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedReplaceView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">advancedUpdateView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">alignByPopup</string> + <string key="candidateClassName">NSPopUpButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">alignByPopupLabel</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">customQueryInstance</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">databaseDataInstance</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">delayedCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">delayedReplaceCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">fieldMapperTableScrollView</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">fieldMapperTableView</string> + <string key="candidateClassName">SPTableView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">fieldMappingImportArray</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">fileSourcePath</string> + <string key="candidateClassName">NSPathControl</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">globalValuesSheet</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">globalValuesTableView</string> + <string key="candidateClassName">NSTableView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">highPriorityCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">ignoreCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">ignoreUpdateCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">importButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">importFieldNamesHeaderSwitch</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">importMethodLabel</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">importMethodPopup</string> + <string key="candidateClassName">NSPopUpButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">insertNULLValueButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">insertPullDownButton</string> + <string key="candidateClassName">NSPopUpButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">lowPriorityCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">lowPriorityReplaceCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">lowPriorityUpdateCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">matchingNameMenuItem</string> + <string key="candidateClassName">NSMenuItem</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">newTableButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">newTableInfoEncodingPopup</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">newTableInfoEnginePopup</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">newTableInfoWindow</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">newTableNameInfoButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">newTableNameLabel</string> + <string key="candidateClassName">NSTextField</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">newTableNameTextField</string> + <string key="candidateClassName">NSTextField</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">onupdateCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">onupdateTextView</string> + <string key="candidateClassName">SPTextView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">recentGlobalValueMenu</string> + <string key="candidateClassName">NSMenu</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">recordCountLabel</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">removeGlobalValueButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">replaceAfterSavingCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">rowDownButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">rowUpButton</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">setAllTypesToMenuItem</string> + <string key="candidateClassName">NSMenuItem</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">skipexistingRowsCheckBox</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">tableTargetPopup</string> + <string key="candidateClassName">NSPopUpButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">tablesListInstance</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">theDelegate</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">typeComboxBox</string> + <string key="candidateClassName">NSComboBoxCell</string> + </object> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBDocumentRelativeSource</string> + <string key="minorKey">../../Source/SPFieldMapperController.h</string> + </object> + </object> + </object> <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 0992cc1b..fd8c3af6 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -352,6 +352,7 @@ extern NSString *SPBlobTextEditorSpellCheckingEnabled; extern NSString *SPUniqueSchemaDelimiter; extern NSString *SPLastImportIntoNewTableEncoding; extern NSString *SPLastImportIntoNewTableType; +extern NSString *SPGlobalValueHistory; // URLs diff --git a/Source/SPConstants.m b/Source/SPConstants.m index b84c174f..3dadf8c4 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -179,6 +179,7 @@ NSString *SPBlobTextEditorSpellCheckingEnabled = @"BlobTextEditorSpellChecking NSString *SPUniqueSchemaDelimiter = @""; // U+FFF8 NSString *SPLastImportIntoNewTableEncoding = @"LastImportIntoNewTableEncoding"; NSString *SPLastImportIntoNewTableType = @"LastImportIntoNewTableType"; +NSString *SPGlobalValueHistory = @"GlobalValueHistory"; // URLs NSString *SPDonationsURL = @"http://www.sequelpro.com/donate.html"; diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index a1051c8c..61698b46 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -1259,6 +1259,7 @@ NSInteger mapColumn; id cellData; NSInteger mappingArrayCount = [fieldMappingArray count]; + NSString *re = @"(?<!\\\\)\\$(\\d+)"; for (i = 0; i < mappingArrayCount; i++) { @@ -1275,8 +1276,34 @@ // Append the data // - check for global values if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns) { - // Global variables are coming wrapped in ' ' if there're not marked as SQL - [setString appendString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)]; + NSMutableString *globalVar = [NSMutableString string]; + if([NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn) isKindOfClass:[NSNull class]]) { + [globalVar setString:@"NULL"]; + } else { + [globalVar setString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)]; + // Global variables are coming wrapped in ' ' if there're not marked as SQL. + // If global variable contains column placeholders $1 etc. replace them. + if([globalVar rangeOfString:@"$"].length && [globalVar isMatchedByRegex:re]) { + while([globalVar isMatchedByRegex:re]) { + [globalVar flushCachedRegexData]; + NSRange aRange = [globalVar rangeOfRegex:re capture:0L]; + NSInteger colIndex = [[globalVar substringWithRange:[globalVar rangeOfRegex:re capture:1L]] integerValue]; + if(colIndex > 0 && colIndex <= [csvRowArray count]) { + NSString *colStr = NSArrayObjectAtIndex(csvRowArray, colIndex-1); + // escape column string for ' or " if the char just before $… is a " or ' + if(aRange.location && [globalVar characterAtIndex:aRange.location-1] == '\'') + [globalVar replaceCharactersInRange:aRange withString:[colStr stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]; + else if(aRange.location && [globalVar characterAtIndex:aRange.location-1] == '"') + [globalVar replaceCharactersInRange:aRange withString:[colStr stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; + else + [globalVar replaceCharactersInRange:aRange withString:colStr]; + } else { + [globalVar replaceCharactersInRange:aRange withString:@""]; + } + } + } + } + [setString appendString:globalVar]; } else { cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn); @@ -1299,8 +1326,34 @@ // Append the data // - check for global values if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns) { - // Global variables are coming wrapped in ' ' if there're not marked as SQL - [whereString appendFormat:@"=%@", NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)]; + NSMutableString *globalVar = [NSMutableString string]; + if([NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn) isKindOfClass:[NSNull class]]) { + [globalVar setString:@"NULL"]; + } else { + [globalVar setString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)]; + // Global variables are coming wrapped in ' ' if there're not marked as SQL. + // If global variable contains column placeholders $1 etc. replace them. + if([globalVar rangeOfString:@"$"].length && [globalVar isMatchedByRegex:re]) { + while([globalVar isMatchedByRegex:re]) { + [globalVar flushCachedRegexData]; + NSRange aRange = [globalVar rangeOfRegex:re capture:0L]; + NSInteger colIndex = [[globalVar substringWithRange:[globalVar rangeOfRegex:re capture:1L]] integerValue]; + if(colIndex > 0 && colIndex <= [csvRowArray count]) { + NSString *colStr = NSArrayObjectAtIndex(csvRowArray, colIndex-1); + // escape column string for ' or " if the char just before $… is a " or ' + if(aRange.location && [globalVar characterAtIndex:aRange.location-1] == '\'') + [globalVar replaceCharactersInRange:aRange withString:[colStr stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]; + else if(aRange.location && [globalVar characterAtIndex:aRange.location-1] == '"') + [globalVar replaceCharactersInRange:aRange withString:[colStr stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; + else + [globalVar replaceCharactersInRange:aRange withString:colStr]; + } else { + [globalVar replaceCharactersInRange:aRange withString:@""]; + } + } + } + } + [whereString appendFormat:@"=%@", globalVar]; } else { cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn); @@ -1331,6 +1384,7 @@ NSInteger mapColumn; id cellData; NSInteger mappingArrayCount = [fieldMappingArray count]; + NSString *re = @"(?<!\\\\)\\$(\\d+)"; for (i = 0; i < mappingArrayCount; i++) { @@ -1344,8 +1398,34 @@ // Append the data // - check for global values if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns) { - // Global variables are coming wrapped in ' ' if there're not marked as SQL - [valueString appendString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)]; + NSMutableString *globalVar = [NSMutableString string]; + if([NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn) isKindOfClass:[NSNull class]]) { + [globalVar setString:@"NULL"]; + } else { + [globalVar setString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)]; + // Global variables are coming wrapped in ' ' if there're not marked as SQL. + // If global variable contains column placeholders $1 etc. replace them. + if([globalVar rangeOfString:@"$"].length && [globalVar isMatchedByRegex:re]) { + while([globalVar isMatchedByRegex:re]) { + [globalVar flushCachedRegexData]; + NSRange aRange = [globalVar rangeOfRegex:re capture:0L]; + NSInteger colIndex = [[globalVar substringWithRange:[globalVar rangeOfRegex:re capture:1L]] integerValue]; + if(colIndex > 0 && colIndex <= [csvRowArray count]) { + NSString *colStr = NSArrayObjectAtIndex(csvRowArray, colIndex-1); + // escape column string for ' or " if the char just before $… is a " or ' + if(aRange.location && [globalVar characterAtIndex:aRange.location-1] == '\'') + [globalVar replaceCharactersInRange:aRange withString:[colStr stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]; + else if(aRange.location && [globalVar characterAtIndex:aRange.location-1] == '"') + [globalVar replaceCharactersInRange:aRange withString:[colStr stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]]; + else + [globalVar replaceCharactersInRange:aRange withString:colStr]; + } else { + [globalVar replaceCharactersInRange:aRange withString:@""]; + } + } + } + } + [valueString appendString:globalVar]; } else { cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn); diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index 33b4a400..8a70df90 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -62,6 +62,8 @@ IBOutlet NSButton *removeGlobalValueButton; IBOutlet NSButton *insertNULLValueButton; IBOutlet id replaceAfterSavingCheckBox; + IBOutlet NSPopUpButton *insertPullDownButton; + IBOutlet NSMenu *recentGlobalValueMenu; IBOutlet id ignoreCheckBox; IBOutlet id ignoreUpdateCheckBox; @@ -175,6 +177,8 @@ - (IBAction)insertNULLValue:(id)sender; - (IBAction)closeGlobalValuesSheet:(id)sender; - (IBAction)advancedCheckboxValidation:(id)sender; +- (IBAction)insertPulldownValue:(id)sender; +- (IBAction)insertRecentGlobalValue:(id)sender; - (IBAction)newTable:(id)sender; - (IBAction)newTableInfo:(id)sender; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 1787c6f2..10afade0 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -280,10 +280,8 @@ { NSMutableArray *globals = [NSMutableArray array]; for(NSInteger i=0; i < [fieldMappingGlobalValues count]; i++) - if([[fieldMappingGlobalValuesSQLMarked objectAtIndex:i] boolValue]) + if([[fieldMappingGlobalValuesSQLMarked objectAtIndex:i] boolValue] || [[fieldMappingGlobalValues objectAtIndex:i] isKindOfClass:[NSNull class]]) [globals addObject:[fieldMappingGlobalValues objectAtIndex:i]]; - else if([[fieldMappingGlobalValues objectAtIndex:i] isKindOfClass:[NSNull class]]) - [globals addObject:[NSString stringWithFormat:@"'%@'", [fieldMappingGlobalValues objectAtIndex:i]]]; else [globals addObject:[NSString stringWithFormat:@"'%@'", [[fieldMappingGlobalValues objectAtIndex:i] stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]]; @@ -1053,6 +1051,35 @@ { addGlobalSheetIsOpen = YES; + // Init insert pulldown menu + + // Remove all dynamic menu items + while([insertPullDownButton numberOfItems] > 5) + [insertPullDownButton removeItemAtIndex:[insertPullDownButton numberOfItems]-1]; + + // Add recent global value menu + if([prefs objectForKey:SPGlobalValueHistory] && [[prefs objectForKey:SPGlobalValueHistory] isKindOfClass:[NSArray class]] && [[prefs objectForKey:SPGlobalValueHistory] count]) + for(id item in [prefs objectForKey:SPGlobalValueHistory]) + [recentGlobalValueMenu addItemWithTitle:item action:@selector(insertRecentGlobalValue:) keyEquivalent:@""]; + + // Add column placeholder + NSInteger i = 0; + if([fieldMappingImportArray count] && [[fieldMappingImportArray objectAtIndex:0] count]) { + for(id item in [fieldMappingImportArray objectAtIndex:0]) { + i++; + if ([item isNSNull]) { + [insertPullDownButton addItemWithTitle:[NSString stringWithFormat:@"%i. <%@>", i, [prefs objectForKey:SPNullValue]]]; + } else if ([item isSPNotLoaded]) { + [insertPullDownButton addItemWithTitle:[NSString stringWithFormat:@"%i. <%@>", i, @"DEFAULT"]]; + } else { + if([item length] > 20) + [insertPullDownButton addItemWithTitle:[NSString stringWithFormat:@"%i. %@…", i, [item substringToIndex:20]]]; + else + [insertPullDownButton addItemWithTitle:[NSString stringWithFormat:@"%i. %@", i, item]]; + } + } + } + [NSApp beginSheet:globalValuesSheet modalForWindow:[self window] modalDelegate:self @@ -1221,6 +1248,27 @@ } } +- (IBAction)insertPulldownValue:(id)sender +{ + + if([globalValuesTableView numberOfSelectedRows] != 1 || [globalValuesTableView editedRow] < 0) return; + + NSInteger index = [sender indexOfItem:[sender selectedItem]] - 4; + if([[[NSApp keyWindow] firstResponder] respondsToSelector:@selector(insertText:)]) + [[[NSApp keyWindow] firstResponder] insertText:[NSString stringWithFormat:@"$%ld", index]]; + +} + +- (IBAction)insertRecentGlobalValue:(id)sender +{ + + if([globalValuesTableView numberOfSelectedRows] != 1 || [globalValuesTableView editedRow] < 0) return; + + if([[[NSApp keyWindow] firstResponder] respondsToSelector:@selector(insertText:)]) + [[[NSApp keyWindow] firstResponder] insertText:[sender title]]; + +} + #pragma mark - #pragma mark Others @@ -1782,14 +1830,36 @@ } [self validateImportButton]; } - // Refresh table - // [aTableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.01]; } else if(aTableView == globalValuesTableView) { - if ([[aTableColumn identifier] isEqualToString:@"global_value"]) + if ([[aTableColumn identifier] isEqualToString:@"global_value"]) { + [fieldMappingGlobalValues replaceObjectAtIndex:(numberOfImportColumns + rowIndex) withObject:anObject]; - else if ([[aTableColumn identifier] isEqualToString:@"sql"]) + + // If anObject contains $1 etc. enable SQL checkbox + if([anObject isMatchedByRegex:@"(?<!\\\\)\\$\\d+"]) + [fieldMappingGlobalValuesSQLMarked replaceObjectAtIndex:(numberOfImportColumns + rowIndex) withObject:[NSNumber numberWithInteger:1]]; + + // Store anObject as recent global value if it's new + NSMutableArray *recents = [NSMutableArray array]; + if([prefs objectForKey:SPGlobalValueHistory] && [[prefs objectForKey:SPGlobalValueHistory] isKindOfClass:[NSArray class]] && [[prefs objectForKey:SPGlobalValueHistory] count]) + [recents setArray:[prefs objectForKey:SPGlobalValueHistory]]; + if([recents containsObject:anObject]) + [recents removeObject:anObject]; + [recents insertObject:anObject atIndex:0]; + while([recents count] > 20) + [recents removeObjectAtIndex:[recents count]-1]; + if([recents count]) + [prefs setObject:recents forKey:SPGlobalValueHistory]; + + // Re-init recent menu + [recentGlobalValueMenu removeAllItems]; + for(id item in recents) + [recentGlobalValueMenu addItemWithTitle:item action:@selector(insertRecentGlobalValue:) keyEquivalent:@""]; + + } else if ([[aTableColumn identifier] isEqualToString:@"sql"]) { [fieldMappingGlobalValuesSQLMarked replaceObjectAtIndex:(numberOfImportColumns + rowIndex) withObject:anObject]; + } } } |