Skip to content

Fix AddProductColumnTypesTest for Java #552

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

Merged
merged 2 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Databases on SQL Server, Azure SQL Database, or Azure SQL Managed Instance which

- 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.
- Input bindings against tables with columns of data types 'DATETIME', 'DATETIME2', or 'SMALLDATETIME' will assume that the values are in UTC format.
- 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.
- 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.

## Telemetry
Expand Down
6 changes: 2 additions & 4 deletions test/Integration/SqlOutputBindingIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,13 @@ public void AddProductArrayTest(SupportedLanguages lang)
}

/// <summary>
/// Test compatability with converting various data types to their respective
/// Test compatibility with converting various data types to their respective
/// SQL server types.
/// </summary>
/// <param name="lang">The language to run the test against</param>
[Theory]
[SqlInlineData()]
// This test is currrently failing in the Linux pipeline for Java
// https://github.com/Azure/azure-functions-sql-extension/issues/521
[UnsupportedLanguages(SupportedLanguages.Java, SupportedLanguages.PowerShell, SupportedLanguages.OutOfProc)]
[UnsupportedLanguages(SupportedLanguages.PowerShell, SupportedLanguages.OutOfProc)]
public void AddProductColumnTypesTest(SupportedLanguages lang)
{
this.StartFunctionHost(nameof(AddProductColumnTypes), lang, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.microsoft.azure.functions.sql.annotation.SQLOutput;
import com.function.Common.ProductColumnTypes;

import java.sql.Timestamp;
import java.sql.Date;
import java.util.Optional;

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

ProductColumnTypes p = new ProductColumnTypes(0, new Timestamp(System.currentTimeMillis()),
new Timestamp(System.currentTimeMillis()));
ProductColumnTypes p = new ProductColumnTypes(
Integer.parseInt(request.getQueryParameters().get("productId")),
new Date(System.currentTimeMillis()),
new Date(System.currentTimeMillis()));
product.setValue(p);

// Items were inserted successfully so return success, an exception would be thrown if there
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

package com.function.Common;

import java.sql.Timestamp;
import java.sql.Date;

public class ProductColumnTypes {
private int ProductId;
private Timestamp Datetime;
private Timestamp Datetime2;
private Date Datetime;
private Date Datetime2;

public ProductColumnTypes(int productId, Timestamp datetime, Timestamp datetime2) {
public ProductColumnTypes(int productId, Date datetime, Date datetime2) {
ProductId = productId;
Datetime = datetime;
Datetime2 = datetime2;
Expand All @@ -23,19 +23,19 @@ public int getProductId() {
return ProductId;
}

public Timestamp getDatetime() {
public Date getDatetime() {
return Datetime;
}

public void setDatetime(Timestamp datetime) {
public void setDatetime(Date datetime) {
Datetime = datetime;
}

public Timestamp getDatetime2() {
public Date getDatetime2() {
return Datetime2;
}

public void setDatetime2(Timestamp datetime2) {
public void setDatetime2(Date datetime2) {
Datetime2 = datetime2;
}
}