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

PostgreSQL Name Case Issues When Generating Using JPADatabase #189

Open
InfoSec812 opened this issue Oct 8, 2021 · 2 comments
Open

PostgreSQL Name Case Issues When Generating Using JPADatabase #189

InfoSec812 opened this issue Oct 8, 2021 · 2 comments

Comments

@InfoSec812
Copy link

InfoSec812 commented Oct 8, 2021

I am generating jOOQ DAOs using JPADatabase in my example project

For some reason, when I try to create a new row/record using the DAO's insertReturningPrimary method, I get the following error:

09:00:20.253 [vert.x-eventloop-thread-1] ERROR com.redhat.runtimes.services.TodosServiceImpl - Column ID does not exist
java.util.NoSuchElementException: Column ID does not exist
	at io.vertx.sqlclient.Row.getValue(Row.java:65) ~[vertx-sql-client-4.1.4.jar:4.1.4]
	at io.github.jklingsporn.vertx.jooq.shared.reactive.AbstractReactiveVertxDAO.lambda$generatePostgresKeyConverter$1(AbstractReactiveVertxDAO.java:49) ~[vertx-jooq-shared-reactive-6.3.0.jar:?]

I have tried tweaking the Configuration to change how names/fields/schemas are rendered with respect to letter case, but it's pretty hit and miss (Mostly miss) so far. In my database, the column is id (lower case) and when jOOQ attempts to fetch the column is it asking for ID (upper case) at io.vertx.sqlclient.Row.getValue(Row.java:65) at which point it fails.

Any advice? If you would like to run the example project:

  1. Clone the repository
  2. Switch to the Issue-7-_-Debug_createTodo_operation branch: git checkout Issue-7-_-Debug_createTodo_operation
  3. Compile the code mvn clean compile
  4. Start the PostgreSQL Container (this uses a generated DDL script from the models module, so you MUST compile first) using docker-compose up in the root of the project
  5. Run the Vert.x application using mvn -pl modules/api clean compile vertx:run
  6. Access the Swagger UI
  7. Attempt to create a new Todo item using Swagger UI
@InfoSec812
Copy link
Author

Hmmm... Some more information... The actual insertion of the data in the table is successful, it is just the returning of the ID field which causes a problem.

@InfoSec812
Copy link
Author

This seems to be unrelated to the insertReturningPrimary and is instead related to the generated RowMapper which looks like:

public class RowMappers {

        private RowMappers(){}

        public static Function<Row,com.redhat.runtimes.data.access.tables.pojos.Todos> getTodosMapper() {
                return row -> {
                        com.redhat.runtimes.data.access.tables.pojos.Todos pojo = new com.redhat.runtimes.data.access.tables.pojos.Todos();
                        pojo.setId(row.getUUID("ID"));
                        pojo.setAuthor(row.getString("AUTHOR"));
                        pojo.setComplete(row.getBoolean("COMPLETE"));
                        pojo.setCreated(row.getLocalDateTime("CREATED"));
                        pojo.setDescription(row.getString("DESCRIPTION"));
                        pojo.setDuedate(row.getLocalDateTime("DUEDATE"));
                        pojo.setTitle(row.getString("TITLE"));
                        return pojo;
                };
        }

        public static Function<Row,com.redhat.runtimes.data.access.tables.pojos.Users> getUsersMapper() {
                return row -> {
                        com.redhat.runtimes.data.access.tables.pojos.Users pojo = new com.redhat.runtimes.data.access.tables.pojos.Users();
                        pojo.setId(row.getUUID("ID"));
                        pojo.setFamilyname(row.getString("FAMILYNAME"));
                        pojo.setGivenname(row.getString("GIVENNAME"));
                        pojo.setName(row.getString("NAME"));
                        pojo.setPreferredusername(row.getString("PREFERREDUSERNAME"));
                        return pojo;
                };
        }
}

The calls to row.getXXX() are using uppercase field names and those are not matching the field names from the PostgreSQL Reactive client which are in lower case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant