Search in sources :

Example 1 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class SelectQueryParser method apply.

@Override
public ColumnQueryParams apply(SelectQuery selectQuery, ColumnObserverParser observer) {
    Objects.requireNonNull(selectQuery, "selectQuery is required");
    Objects.requireNonNull(observer, "observer is required");
    Params params = Params.newParams();
    ColumnQuery columnQuery = getColumnQuery(params, selectQuery, observer);
    return new DefaultColumnQueryParams(columnQuery, params);
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) ColumnQueryParams(jakarta.nosql.column.ColumnQueryParams) Params(jakarta.nosql.Params)

Example 2 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameLike.

@Test
public void shouldSelectWhereNameLike() {
    String columnFamily = "columnFamily";
    String name = "Ada Lovelace";
    ColumnQuery query = select().from(columnFamily).where("name").like(name).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.LIKE, condition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(name, column.get());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Column(jakarta.nosql.column.Column) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 3 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class DefaultSelectQueryBuilderTest method shouldSelectLimit.

@Test
public void shouldSelectLimit() {
    String columnFamily = "columnFamily";
    ColumnQuery query = select().from(columnFamily).limit(10).build();
    assertTrue(query.getColumns().isEmpty());
    assertFalse(query.getCondition().isPresent());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(10L, query.getLimit());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Test(org.junit.jupiter.api.Test)

Example 4 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameBetween.

@Test
public void shouldSelectWhereNameBetween() {
    String columnFamily = "columnFamily";
    Number valueA = 10;
    Number valueB = 20;
    ColumnQuery query = select().from(columnFamily).where("name").between(valueA, valueB).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.BETWEEN, condition.getCondition());
    assertEquals("name", column.getName());
    assertThat(column.get(new TypeReference<List<Number>>() {
    }), Matchers.contains(10, 20));
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Column(jakarta.nosql.column.Column) TypeReference(jakarta.nosql.TypeReference) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Example 5 with ColumnQuery

use of jakarta.nosql.column.ColumnQuery in project jnosql-diana by eclipse.

the class DefaultSelectQueryBuilderTest method shouldSelectWhereNameEq.

@Test
public void shouldSelectWhereNameEq() {
    String columnFamily = "columnFamily";
    String name = "Ada Lovelace";
    ColumnQuery query = select().from(columnFamily).where("name").eq(name).build();
    ColumnCondition condition = query.getCondition().get();
    Column column = condition.getColumn();
    assertTrue(query.getColumns().isEmpty());
    assertEquals(columnFamily, query.getColumnFamily());
    assertEquals(Condition.EQUALS, condition.getCondition());
    assertEquals("name", column.getName());
    assertEquals(name, column.get());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Column(jakarta.nosql.column.Column) ColumnCondition(jakarta.nosql.column.ColumnCondition) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnQuery (jakarta.nosql.column.ColumnQuery)160 Test (org.junit.jupiter.api.Test)120 ColumnCondition (jakarta.nosql.column.ColumnCondition)64 Person (jakarta.nosql.tck.entities.Person)50 Column (jakarta.nosql.column.Column)35 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)30 ValueSource (org.junit.jupiter.params.provider.ValueSource)30 Pagination (jakarta.nosql.mapping.Pagination)27 ColumnEntity (jakarta.nosql.column.ColumnEntity)26 List (java.util.List)26 Collections.singletonList (java.util.Collections.singletonList)10 Value (jakarta.nosql.Value)8 ColumnQueryPagination (jakarta.nosql.mapping.column.ColumnQueryPagination)8 Arrays.asList (java.util.Arrays.asList)8 Params (jakarta.nosql.Params)7 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)7 ColumnPreparedStatement (jakarta.nosql.column.ColumnPreparedStatement)7 ColumnQueryParams (jakarta.nosql.column.ColumnQueryParams)7 ColumnTemplate (jakarta.nosql.mapping.column.ColumnTemplate)6 SelectQuery (jakarta.nosql.query.SelectQuery)6