Skip to content

Add getters on BoundStatement (JAVA-547)#305

Merged
olim7t merged 4 commits into
2.0from
java547
Mar 27, 2015
Merged

Add getters on BoundStatement (JAVA-547)#305
olim7t merged 4 commits into
2.0from
java547

Conversation

@olim7t

@olim7t olim7t commented Mar 24, 2015

Copy link
Copy Markdown
Contributor

Backport BoundStatement.get<Type>() from 2.1, and add a global getValues().

This is depended upon by JAVA-646 -- slow query logger (not for the feature itself, but for DataType#format that I also backported from 2.1).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder: wouldn't it be even more useful to return a LinkedHashMap<String,Object> where keys would be the parameter name and values the corresponding value? Implementation-wise the name is retrievable via metadata().getName(i); I'm suggesting LinkedHashMap to preserve the order in which parameters appear in the statement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: would it make sense to declare this method at GettableData interface level? An implementation in AbstractGettableData seems feasible and would benefit to the Row interface too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, both very good points. I need to check how names work when the query uses positional parameters, but IIRC they get generated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my experience positional parameters use original column names as parameter names - but indeed this detail needs to be double-checked.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but a column can also appear twice, which is where this is going to get complicated.

@olim7t

olim7t commented Mar 25, 2015

Copy link
Copy Markdown
Contributor Author

@adutra I've moved getValues to the GettableData interface. It's still a list because of the potential duplicate identifiers, if clients need more details they can downcast to Row or BoundStatement to get the ColumnDefinitions.
I also figured it would be a good time to add getObject since it's closely related.

@adutra

adutra commented Mar 25, 2015

Copy link
Copy Markdown
Contributor

@olim7t Awesome!

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

Successfully merging this pull request may close these issues.

2 participants