Skip to content

Exception when hstore key or value contains escaped characters #30

@jglapa

Description

@jglapa

Hi, it looks like "manually" inserted data(via psql) cannot be "parsed" by the extension.
Hstore allows for the keys and values to contain double quote character but upon parsing we'll get an error as the escape character is not properly handled.

Caused by IllegalStateException: net.kaleidos.hibernate.usertype.HstoreParseException: Error @8 : Cannot find comma as an end of the value

Executing this:

insert into test(hs) values(hstore(ARRAY['key','"value"']));
insert into test(hs) values(hstore(ARRAY['\key','value']));
insert into test(hs) values(hstore(ARRAY['''key'''','value']))

will result with the following in db:

"key"=>"\"value\""
"\\key"=>"value" 
"'key'"=>"value" 

Those ", ', \ sequences should be treated in a special way.

I guess this should be somehow handled in the HstoreParser.advanceQuoted or HstoreParser.advanceWord. Are there any bigger limitations or gotchas around this issue? I might try to face this bug.

Just to mention: currently the extension "corrupts" the data. If we insert a key with double quote character inside it will be convert to a single quote. This means if this string was a hstore key we wouldn't be able to look up the value having the original key.

Thanks!
PS.
Good job guys with the extension! Keep up the good work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions