提交 3f382525 authored 作者: christian.peter.io's avatar christian.peter.io

Support for database paths with backslashes on non Windows systems.

上级 55e2d0c4
......@@ -19,7 +19,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Improved MS SQL Server and MySQL compatibility: support DELETE with TOP or LIMIT.
<li>Support for database paths with backslashes on non Windows systems.
</li><li>Improved MS SQL Server and MySQL compatibility: support DELETE with TOP or LIMIT.
</li><li>Support for COSH, SINH, and TANH functions.
</li><li>Support for the % operator (modulo) thanks to Noel Grandin.
</li><li>Issue 288: Some right outer join queries failed to produce the correct result or
......
......@@ -6,6 +6,7 @@
*/
package org.h2.engine;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
......@@ -126,6 +127,13 @@ public class ConnectionInfo implements Cloneable {
} else {
persistent = true;
}
if (persistent && !remote) {
if (File.separatorChar == '/') {
name = name.replace('\\', '/');
} else {
name = name.replace('/', '\\');
}
}
}
/**
......
......@@ -10,6 +10,7 @@ import org.h2.test.TestBase;
import org.h2.constant.ErrorCode;
import org.h2.engine.ConnectionInfo;
import java.io.File;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
......@@ -33,6 +34,7 @@ public class TestConnectionInfo extends TestBase {
public void test() throws Exception {
testConnectInitError();
testConnectionInfo();
testName();
}
private void testConnectInitError() throws Exception {
......@@ -68,5 +70,12 @@ public class TestConnectionInfo extends TestBase {
assertEquals("TRUE", connectionInfo.getProperty("IFEXISTS", ""));
assertEquals("undefined", connectionInfo.getProperty("CACHE_TYPE", "undefined"));
}
private void testName() throws Exception {
char differentFileSeparator = File.separatorChar == '/' ? '\\' : '/';
ConnectionInfo connectionInfo = new ConnectionInfo("testdb" + differentFileSeparator + "subdir");
File file = new File("testdb" + File.separatorChar + "subdir");
assertEquals(file.getCanonicalPath(), connectionInfo.getName());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论