Skip to content

Commit c9affd2

Browse files
authored
Fix AddProductColumnTypesTest for Java (#552)
* enable addproductcolumntypestest for java * add to known issues
1 parent 437ecd8 commit c9affd2

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Databases on SQL Server, Azure SQL Database, or Azure SQL Managed Instance which
4242

4343
- Output bindings against tables with columns of data types `NTEXT`, `TEXT`, or `IMAGE` are not supported and data upserts will fail. These types [will be removed](https://docs.microsoft.com/sql/t-sql/data-types/ntext-text-and-image-transact-sql) in a future version of SQL Server and are not compatible with the `OPENJSON` function used by this Azure Functions binding.
4444
- Input bindings against tables with columns of data types 'DATETIME', 'DATETIME2', or 'SMALLDATETIME' will assume that the values are in UTC format.
45+
- For Java Functions using Output bindings against a table with columns of data types 'DATETIME', 'DATETIME2', or 'SMALLDATETIME', use java.util.Date type to ensure the datetime is formatted correctly.
4546
- Trigger bindings will exhibit undefined behavior if the SQL table schema gets modified while the user application is running, for example, if a column is added, renamed or deleted or if the primary key is modified or deleted. In such cases, restarting the application should help resolve any errors.
4647

4748
## Telemetry

test/Integration/SqlOutputBindingIntegrationTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,13 @@ public void AddProductArrayTest(SupportedLanguages lang)
108108
}
109109

110110
/// <summary>
111-
/// Test compatability with converting various data types to their respective
111+
/// Test compatibility with converting various data types to their respective
112112
/// SQL server types.
113113
/// </summary>
114114
/// <param name="lang">The language to run the test against</param>
115115
[Theory]
116116
[SqlInlineData()]
117-
// This test is currrently failing in the Linux pipeline for Java
118-
// https://github.com/Azure/azure-functions-sql-extension/issues/521
119-
[UnsupportedLanguages(SupportedLanguages.Java, SupportedLanguages.PowerShell, SupportedLanguages.OutOfProc)]
117+
[UnsupportedLanguages(SupportedLanguages.PowerShell, SupportedLanguages.OutOfProc)]
120118
public void AddProductColumnTypesTest(SupportedLanguages lang)
121119
{
122120
this.StartFunctionHost(nameof(AddProductColumnTypes), lang, true);

test/Integration/test-java/src/main/java/com/function/AddProductColumnTypes.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import com.microsoft.azure.functions.sql.annotation.SQLOutput;
1818
import com.function.Common.ProductColumnTypes;
1919

20-
import java.sql.Timestamp;
20+
import java.sql.Date;
2121
import java.util.Optional;
2222

2323
public class AddProductColumnTypes {
@@ -35,8 +35,10 @@ public HttpResponseMessage run(
3535
connectionStringSetting = "SqlConnectionString")
3636
OutputBinding<ProductColumnTypes> product) {
3737

38-
ProductColumnTypes p = new ProductColumnTypes(0, new Timestamp(System.currentTimeMillis()),
39-
new Timestamp(System.currentTimeMillis()));
38+
ProductColumnTypes p = new ProductColumnTypes(
39+
Integer.parseInt(request.getQueryParameters().get("productId")),
40+
new Date(System.currentTimeMillis()),
41+
new Date(System.currentTimeMillis()));
4042
product.setValue(p);
4143

4244
// Items were inserted successfully so return success, an exception would be thrown if there

test/Integration/test-java/src/main/java/com/function/Common/ProductColumnTypes.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
package com.function.Common;
88

9-
import java.sql.Timestamp;
9+
import java.sql.Date;
1010

1111
public class ProductColumnTypes {
1212
private int ProductId;
13-
private Timestamp Datetime;
14-
private Timestamp Datetime2;
13+
private Date Datetime;
14+
private Date Datetime2;
1515

16-
public ProductColumnTypes(int productId, Timestamp datetime, Timestamp datetime2) {
16+
public ProductColumnTypes(int productId, Date datetime, Date datetime2) {
1717
ProductId = productId;
1818
Datetime = datetime;
1919
Datetime2 = datetime2;
@@ -23,19 +23,19 @@ public int getProductId() {
2323
return ProductId;
2424
}
2525

26-
public Timestamp getDatetime() {
26+
public Date getDatetime() {
2727
return Datetime;
2828
}
2929

30-
public void setDatetime(Timestamp datetime) {
30+
public void setDatetime(Date datetime) {
3131
Datetime = datetime;
3232
}
3333

34-
public Timestamp getDatetime2() {
34+
public Date getDatetime2() {
3535
return Datetime2;
3636
}
3737

38-
public void setDatetime2(Timestamp datetime2) {
38+
public void setDatetime2(Date datetime2) {
3939
Datetime2 = datetime2;
4040
}
4141
}

0 commit comments

Comments
 (0)