use column labels

main 1.2.0
Jörg Prante 12 months ago
parent f8d1200314
commit 26bbb56b35

@ -1,5 +1,5 @@
group = org.xbib
name = database
version = 1.1.0
version = 1.2.0
org.gradle.warning.mode = ALL

@ -1,6 +1,7 @@
package org.xbib.jdbc.oracle.test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@ -10,6 +11,7 @@ import org.xbib.jdbc.query.Config;
import org.xbib.jdbc.query.ConfigSupplier;
import org.xbib.jdbc.query.DatabaseProvider;
import org.xbib.jdbc.query.OptionsOverride;
import org.xbib.jdbc.query.Schema;
import org.xbib.jdbc.test.CommonTest;
/**
@ -64,4 +66,16 @@ public class OracleTest extends CommonTest {
public void argDoubleNegativeZero() {
super.argDoubleNegativeZero();
}
@Override
@Test
public void metadataColumnNames() {
db.dropTableQuietly("dbtest");
new Schema().addTable("dbtest").addColumn("pk").primaryKey().schema().execute(db);
db.toSelect("select Pk, Pk as Foo, Pk as \"Foo\" from dbtest")
.query(rs -> {
Assertions.assertArrayEquals(new String[]{"PK", "FOO", "Foo"}, rs.getColumnLabels());
return null;
});
}
}

@ -338,13 +338,13 @@ public class DatabaseImpl implements Database {
Table table = new Table();
sql.query(rows -> {
ResultSetMetaData md = rows.getMetadata();
List<Object> columnNames = new ArrayList<>();
List<Object> columnLabels = new ArrayList<>();
List<Object> classNames = new ArrayList<>();
for (int i = 1; i <= md.getColumnCount(); i++) {
columnNames.add(md.getColumnName(i).toLowerCase(Locale.ROOT));
columnLabels.add(md.getColumnLabel(i));
classNames.add(md.getColumnClassName(i));
}
table.add(columnNames);
table.add(columnLabels);
table.add(classNames);
int i = 0;
while (rows.next() && (limit <= 0 || i++ < limit)) {

@ -25,7 +25,7 @@ public class Schema {
private final List<Sequence> sequences;
private boolean indexForeignKeys = true;
private boolean indexForeignKeys;
private String userTableName;

Loading…
Cancel
Save