Unverified 提交 6aaa1966 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #998 from katzyn/enum

Fix MVSecondaryIndex.convertToKey() for ENUM data type
...@@ -323,7 +323,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex { ...@@ -323,7 +323,7 @@ public final class MVSecondaryIndex extends BaseIndex implements MVIndex {
int idx = c.getColumnId(); int idx = c.getColumnId();
Value v = r.getValue(idx); Value v = r.getValue(idx);
if (v != null) { if (v != null) {
array[i] = v.convertTo(c.getType()); array[i] = v.convertTo(c.getType(), -1, null, null, c.getEnumerators());
} }
} }
array[keyColumns - 1] = ValueLong.get(r.getKey()); array[keyColumns - 1] = ValueLong.get(r.getKey());
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package org.h2.test.db; package org.h2.test.db;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -99,6 +100,9 @@ public class TestIndex extends TestBase { ...@@ -99,6 +100,9 @@ public class TestIndex extends TestBase {
conn.close(); conn.close();
deleteDb("index"); deleteDb("index");
// This test uses own connection
testEnumIndex();
} }
private void testOrderIndex() throws SQLException { private void testOrderIndex() throws SQLException {
...@@ -750,4 +754,27 @@ public class TestIndex extends TestBase { ...@@ -750,4 +754,27 @@ public class TestIndex extends TestBase {
assertEquals(1, testFunctionIndexCounter); assertEquals(1, testFunctionIndexCounter);
} }
private void testEnumIndex() throws SQLException {
if (config.memory || config.networked) {
return;
}
deleteDb("index");
String url = "jdbc:h2:" + getBaseDir() + "/index;DB_CLOSE_DELAY=0";
Connection conn = DriverManager.getConnection(url);
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT, V ENUM('A', 'B'), CONSTRAINT PK PRIMARY KEY(ID, V))");
stat.execute("INSERT INTO TEST VALUES (1, 'A'), (2, 'B')");
conn.close();
conn = DriverManager.getConnection(url);
stat = conn.createStatement();
stat.execute("DELETE FROM TEST WHERE V = 'A'");
stat.execute("DROP TABLE TEST");
conn.close();
deleteDb("index");
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论