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

Fix: do not use QuerySpec when SqlContractDefinitionStore#findAll() #1539

Conversation

paullatzelsperger
Copy link
Member

@paullatzelsperger paullatzelsperger commented Jun 24, 2022

What this PR changes/adds

Does not use a QuerySpec when executing SqlContractDefinitionStore#findAll, instead execute a plain SELECT * FROM....

Why it does that

all = no limits!

Linked Issue(s)

Closes #1515

Checklist

  • added appropriate tests?
  • performed checkstyle check locally?
  • added/updated copyright headers?
  • documented public classes/methods?
  • added/updated relevant documentation?
  • added relevant details to the changelog? (skip with label no-changelog)
  • formatted title correctly? (take a look at the CONTRIBUTING and styleguide for details)

@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2022

Codecov Report

Merging #1539 (a73fa53) into main (385be86) will decrease coverage by 0.03%.
The diff coverage is 18.18%.

@@            Coverage Diff             @@
##             main    #1539      +/-   ##
==========================================
- Coverage   67.16%   67.12%   -0.04%     
==========================================
  Files         736      736              
  Lines       16139    16144       +5     
  Branches     1048     1050       +2     
==========================================
- Hits        10839    10836       -3     
- Misses       4823     4831       +8     
  Partials      477      477              
Impacted Files Coverage Δ
...actdefinition/InMemoryContractDefinitionStore.java 76.92% <ø> (-1.65%) ⬇️
...efinition/store/CosmosContractDefinitionStore.java 89.79% <ø> (-0.21%) ⬇️
.../contract/offer/store/ContractDefinitionStore.java 0.00% <ø> (ø)
...clipse/dataspaceconnector/spi/query/QuerySpec.java 78.33% <0.00%> (-12.06%) ⬇️
...ctdefinition/store/SqlContractDefinitionStore.java 85.54% <50.00%> (-0.18%) ⬇️
.../contract/offer/ContractDefinitionServiceImpl.java 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 385be86...a73fa53. Read the comment docs.

@paullatzelsperger paullatzelsperger force-pushed the bugfix/1515_pass_INTEGER_MAXVALUE_in_sql_contractdefstore branch from fd422b6 to bd98be1 Compare June 24, 2022 09:24
@@ -69,7 +69,15 @@ ContractDefinition mapResultSet(ResultSet resultSet) throws Exception {

@Override
public @NotNull Collection<ContractDefinition> findAll() {
return findAll(QuerySpec.none()).collect(Collectors.toList());
return transactionContext.execute(() -> {
Copy link
Member

Choose a reason for hiding this comment

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

I would make this more explicit as it was done in the SqlAssetIndex at line 132, passing to the other findAll method a QuerySpec instance with an insanely high limit value.
In this way the thing will be explicit (as I would expect this to change in the future), there will be no duplication and no SQL syntax will overflow in the store implementation

Copy link
Member Author

@paullatzelsperger paullatzelsperger Jun 24, 2022

Choose a reason for hiding this comment

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

There isn't really any duplication, there is just two (slightly) different SQL statements. In reality those two approaches would have the same effect, and once we have true pagination in IDS, we can remove the parameterless findAll() method completely. So I'd either leave it as is, because after all, it's a "true" findAll or remove the findAll altogether :)

What do you mean by "SQL syntax overflow"?

Copy link
Member

Choose a reason for hiding this comment

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

having a string with SELECT something FROM somewhere in the Store/Index, we never did that anywhere else, all the SQL stuff is in the Statements class

Copy link
Member Author

@paullatzelsperger paullatzelsperger Jun 24, 2022

Choose a reason for hiding this comment

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

ah got it what you mean. How about we remove findAll() altogether then, and provide a static method QuerySpec.max() that creates a QuerySpec with limit = Integer.MAX_VALUE?

Copy link
Member Author

Choose a reason for hiding this comment

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

this commit removes the parameterless findAll(). WDYT?

@paullatzelsperger paullatzelsperger force-pushed the bugfix/1515_pass_INTEGER_MAXVALUE_in_sql_contractdefstore branch from ec62ff0 to a73fa53 Compare June 24, 2022 12:54
Copy link
Member

@ndr-brt ndr-brt left a comment

Choose a reason for hiding this comment

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

Totally agree on findAll()'s inline. Good for me then

@paullatzelsperger paullatzelsperger merged commit cfba051 into eclipse-edc:main Jun 27, 2022
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.

SQL: Connector sends out 50 contract offers max.
4 participants