objectbox / objectbox-c

C and C++ database for objects and structs
https://objectbox.io/
Apache License 2.0
211 stars 37 forks source link

in filter does not support obx_id #42

Open black-inc-service opened 4 months ago

black-inc-service commented 4 months ago

Describe the bug Cannot use in filter with obx_id

Basic info (please complete the following information):

To Reproduce Steps to reproduce the behavior:

  1. Create vector of obx_id
  2. Pass vector to "in" filter
  3. Compiler error

Expected behavior Should be able to handle obx_id

Code

database.fbs - example
table Device {
    /// objectbox:id
    id                        : ulong;
    active                    : bool; 
} 
std::vector<obx_id> requestIDs = {1, 2, 9};
tableDevice_.query().with(Device_::id.in(requestIDs)).build().findUniquePtrs(); // Fails to compile

std::vector<int64_t> requestIDs = {1, 2, 9};
tableDevice_.query().with(Device_::id.in(requestIDs)).build().findUniquePtrs(); // Is ok

This is caused as the template implementation for uint64_t is missing and obx_id is unsigned 64bit

objectbox.h
typedef uint64_t obx_id;

For our system we do not have big obx_id values bigger than 9,223,372,036,854,775,807 but a unsigned/signed conversion must be made or implement our own template in objectbox.hpp