Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blob values are not quoted #7

Closed
asgrim opened this issue Jul 12, 2022 · 3 comments
Closed

Blob values are not quoted #7

asgrim opened this issue Jul 12, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@asgrim
Copy link
Contributor

asgrim commented Jul 12, 2022

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]
@asgrim
Copy link
Contributor Author

asgrim commented Jul 12, 2022

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

@ppomes ppomes added bug Something isn't working labels Jul 12, 2022
ppomes added a commit that referenced this issue Jul 14, 2022
ppomes added a commit that referenced this issue Jul 14, 2022
@ppomes
Copy link
Owner

ppomes commented Jul 14, 2022

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

@asgrim
Copy link
Contributor Author

asgrim commented Jul 19, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants