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

Fix for insert into Postgres String Array when strings contained " or \. #1889

Merged
merged 6 commits into from Oct 26, 2012

Conversation

Projects
None yet
2 participants
@hencjo
Contributor

hencjo commented Oct 26, 2012

Having quotes (") in a string in a Postgres Array caused the following exception. And backslashes in such string were stripped. -- Fixed.

Exception in thread "main" org.jooq.exception.DataAccessException: SQL [insert into "" () values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?::varchar[], ?, ?)]; ERROR: malformed array literal: "{"""this will not work"}"
at org.jooq.impl.Util.translate(Util.java:621)
at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:360)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:176)
at org.jooq.impl.InsertImpl.execute(InsertImpl.java:95)

Caused by: org.postgresql.util.PSQLException: ERROR: malformed array literal: "{"""this will not work"}"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381)
at org.jooq.impl.DataSourcePreparedStatement.execute(DataSourcePreparedStatement.java:86)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:219)
at org.jooq.impl.InsertQueryImpl.execute(InsertQueryImpl.java:487)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:172)
... 2 more

@lukaseder

This comment has been minimized.

Member

lukaseder commented Oct 26, 2012

Thanks for reporting this. This will be tracked as #1890. I'll review your suggested fix ASAP

lukaseder added a commit that referenced this pull request Oct 26, 2012

Merge pull request #1889 from hencjo/postgresql-insert-into-array-esc…
…aping-fix

Fix for insert into Postgres String Array when strings contained " or \.

@lukaseder lukaseder merged commit f70f5de into jOOQ:version-2.5.0-branch Oct 26, 2012

@lukaseder

This comment has been minimized.

Member

lukaseder commented Oct 26, 2012

Thanks again for the fix. Nice technique btw, checking in every detailed refactoring step!

@hencjo

This comment has been minimized.

Contributor

hencjo commented Oct 27, 2012

Thanks for the feedback! I was unsure if it was overkill, but it felt like I was doing more than just the fix, and then I felt like it should be explained.

I just stumbled on the blog you posted about it. Thanks :)

@lukaseder

This comment has been minimized.

Member

lukaseder commented Oct 27, 2012

Well, I had some feedback by a friend. Obviously, if there are several commits to a change, it may be harder to use git's bisect feature to detect the exact commit that may have caused a regression. But then again...

  1. jOOQ doesn't have regressions ;-) (just kidding)
  2. I really liked the fact that you explained the refactoring.

Since the change was done to a rather remote piece of code, cherry-picking 6x instead of 1x wasn't really a pain either...

So thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment