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

Add support for TDSType.GUID (#1582) #2324

Merged
merged 4 commits into from
Mar 20, 2024
Merged

Conversation

vxel
Copy link
Contributor

@vxel vxel commented Feb 8, 2024

This PR intends to provide support for sending UUID parameters as TDSType.GUID (0x24) on the wire and (hopefully) implements feature request #1582.
It currently requires the Java parameter be given to the driver as String with JDBCType.GUID, i.e. :

st.setObject(index, myUUID.toString(), microsoft.sql.Types.GUID);

@vxel
Copy link
Contributor Author

vxel commented Feb 9, 2024

@microsoft-github-policy-service agree company="Oniryx"

@vxel vxel changed the title Added support for TDSType.GUID (#1582) Add support for TDSType.GUID (#1582) Feb 9, 2024
@lilgreenbird
Copy link
Contributor

@vxel thank you for submitting this, the team will review this when time permits

@lilgreenbird
Copy link
Contributor

took a quick glance at this, please add tests covering the added feature, thanks!

@vxel
Copy link
Contributor Author

vxel commented Feb 9, 2024

took a quick glance at this, please add tests covering the added feature, thanks!

The code is already covered by the BatchExecutionWithBulkCopyTest.testNullGuid() and StatementTest.testJdbc41CallableStatementMethods() methods, so I wonder which kind of specific test you request.
I guess I can make tests similar to those in BigIntegerTest ?

@vxel
Copy link
Contributor Author

vxel commented Feb 9, 2024

I just pushed some specific tests

@tkyc
Copy link
Member

tkyc commented Feb 12, 2024

@vxel Thanks, I'll need to some testing on our private pipelines.

@lilgreenbird lilgreenbird linked an issue Feb 14, 2024 that may be closed by this pull request
@tkyc
Copy link
Member

tkyc commented Feb 14, 2024

Testing looks good from internal runs. A question more for the team, is there anywhere else that test can be placed rather than in a new test file?

@vxel
Copy link
Contributor Author

vxel commented Feb 14, 2024

Considering the test classes from the com.microsoft.sqlserver.jdbc.datatypes package, it seems the practice is to use individual test files for each "special" datatype, e.g. BigIntegerTest (for java.math.BigInteger), DateAndTimeTypeTest (for temporal datatypes), SQLServerSpatialDatatypeTest (for Geometry / Geography classes). Hence I guess adding a new test file for the java.util.UUID datatype is also suitable.
Another test file I considered was com.microsoft.sqlserver.jdbc.preparedStatement.SetObjectTest but the class is annotated with @Tag(Constants.xAzureSQLDW) which I guess would unnecessarily retrict the scope for my GUID tests.
I do not see alternatives but you certainly know the driver better than me.
Please tell me if you find a better place and I will move the test.

assertEquals(uuid, UUID.fromString(rs.getUniqueIdentifier(1)));
}

// Test NULL GUFID
Copy link
Contributor

Choose a reason for hiding this comment

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

typo?? same in line 81?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this is indeed a typo, copy-pasted to line 81... Thanks. This is fixed in my latest commit.

// Test Illegal GUFID
try {
pstmt.setObject(1, "garbage", Types.GUID);
fail("Must throw an IllegalArgumentException for this illegal UUID");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fail("Must throw an IllegalArgumentException for this illegal UUID");
fail(TestResource.getResource("R_expectedFailPassed"));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I applied your suggestion in the latest commit.

@lilgreenbird lilgreenbird added this to the 12.7.0 milestone Feb 28, 2024
@lilgreenbird lilgreenbird added the Enhancement An enhancement to the driver. Lower priority than bugs. label Feb 28, 2024
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 71.64179% with 19 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (main@9b5036d). Click here to learn what that means.

❗ Current head 10bbb16 differs from pull request most recent head 40b9ed9. Consider uploading reports for the commit 40b9ed9 to get more accurate results

Files Patch % Lines
.../microsoft/sqlserver/jdbc/SQLServerConnection.java 59.37% 5 Missing and 8 partials ⚠️
...m/microsoft/sqlserver/jdbc/SQLServerException.java 50.00% 0 Missing and 3 partials ⚠️
...rc/main/java/com/microsoft/sqlserver/jdbc/dtv.java 77.77% 1 Missing and 1 partial ⚠️
...oft/sqlserver/jdbc/SQLServerPreparedStatement.java 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2324   +/-   ##
=======================================
  Coverage        ?   50.12%           
  Complexity      ?     3788           
=======================================
  Files           ?      143           
  Lines           ?    33146           
  Branches        ?     5630           
=======================================
  Hits            ?    16614           
  Misses          ?    14147           
  Partials        ?     2385           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lilgreenbird lilgreenbird merged commit 9a8849b into microsoft:main Mar 20, 2024
17 checks passed
@vxel vxel deleted the feature/1582 branch March 21, 2024 17:10
tkyc added a commit that referenced this pull request Mar 25, 2024
lilgreenbird pushed a commit that referenced this pull request Mar 25, 2024
@Jeffery-Wasty
Copy link
Contributor

Hi @vxel,

This PR requires additional work to integrate fully with existing code. Unfortunately, this fact wasn't caught prior to merging. We've therefore reverted the PR, and will look at merging it again once we make the necessary changes.

@vxel
Copy link
Contributor Author

vxel commented Mar 26, 2024

Hi @Jeffery-Wasty
No problem, I'm sorry I missed this.
I wonder however why the CI did not catch this when I submitted the PR.
I will take a look at the issue.

@vxel
Copy link
Contributor Author

vxel commented Mar 26, 2024

Ok I see now that those tests require external setup and are disabled by default.
Unfortunately I'm unable to setup a suitable test environment to reproduce the problem. Hence it is hard for me to see how to fix it.

@vxel
Copy link
Contributor Author

vxel commented Mar 27, 2024

Ok I finally got a suitable environment and managed to reproduce the problem.
I think I can fix it. I'm preparing a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement An enhancement to the driver. Lower priority than bugs.
Projects
Status: Closed/Merged PRs
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] Allow sending UUID in binary to database
4 participants