use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method schemaFromDefault.
@Test
void schemaFromDefault() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").build();
Table<NameInAnnotation> result = database.table(NameInAnnotation.class);
assertThat(result.qualifiedName(), is("DEFAULT_SCHEMA.NAME_IN_ANNOTATION"));
}
use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method notUpdatableFromAnnotation.
@Test
void notUpdatableFromAnnotation() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").build();
String updateSql = database.table(IdAnnotation.class).columns().flatMap(Column::updateSql).collect(joining(", "));
assertThat(database.table(IdAnnotation.class).column(IdAnnotation::id).updatable(), is(false));
assertThat(database.table(IdAnnotation.class).column(IdAnnotation::name).updatable(), is(true));
assertThat(database.table(IdAnnotation.class).column(IdAnnotation::insertTime).updatable(), is(false));
assertThat(database.table(IdAnnotation.class).column(IdAnnotation::updateTime).updatable(), is(true));
assertThat(updateSql, is("NAME = ?, UPDATE_TIME = ?"));
}
use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method nameFromAnnotation.
@Test
void nameFromAnnotation() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").build();
Table<NameInAnnotation> result = database.table(NameInAnnotation.class);
assertThat(result.qualifiedName(), is("DEFAULT_SCHEMA.NAME_IN_ANNOTATION"));
}
use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method nameFromClassName.
@Test
void nameFromClassName() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").table(NameInAnnotation.class, t -> t.tableName("NAME_IN_BUILDER")).build();
Table<NoAnnotations> result = database.table(NoAnnotations.class);
assertThat(result.qualifiedName(), is("DEFAULT_SCHEMA.NO_ANNOTATIONS"));
}
use of com.cadenzauk.siesta.Database in project siesta by cadenzauk.
the class TableBuilderTest method embeddedIdFromAnnotation.
@Test
void embeddedIdFromAnnotation() {
Database database = Database.newBuilder().defaultSchema("DEFAULT_SCHEMA").build();
Alias<EmbeddedIdAnnotation> alias = database.table(EmbeddedIdAnnotation.class).as("t");
String idSql = database.table(EmbeddedIdAnnotation.class).columns().flatMap(c -> c.idSql(alias)).collect(joining(" and "));
assertThat(idSql, is("t.KEY_IDENTIFIER = ? and t.KEY_VERSION = ?"));
}
Aggregations