+ "Column[name=baz,columnNumber=3,type=INTEGER,nullable=null,nativeType=null,columnSize=null], "
+ "Column[name=foo,columnNumber=4,type=VARCHAR,nullable=null,nativeType=null,columnSize=null]]",
Arrays.toString(table.getColumns()));
// first delete the manually created database!
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.dropTable(databaseName).execute();
}
});
table = dc.getDefaultSchema().getTableByName(databaseName);
assertNull(table);
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
Table table = callback.createTable(dc.getDefaultSchema(), databaseName).withColumn("foo")
.ofType(ColumnType.VARCHAR).withColumn("greeting").ofType(ColumnType.VARCHAR).execute();
assertEquals("[_id, _rev, foo, greeting]", Arrays.toString(table.getColumnNames()));
}
});
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.insertInto(databaseName).value("foo", "bar").value("greeting", "hello").execute();
callback.insertInto(databaseName).value("foo", "baz").value("greeting", "hi").execute();
}
});
DataSet ds = dc.query().from(databaseName).select("_id", "foo", "greeting").execute();
assertTrue(ds.next());
assertNotNull(ds.getRow().getValue(0));
assertEquals("bar", ds.getRow().getValue(1));
assertEquals("hello", ds.getRow().getValue(2));
assertTrue(ds.next());
assertNotNull(ds.getRow().getValue(0));
assertEquals("baz", ds.getRow().getValue(1));
assertEquals("hi", ds.getRow().getValue(2));
assertFalse(ds.next());
ds.close();
dc.executeUpdate(new UpdateScript() {
@Override
public void run(UpdateCallback callback) {
callback.update(databaseName).value("greeting", "howdy").where("foo").isEquals("baz").execute();
callback.update(databaseName).value("foo", "foo").where("foo").isEquals("bar").execute();