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

Disallow non-parameterized queries for Bulk Copy API for batch insert #756

Merged
merged 22 commits into from
Jul 28, 2018

Conversation

peterbae
Copy link
Contributor

@peterbae peterbae commented Jul 23, 2018

As for the error messages, I am throwing an illegalArgumentException but it gets caught and gets turned into a logging message, so this part doesn't need translation into other languages.

@peterbae peterbae changed the title Not going to allow non-parameterized query + test Disallow non-parameterized queries Bulk Copy API for batch insert + test Jul 23, 2018
pstmt.addBatch();

pstmt.executeBatch();
throw new Exception("shouldn't come here.");
Copy link
Member

Choose a reason for hiding this comment

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

Can we throw "Test did not throw an exception when it was Expected" instead? I think there's existing tests that do this and we should be consistent.

@cheenamalhotra cheenamalhotra added this to the 7.0.0 milestone Jul 24, 2018
@codecov-io
Copy link

codecov-io commented Jul 24, 2018

Codecov Report

Merging #756 into dev will increase coverage by 0.08%.
The diff coverage is 59.22%.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev     #756      +/-   ##
============================================
+ Coverage     48.35%   48.43%   +0.08%     
- Complexity     2771     2806      +35     
============================================
  Files           116      116              
  Lines         27871    27853      -18     
  Branches       4631     4636       +5     
============================================
+ Hits          13476    13490      +14     
- Misses        12212    12225      +13     
+ Partials       2183     2138      -45
Flag Coverage Δ Complexity Δ
#JDBC42 47.7% <59.22%> (-0.13%) 2738 <22> (+11)
#JDBC43 48.31% <59.22%> (+0.09%) 2796 <22> (+30) ⬆️
Impacted Files Coverage Δ Complexity Δ
...oft/sqlserver/jdbc/SQLServerPreparedStatement.java 52.23% <59.22%> (-1.88%) 217 <22> (+6)
...in/java/com/microsoft/sqlserver/jdbc/Geometry.java 52.38% <0%> (-20.06%) 15% <0%> (-18%)
...n/java/com/microsoft/sqlserver/jdbc/Geography.java 52.38% <0%> (-17.7%) 15% <0%> (-18%)
...sqlserver/jdbc/SQLServerBulkBatchInsertRecord.java 40.39% <0%> (-2.65%) 25% <0%> (-2%)
...osoft/sqlserver/jdbc/SQLServerSpatialDatatype.java 85.38% <0%> (-0.88%) 290% <0%> (+33%)
...ncurrentlinkedhashmap/ConcurrentLinkedHashMap.java 38.36% <0%> (-0.44%) 42% <0%> (-1%)
...rc/main/java/com/microsoft/sqlserver/jdbc/dtv.java 62.43% <0%> (-0.12%) 0% <0%> (ø)
...om/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java 52.6% <0%> (ø) 262% <0%> (ø) ⬇️
...lserver/jdbc/SQLServerDataSourceObjectFactory.java 0% <0%> (ø) 0% <0%> (ø) ⬇️
... and 34 more

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 0fef350...b62d82a. Read the comment docs.

}

checkAdditionalQuery();

String destinationTableName = tableName;
SQLServerStatement stmt = (SQLServerStatement) connection.createStatement(ResultSet.TYPE_FORWARD_ONLY,
Copy link
Member

@cheenamalhotra cheenamalhotra Jul 25, 2018

Choose a reason for hiding this comment

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

Statement is created here, and closed in next try's finally block? Better to put it in the next try-with-resources block along with ResultSet and remove finally block as it will have no purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that try block is closing the resultset. this statement is closed during finally.

Copy link
Contributor

Choose a reason for hiding this comment

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

@peterbae , Why don't you just move statement creation to try-with-resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved.

@peterbae peterbae changed the title Disallow non-parameterized queries Bulk Copy API for batch insert + test Disallow non-parameterized queries for Bulk Copy API for batch insert Jul 26, 2018
@cheenamalhotra cheenamalhotra added this to Under Peer Review in MSSQL JDBC Jul 27, 2018
cheenamalhotra
cheenamalhotra previously approved these changes Jul 27, 2018
rene-ye
rene-ye previously approved these changes Jul 27, 2018
@peterbae peterbae dismissed stale reviews from rene-ye and cheenamalhotra via 2e80254 July 27, 2018 20:54
@@ -2514,9 +2605,17 @@ private boolean checkAndRemoveComments() {
localUserSQL = localUserSQL.substring(temp);
Copy link
Contributor

Choose a reason for hiding this comment

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

int temp = localUserSQL.indexOf("\n") + 2;

It should be +1 here, not +2.

@peterbae peterbae merged commit ca4558e into microsoft:dev Jul 28, 2018
MSSQL JDBC automation moved this from Under Peer Review to Closed/Merged PRs Jul 28, 2018
cheenamalhotra added a commit that referenced this pull request Jul 31, 2018
* Update Snapshot for upcoming RTW release v7.0.0

* Change order of logic for checking the condition for using Bulk Copy API (#736)

Fix | Change order of logic for checking the condition for using Bulk Copy API (#736)

* Update CHANGELOG.md

* Merge pull request #732 from cheenamalhotra/module (Export driver in automatic module)

Introduce Automatic Module Name in POM.

* Update CHANGELOG.md

* Change Sha1HashKey to CityHash128Key for generating PreparedStatement handle and metadata cache keys (#717)

* Change Sha1HashKey to CityHash128Key

* Formatted code

* Prepared statement performance fixes

1) Further speedups to prepared statement hashing

2) Caching of '?' chararacter positiobs in prepared statements to speed parameter substitution

* String compare for hash keys
added missing line for bulkcopy tests.

* comment change

* Move CityHash class to a separate file

* spacings fixes
cleaner code & logic

* Add | Adding useBulkCopyForBatchInsert property to Request Boundary methods (#739)

* Apply the collation name change to UTF8SupportTest

* Package changes for CityHash with license information (#740)

* Reformatted Code + Updated formatter (#742)

* Reformatted Code + Updated formatter

* Fix policheck issue with 'Country' keyword (#745)

* Adding a new test for beginRequest()/endRequest() (#746)

* Add | Adding a new test to notify the developers to consider beginRequest()/endRequest() when adding a new Connection API

* Fix | Fixes for issues reported by static analysis tools (SonarQube + Fortify) (#747)

* handle buffer reading

for invalid buffer input by user

* Revert "handle buffer reading"

This reverts commit 11e2bf4.

* updated javadocs (#754)

* fixed some typos in javadocs (#760)

* API and JavaDoc changes for Spatial Datatypes (#752)

Add | API and JavaDoc changes for Spatial Datatypes (#752)

* Disallow non-parameterized queries for Bulk Copy API for batch insert (#756)

fix | Disallow non-parameterized queries for Bulk Copy API for batch insert (#756)

* Formatting | Change scope of unwanted Public APIs + Code Format (#757)

* Fix unwanted Public APIs.
* Updated formatter to add new line to EOF + formatted project

* Release | Release 7.0 changelog and version update (#748)

* Updated Changelog + release version changes

* Changelog entry updated as per review.

* Updated changelog for new changes

* Terminology update: request boundary declaration APIs

* Trigger Appveyor

* Update Samples and add new samples for new features (#761)

* Update Samples and add new Samples for new features

* Update samples from Peter

* Updated JavaDocs

* Switch to block comment

* Update License copyright (#767)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MSSQL JDBC
  
Closed/Merged PRs
Development

Successfully merging this pull request may close these issues.

None yet

5 participants