ppomes/myanon

Blob values are not quoted

asgrim opened this issue · 3 comments

Given the following config:

# Config file for test1.sql
secret = 'lapin'
stats  = 'no'

tables = {
   `lottypes` = {
     `int1`      = inthash 2
     `int2`      = fixed '9'
     `datetime1` = fixed '1970-01-01 12:00:00'
     `text1`     = texthash 5
     `text2`     = fixed null
     `blob1`     = fixed 'hello'
     `blob2`     = texthash 5
#      `blob3`     = fixed '\'hi\''
   }
}

When I run

build/main/myanon -f tests/test1.conf < tests/test1.sql

I expect to see see

INSERT INTO `lottypes` VALUES (... ,'hello','migez', ...);

But I actually see

INSERT INTO `lottypes` VALUES (... ,hello,migez, ...);

I tried quoting/escaping (by uncommenting the config line for blob3) , but I received the error:

Config parsing error at line 14: Syntax error - Unexpected [h]

A workaround is to use hex value directly, e.g.

    # ASCII value is "hello"
    `blob1`  = fixed '0x68656c6c6f'

since using an apostrophe ' is not required for this

Hi,

Myanon tries to deduce if quotes are needed or not, depending on field type. Your example showed it took the wrong decision for blob types. I fixed it and I modified the "test1/lottypes" test to reflect this change.

However, I also added a manual option to control quoting, in order to support your workaround as well. You can see the new option on the "test1/the_blobs" test.

Everything should work now, can you try the latest code? I will then update the docs.

Regards,
Pierre

Yes, that works fine, just needed to add unquoted :) thank you!