diff options
author | Albert Choy <albert.choy@osii.com> | 2015-04-15 14:06:24 -0500 |
---|---|---|
committer | Albert Choy <albert.choy@osii.com> | 2015-04-15 14:06:24 -0500 |
commit | aae95db4ebb70b80d83b97cefe754dd5836bc25c (patch) | |
tree | 158e32452e6445fcff84c0c5191c47e23cd9d13a | |
parent | bbae9bb8aacfc7d4923a4d29005d2d4a704371dd (diff) | |
download | ejdb-aae95db4ebb70b80d83b97cefe754dd5836bc25c.tar.gz ejdb-aae95db4ebb70b80d83b97cefe754dd5836bc25c.tar.bz2 ejdb-aae95db4ebb70b80d83b97cefe754dd5836bc25c.zip |
#129 query BSON_SYMBOL like BSON_STRING
Fix query handling to use BSON_IS_STRING_TYPE() to check for both string
and symbols.
-rw-r--r-- | src/ejdb/ejdb.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/ejdb/ejdb.c b/src/ejdb/ejdb.c index 5eabbfc..a3d363a 100644 --- a/src/ejdb/ejdb.c +++ b/src/ejdb/ejdb.c @@ -1794,10 +1794,11 @@ static bool _qrybsvalmatch(const EJQF *qf, bson_iterator *it, bool expandarrays, int sp; const char *fval; + // Feature #129: Handle BSON_SYMBOL like BSON_STRING #define _FETCHSTRFVAL() \ do { \ - fvalsz = (bt == BSON_STRING) ? bson_iterator_string_len(it) : 1; \ - fval = (bt == BSON_STRING) ? bson_iterator_string(it) : ""; \ + fvalsz = (BSON_IS_STRING_TYPE(bt)) ? bson_iterator_string_len(it) : 1; \ + fval = (BSON_IS_STRING_TYPE(bt)) ? bson_iterator_string(it) : ""; \ if (bt == BSON_OID) { \ bson_oid_to_string(bson_iterator_oid(it), oidbuf); \ fvalsz = 25; \ @@ -1824,7 +1825,7 @@ static bool _qrybsvalmatch(const EJQF *qf, bson_iterator *it, bool expandarrays, switch (qf->tcop) { case TDBQCSTREQ: { _FETCHSTRFVAL(); - if ((qf->flags & EJCONDICASE) && (bt == BSON_STRING)) { + if ((qf->flags & EJCONDICASE) && (BSON_IS_STRING_TYPE(bt))) { cbufstrlen = tcicaseformat(fval, fvalsz - 1, sbuf, JBSTRINOPBUFFERSZ, &cbuf); if (cbufstrlen < 0) { _ejdbsetecode(qf->jb, cbufstrlen, __FILE__, __LINE__, __func__); @@ -1842,7 +1843,7 @@ static bool _qrybsvalmatch(const EJQF *qf, bson_iterator *it, bool expandarrays, } case TDBQCSTRINC: { _FETCHSTRFVAL(); - if ((qf->flags & EJCONDICASE) && (bt == BSON_STRING)) { + if ((qf->flags & EJCONDICASE) && (BSON_IS_STRING_TYPE(bt))) { cbufstrlen = tcicaseformat(fval, fvalsz - 1, sbuf, JBSTRINOPBUFFERSZ, &cbuf); if (cbufstrlen < 0) { _ejdbsetecode(qf->jb, cbufstrlen, __FILE__, __LINE__, __func__); @@ -1860,7 +1861,7 @@ static bool _qrybsvalmatch(const EJQF *qf, bson_iterator *it, bool expandarrays, } case TDBQCSTRBW: { _FETCHSTRFVAL(); - if ((qf->flags & EJCONDICASE) && (bt == BSON_STRING)) { + if ((qf->flags & EJCONDICASE) && (BSON_IS_STRING_TYPE(bt))) { cbufstrlen = tcicaseformat(fval, fvalsz - 1, sbuf, JBSTRINOPBUFFERSZ, &cbuf); if (cbufstrlen < 0) { _ejdbsetecode(qf->jb, cbufstrlen, __FILE__, __LINE__, __func__); @@ -1878,7 +1879,7 @@ static bool _qrybsvalmatch(const EJQF *qf, bson_iterator *it, bool expandarrays, } case TDBQCSTREW: { _FETCHSTRFVAL(); - if ((qf->flags & EJCONDICASE) && (bt == BSON_STRING)) { + if ((qf->flags & EJCONDICASE) && (BSON_IS_STRING_TYPE(bt))) { cbufstrlen = tcicaseformat(fval, fvalsz - 1, sbuf, JBSTRINOPBUFFERSZ, &cbuf); if (cbufstrlen < 0) { _ejdbsetecode(qf->jb, cbufstrlen, __FILE__, __LINE__, __func__); @@ -1898,7 +1899,7 @@ static bool _qrybsvalmatch(const EJQF *qf, bson_iterator *it, bool expandarrays, TCLIST *tokens = qf->exprlist; assert(tokens); _FETCHSTRFVAL(); - if ((qf->flags & EJCONDICASE) && (bt == BSON_STRING)) { + if ((qf->flags & EJCONDICASE) && (BSON_IS_STRING_TYPE(bt))) { cbufstrlen = tcicaseformat(fval, fvalsz - 1, sbuf, JBSTRINOPBUFFERSZ, &cbuf); if (cbufstrlen < 0) { _ejdbsetecode(qf->jb, cbufstrlen, __FILE__, __LINE__, __func__); @@ -1918,7 +1919,7 @@ static bool _qrybsvalmatch(const EJQF *qf, bson_iterator *it, bool expandarrays, TCLIST *tokens = qf->exprlist; assert(tokens); _FETCHSTRFVAL(); - if ((qf->flags & EJCONDICASE) && (bt == BSON_STRING)) { + if ((qf->flags & EJCONDICASE) && (BSON_IS_STRING_TYPE(bt))) { cbufstrlen = tcicaseformat(fval, fvalsz - 1, sbuf, JBSTRINOPBUFFERSZ, &cbuf); if (cbufstrlen < 0) { _ejdbsetecode(qf->jb, cbufstrlen, __FILE__, __LINE__, __func__); @@ -1938,7 +1939,7 @@ static bool _qrybsvalmatch(const EJQF *qf, bson_iterator *it, bool expandarrays, TCLIST *tokens = qf->exprlist; assert(tokens); _FETCHSTRFVAL(); - if ((qf->flags & EJCONDICASE) && (bt == BSON_STRING)) { + if ((qf->flags & EJCONDICASE) && (BSON_IS_STRING_TYPE(bt))) { cbufstrlen = tcicaseformat(fval, fvalsz - 1, sbuf, JBSTRINOPBUFFERSZ, &cbuf); if (cbufstrlen < 0) { _ejdbsetecode(qf->jb, cbufstrlen, __FILE__, __LINE__, __func__); @@ -1986,7 +1987,7 @@ static bool _qrybsvalmatch(const EJQF *qf, bson_iterator *it, bool expandarrays, TCLIST *tokens = qf->exprlist; assert(tokens); _FETCHSTRFVAL(); - if ((qf->flags & EJCONDICASE) && (bt == BSON_STRING)) { + if ((qf->flags & EJCONDICASE) && (BSON_IS_STRING_TYPE(bt))) { cbufstrlen = tcicaseformat(fval, fvalsz - 1, sbuf, JBSTRINOPBUFFERSZ, &cbuf); if (cbufstrlen < 0) { _ejdbsetecode(qf->jb, cbufstrlen, __FILE__, __LINE__, __func__); |