Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove one set of surrounding single or double quotes from the data source value. This is needed because the connection string may have been built using the SQLiteConnectionStringBuilder class, which reuses connection string construction logic from inside the .NET Framwork itself. Fix for ticket [8c3bee31c8]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
7d432770a95cee8372b884d601428174 |
User & Date: | mistachkin 2012-08-28 01:03:03.387 |
References
2012-08-28
| ||
01:03 | • Closed ticket [8c3bee31c8]: cannot open database file name containing spaces when built by SQLiteConnectionStringBuilder plus 4 other changes artifact: ab66c99584 user: mistachkin | |
Context
2012-08-28
| ||
02:31 | Add links to the official NuGet packages to the download page. check-in: 9e12cdcbf9 user: mistachkin tags: trunk | |
01:03 | Remove one set of surrounding single or double quotes from the data source value. This is needed because the connection string may have been built using the SQLiteConnectionStringBuilder class, which reuses connection string construction logic from inside the .NET Framwork itself. Fix for ticket [8c3bee31c8]. check-in: 7d432770a9 user: mistachkin tags: trunk | |
2012-08-24
| ||
10:09 | Add doc comments for the ToFullPath connection string property. check-in: c9ec60e016 user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 | bool fullUri = false; string fileName; if (Convert.ToInt32(FindKey(opts, "Version", DefaultVersion.ToString()), CultureInfo.InvariantCulture) != DefaultVersion) throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture, "Only SQLite Version {0} is supported at this time", DefaultVersion)); fileName = FindKey(opts, "Data Source", DefaultDataSource); if (String.IsNullOrEmpty(fileName)) { fileName = FindKey(opts, "Uri", DefaultUri); if (String.IsNullOrEmpty(fileName)) { fileName = FindKey(opts, "FullUri", DefaultFullUri); | > | 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 | bool fullUri = false; string fileName; if (Convert.ToInt32(FindKey(opts, "Version", DefaultVersion.ToString()), CultureInfo.InvariantCulture) != DefaultVersion) throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture, "Only SQLite Version {0} is supported at this time", DefaultVersion)); fileName = FindKey(opts, "Data Source", DefaultDataSource); fileName = UnwrapFileName(fileName); if (String.IsNullOrEmpty(fileName)) { fileName = FindKey(opts, "Uri", DefaultUri); if (String.IsNullOrEmpty(fileName)) { fileName = FindKey(opts, "FullUri", DefaultFullUri); |
︙ | ︙ | |||
1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 | { if (pArg != IntPtr.Zero) Marshal.FreeHGlobal(pArg); } return rc; } /// <summary> /// Expand the filename of the data source, resolving the |DataDirectory| /// macro as appropriate. /// </summary> /// <param name="sourceFile">The database filename to expand</param> /// <param name="toFullPath"> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 | { if (pArg != IntPtr.Zero) Marshal.FreeHGlobal(pArg); } return rc; } /// <summary> /// Removes one set of surrounding single -OR- double quotes from the file /// name and returns the resulting file name. If the string is null, empty, /// or contains quotes that are not balanced, nothing is done and the original /// string will be returned. /// </summary> /// <param name="sourceFile">The database file name to process.</param> /// <returns>The modified database file name.</returns> private string UnwrapFileName(string sourceFile) { if (String.IsNullOrEmpty(sourceFile)) { // // NOTE: The string is null or empty, return it verbatim. // return sourceFile; } int length = sourceFile.Length; if (((sourceFile[0] == '\'') && (sourceFile[length - 1] == '\'')) || ((sourceFile[0] == '"') && (sourceFile[length - 1] == '"'))) { // // NOTE: Remove the first and last character. // return sourceFile.Substring(1, length - 2); } // // NOTE: No match, return the input string verbatim. // return sourceFile; } /// <summary> /// Expand the filename of the data source, resolving the |DataDirectory| /// macro as appropriate. /// </summary> /// <param name="sourceFile">The database filename to expand</param> /// <param name="toFullPath"> |
︙ | ︙ |
Added Tests/tkt-8c3bee31c8.eagle.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | ############################################################################### # # tkt-8c3bee31c8.eagle -- # # Written by Joe Mistachkin. # Released to the public domain, use at your own risk! # ############################################################################### package require Eagle package require Eagle.Library package require Eagle.Test runTestPrologue ############################################################################### package require System.Data.SQLite.Test runSQLiteTestPrologue ############################################################################### runTest {test tkt-8c3bee31c8-1.1 {built connection string quoting} -setup { unset -nocomplain dataSource o result } -body { set o [object create -alias System.Data.SQLite.SQLiteConnectionStringBuilder] foreach dataSource [list \ "C:\\test_path\\test.db" \ "/test_path/test.db" \ "C:\\test path\\test.db" \ "/test path/test.db" \ "C:\\test'path\\test.db" \ "/test'path/test.db"] { $o DataSource $dataSource lappend result [list $dataSource [$o ToString]] } set result } -cleanup { unset -nocomplain dataSource o result } -constraints {eagle monoBug28 command.sql compile.DATA SQLite\ System.Data.SQLite} -result {{{C:\test_path\test.db}\ {data source=C:\test_path\test.db}} {/test_path/test.db\ {data source=/test_path/test.db}} {{C:\test path\test.db} {data source="C:\test\ path\test.db"}} {{/test path/test.db} {data source="/test path/test.db"}}\ {{C:\test'path\test.db} {data source="C:\test'path\test.db"}}\ {/test'path/test.db {data source="/test'path/test.db"}}}} ############################################################################### runTest {test tkt-8c3bee31c8-1.2 {open single quoted file name} -setup { unset -nocomplain fileName o } -body { set fileName [appendArgs ' [file join [getDatabaseDirectory] \ tkt-8c3bee31c8-1.2.db] '] set o [object create -alias System.Data.SQLite.SQLiteConnection] $o ConnectionString [appendArgs "Data Source=" $fileName \;] $o Open; # NOTE: This command may throw an exception, failing the test. } -cleanup { unset -nocomplain fileName o } -constraints {eagle monoBug28 command.sql compile.DATA SQLite\ System.Data.SQLite} -result {}} ############################################################################### runTest {test tkt-8c3bee31c8-1.3 {open double quoted file name} -setup { unset -nocomplain fileName o } -body { set fileName [appendArgs \" [file join [getDatabaseDirectory] \ tkt-8c3bee31c8-1.3.db] \"] set o [object create -alias System.Data.SQLite.SQLiteConnection] $o ConnectionString [appendArgs "Data Source=" $fileName \;] $o Open; # NOTE: This command may throw an exception, failing the test. } -cleanup { unset -nocomplain fileName o } -constraints {eagle monoBug28 command.sql compile.DATA SQLite\ System.Data.SQLite} -result {}} ############################################################################### runSQLiteTestEpilogue runTestEpilogue |