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

Queries returning arrays are being wrapped in Object[] #1004

Closed
cowwoc opened this issue Oct 11, 2014 · 1 comment
Closed

Queries returning arrays are being wrapped in Object[] #1004

cowwoc opened this issue Oct 11, 2014 · 1 comment
Labels
bug
Milestone

Comments

@cowwoc
Copy link
Contributor

@cowwoc cowwoc commented Oct 11, 2014

If a user invokes:

QAuthentication a = QAuthentication.authentication;
List<byte[]> foo = session.query(a).where(a.userId.eq(userId)).list(a.id);

where a.id is of type byte[] then the Query returns the wrong type. Instead of a List<byte[]> it returns a List<Object[]> where the list contains a Object[] and that array, in turn, contains byte[] per element. What is more confusing is that the above code does not generate a compile-time error.

Expected behavior: Query should return a List<byte[]>.

I believe you can fix this issue by doing the following:

AbstractSQLQuery:257 reads;

                        while (rs.next()) {
                            Object[] row = new Object[rs.getMetaData().getColumnCount()];
                            if (getLastCell) {
                                lastCell = rs.getObject(row.length);
                                getLastCell = false;
                            }
                            for (int i = 0; i < row.length; i++) {
                                row[i] = rs.getObject(i+1);
                            }
                            rv.add((RT)row);
                        }

I would replace it with the following code:

                        while (rs.next()) {
                            if (getLastCell) {
                                lastCell = rs.getObject(row.length);
                                getLastCell = false;
                            }
                            for (int i = 0; i < row.length; i++) {
                                rv.add((RT)rs.getObject(i+1));
                            }
                        }
@timowest
Copy link
Member

@timowest timowest commented Oct 12, 2014

This part was originally a wildcard detection. I added a PR which does the detection properly.

@timowest timowest added this to the 3.5.1 milestone Oct 12, 2014
@timowest timowest added the bug label Oct 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.