Java RethinkDB Expected type DATUM but found SELECTION

点点圈 提交于 2019-12-12 03:47:38

问题


I'm using RethinkDB driver for Java. I want to filter the rows without field endedAt in table jam like this:

public List<Jam> getCurrent(){
        Cursor cursor = r.table("jam")
                .filter(row -> row.hasFields("endedAt")).not()
                .run(conn);
        List<Map<String,Object>> list=cursor.toList();
        return list.stream().map(item->JamRepository.toJam(item)).collect(Collectors.toList());
    }

And I've got this error Expected type DATUM but found SELECTION Java

I have another filter function in another class:

public List<Speedlog> getByTime(long time){
        Cursor cursor = r.table("speedlog")
                .filter(row -> row.g("createdAt").eq(time))
                .run(conn);
        List<Map<String,Object>> list=cursor.toList();
        return list.stream().map(item->SpeedlogRepository.toSpeedlog(item)).collect(Collectors.toList());
    }

This function works properly

Could anyone please explain what makes the difference between these two? Why does getCurrent function get that error? What is its meaning and how to fix? Thank you


回答1:


not() should be right after row.hasFields("endedAt"). For now you are trying to call not() on the result of filter function. So, correct code:

public List<Jam> getCurrent(){
        Cursor cursor = r.table("jam")
                .filter(row -> row.hasFields("endedAt").not())
                .run(conn);
        List<Map<String,Object>> list=cursor.toList();
        return list.stream().map(item->JamRepository.toJam(item)).collect(Collectors.toList());
}


来源:https://stackoverflow.com/questions/40206697/java-rethinkdb-expected-type-datum-but-found-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!