Add columnNames to LimboResultSet

This commit is contained in:
김선우
2025-02-02 21:14:30 +09:00
parent 098da0794f
commit f6919f028e
4 changed files with 74 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
package org.github.tursodatabase.core;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Properties;
import org.github.tursodatabase.TestUtils;
@@ -28,4 +30,26 @@ class LimboStatementTest {
assertTrue(stmt.isClosed());
assertFalse(stmt.getResultSet().isOpen());
}
@Test
void test_initializeColumnMetadata() throws Exception {
runSql("CREATE TABLE users (name TEXT, age INT, country TEXT);");
runSql("INSERT INTO users VALUES ('seonwoo', 30, 'KR');");
final LimboStatement stmt = connection.prepare("SELECT * FROM users");
stmt.initializeColumnMetadata();
final LimboResultSet rs = stmt.getResultSet();
final String[] columnNames = rs.getColumnNames();
assertEquals(columnNames[0], "name");
assertEquals(columnNames[1], "age");
assertEquals(columnNames[2], "country");
}
private void runSql(String sql) throws Exception {
LimboStatement stmt = connection.prepare(sql);
while (stmt.execute()) {
stmt.execute();
}
}
}