a hack to handle boolean items in VBA with MS Access.
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Tue, 8 Nov 2016 22:54:56 +0000 (07:54 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sat, 21 Jan 2017 08:21:14 +0000 (17:21 +0900)
VBA seems to transform the where condition
a_boolean_item=True
into
("a_boolean_item" = 1)
which causes an ERROR:Operator does not exist boolean = integer .
Here transforms it into
("a_boolean_item"='1')
which seems safe in anyway.

convert.c

index 90a57b3ded59471c88a87e0da61356765fe8e916..0e7bd3750a14eb235a0f6257aa1a3f1ac5b461b2 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -3523,6 +3523,47 @@ inner_process_tokens(QueryParse *qp, QueryBuild *qb)
        }
        else
        {
+           /*
+            *  a hack to handle boolean items in VBA
+            *      with MS Access.
+            *  VBA seems to transform the where condition
+            *      a_boolean_item=True
+            *  into
+            *      ("a_boolean_item" = 1)
+            *  which causes an ERROR:Operator does not exist boolean = integer .
+            *  So transforms it into
+            *      ("a_boolean_item"='1')
+            *  here.
+            */
+           if (')' == oldchar &&
+               qb->conn->ms_jet &&
+               1 == qp->token_len &&
+               '1' == qp->token_save[0] &&
+               8 <= F_OldPos(qp))
+           {
+               const char *oldptr = F_OldPtr(qp);
+               int oldpos = F_OldPos(qp);
+
+               if (strncmp(oldptr - 5, "\" =", 3) == 0)
+               {
+                   int i;
+
+                   for (i = 6; i < oldpos - 1; i++)
+                   {
+                       if (oldptr[-i] == '"')
+                       {
+                           if (oldptr[-(i+1)] == '(')
+                           {
+                               F_NewPtr(qb)[-4] = '=';
+                               F_NewPtr(qb)[-3] = '\'';
+                               F_NewPtr(qb)[-2] = '1';
+                               F_NewPtr(qb)[-1] = '\'';
+                           }
+                           break;
+                       }
+                   }
+               }
+           }
            if (isspace((UCHAR) oldchar))
            {
                if (!qp->prev_token_end)