-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Fix issue with PostgreSQL: org.postgresql.util.PSQLException #6050
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
Conversation
@nenaraab Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@nenaraab Thank you for signing the Contributor License Agreement! |
acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java
Outdated
Show resolved
Hide resolved
@rwinch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fast turnaround @nenaraab! Can you add tests for potential null value and to ensure it is converted to a String for non-string types?
acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java
Show resolved
Hide resolved
@rwinch
|
Thanks for the fast reply @nenaraab! Sorry for the confusion. I was not very clear. What I meant was to do something like this: String id = parentIdentity.getIdentifier() == null ?
null : parentIdentity.getIdentifier().toString() As for the testing I meant to add some tests that break before your changes and are fixed after the changes. Also add a test that validates that a null value is passed through if To make testing more realistic, I'd:
Then the tests could inject a Mock Thanks again for your help with this ticket! If you have any questions, don't hesitate to reach out. |
@rwinch But as Furthermore I've checked the ObjectIdentityImplTests thoroughly. All not null assertions according to the identifier are covered by tests. |
acl/src/test/java/org/springframework/security/acls/jdbc/JdbcAclServiceTests.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! You are right about not needing the null checks. I have provided feedback inline.
@rwinch Furthermore I've added integration tests (using hsql in-memory database) to test also a proper conversion of the fetched entries, and the find-children sql queries as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the tests @nenaraab! I have another round of feedback inline.
acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java
Outdated
Show resolved
Hide resolved
acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fast turnaround! I have provided feedback inline.
@@ -77,9 +78,14 @@ | |||
// =================================================================================================== | |||
|
|||
public JdbcAclService(DataSource dataSource, LookupStrategy lookupStrategy) { | |||
this(new JdbcTemplate(dataSource), lookupStrategy); | |||
Assert.notNull(dataSource, "DataSource required"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this assertion is not necessary because JdbcTemplate validates that the dataSource is not null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm so sorry!
this @Nullable
was missleading...
but you're right: the method afterPropertiesSet
raises an exception, so I've removed the assertion. Sorry for inconvenience...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. It is a bit confusing and due the fact there is also a default constructor.
Thanks for the fast turnaround!
When setup the acl tables as specified in the Spring.io documentation I have faced the following error on a PostgreSql database: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying. This is because the acl_object_identity.object_id_identity column is of type varchar(36) but it is not necessarily accessed with a value of type String. - JdbcAclService / JdbcMutableAclService: SQL query must match object_id_identity column specification - JdbcAclService: changed JdbcTemplate to JdbcOperations for testability - JdbcAclServiceTest: Increased test coverage, the integration tests using embedded db relates to this commit thomasdarimont@cd8d207 Fixes gh-5508
In which version is this fix available? |
You can see by looking at the commit hash - d1a754f. In the comment at the top, the versions are listed. Let me know if I can help further. |
Got it, so it is available since v5.2. Thanks @jzheaux |
When trying to use Spring Security ACL, I am facing the error: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying.
As recommended in the Spring.io documentation i've setup the acl tables in my PostgreSQL database, with column
acl_object_identity.object_id_identity
of typevarchar(36)
.IMHO the
object_id_identity
in thejdbcTemplate
method calls MUST always be passed as a character sequence.This relates to issue:
#5508