Ok, compiled with driver 1.23.4 and have no more linking issues.
I noticed if I have docker_va_filter parameter, it throws:
Dec 06 22:32:49 mail postfix/proxymap[202]: fatal: bad string length 0 < 1: 
docker_va_query_filter = 

I think line 168 needs to be:
    dict_mongodb->query_filter = cfg_get_str(p, "query_filter", NULL, 0, 0);
for the fallback to work (from query_filter to filter).

The queries are not returning any results tho, need to do some more debugging...

> Only when config is specified in main.cf. Not when config
> is specified as in the current mongodb_table manpage.

True. From your's and Viktor's explanation, I understand that the
documentation is in the wrong place. I'll defer to you to move it
to the correct location, still a bit confused on where it should be.

>> now, in my case, I'm using a docker container, and am using parameters
>> in main.cf , a sample below:
>> docker_va_uri = $docker_dburi
>> docker_va_dbname = $docker_dbname
>> docker_va_collection = mailbox
>> docker_va_filter = {"$$or": [{"username":"%s"}, {"alias.address": "%s"}], 
>> "active": 1}
>> docker_va_result_attribute = username

Great, so at least I was using it right in my testing scenario. A bit
confused about Viktor's comment on how I am confusing the layers, but
I would need to learn more about postfix and I'm sure I'll figure that
out. Is there an example on how to do the parameterized config I can
look at?

> Here you have to duplicate the $. That leaves Viktor's question
> about placing quotes around "$or".

This is because bson_new_from_json is used. A proper JSON format is
required for this function to work, and that means $or should come
inside double quotes. If I do something like:

#include <bson/bson.h>
#include <mongoc/mongoc.h>

void main() {
        bson_error_t err;
        bson_t *obj = bson_new_from_json("{$or: [{\"a\": 1}, {\"a\": 2}]}", -1, 
&err);
        if (!obj) {
                printf("%s\n", err.message);
        }
        bson_destroy(obj);
}

and run the compiled binary, I will get:
Got parse error at "$", position 1: "SPECIAL_EXPECTED"

Changing the line to:
bson_t *obj = bson_new_from_json("{\"$or\": [{\"a\": 1}, {\"a\": 2}]}", -1, 
&err);

would resolve the issue.

Regards,
Hamid Maadani
_______________________________________________
Postfix-devel mailing list -- postfix-devel@postfix.org
To unsubscribe send an email to postfix-devel-le...@postfix.org

Reply via email to