Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Handle null params in Spring Data Spanner #2448

Merged
merged 4 commits into from
Jun 25, 2020

Conversation

dmitry-s
Copy link
Contributor

fixes #2443

@dmitry-s dmitry-s requested review from dzou and meltsufin June 22, 2020 21:31
Copy link
Contributor

@dzou dzou left a comment

Choose a reason for hiding this comment

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

Minor nit: Just to rename the title of the PR to be more specific (null params for which service and in what context?) Looks good!

@@ -361,7 +361,8 @@ public static Statement buildStatementFromSqlWithArgs(String sql, List<String> t
private static void bindParameter(ValueBinder<Statement.Builder> bind,
Function<Object, Struct> paramStructConvertFunc, SpannerCustomConverter spannerCustomConverter,
Object originalParam, Parameter paramMetadata) {
if (ConversionUtils.isIterableNonByteArrayType(originalParam.getClass())) {
Class propType = originalParam != null ? originalParam.getClass() : paramMetadata.getType();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here about how you need to know the type of the parameter (even if you bind null) which is why the type information is relevant for null?

@dzou
Copy link
Contributor

dzou commented Jun 22, 2020

Gonna close my PR in favor of this one.

@meltsufin meltsufin changed the title handle null params Handle null params in Spring Data Spanner Jun 23, 2020
Copy link
Contributor

@meltsufin meltsufin left a comment

Choose a reason for hiding this comment

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

Looks good overall, but let's make sure we don't reduce the test coverage.

sqlSpannerQuery.execute(params);

verify(this.spannerTemplate, times(1)).executeQuery(any(), any());
}

@Test
public void multiplePageableSortTest() {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's replacing these 3 tests that you deleted?

dmitry-s and others added 2 commits June 23, 2020 13:16
…k/cloud/gcp/data/spanner/repository/it/SpannerRepositoryInsertIntegrationTests.java

Co-authored-by: Daniel Zou <dzou@users.noreply.github.com>
dzou
dzou previously approved these changes Jun 24, 2020
@dzou dzou dismissed their stale review June 24, 2020 01:02

Sorry didn't mean to yet

@dzou
Copy link
Contributor

dzou commented Jun 24, 2020

LGTM - only thing left is I think the build is broken.

@sonarcloud
Copy link

sonarcloud bot commented Jun 25, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

84.6% 84.6% Coverage
0.0% 0.0% Duplication

warning The version of Java (1.8.0_151) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more here

@codecov
Copy link

codecov bot commented Jun 25, 2020

Codecov Report

Merging #2448 into master will decrease coverage by 0.03%.
The diff coverage is 69.23%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2448      +/-   ##
============================================
- Coverage     74.13%   74.09%   -0.04%     
+ Complexity     2121     2118       -3     
============================================
  Files           264      264              
  Lines          7654     7652       -2     
  Branches        792      790       -2     
============================================
- Hits           5674     5670       -4     
+ Misses         1617     1614       -3     
- Partials        363      368       +5     
Flag Coverage Δ Complexity Δ
#unittests 74.09% <69.23%> (-0.04%) 2118.00 <6.00> (-3.00)
Impacted Files Coverage Δ Complexity Δ
...epository/query/SpannerStatementQueryExecutor.java 85.26% <60.00%> (-0.07%) 70.00 <4.00> (ø)
...data/spanner/repository/query/SqlSpannerQuery.java 81.89% <75.00%> (-3.15%) 26.00 <2.00> (-5.00)
.../core/convert/DefaultDatastoreEntityConverter.java 87.09% <0.00%> (ø) 24.00% <0.00%> (-1.00%)
...cp/autoconfigure/storage/GcpStorageProperties.java 100.00% <0.00%> (+25.00%) 4.00% <0.00%> (+3.00%)
...configure/storage/GcpStorageAutoConfiguration.java 46.66% <0.00%> (+34.16%) 1.00% <0.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 9bd57f8...98351d3. Read the comment docs.

@dmitry-s dmitry-s merged commit 60c6f29 into master Jun 25, 2020
@dmitry-s dmitry-s deleted the spanner-query-null-parameters branch June 25, 2020 21:04
@s13o
Copy link
Contributor

s13o commented Jul 22, 2020

Finally!
What is a planned release time?

@dmitry-s
Copy link
Contributor Author

@s13o
The next Spring Cloud release is scheduled for next week, but it can be delayed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

NullPointerException when passing the null value for nullable column
4 participants