-
Notifications
You must be signed in to change notification settings - Fork 63
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 sql trigger test for different data types #876
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
63aa521
add productcolumntypestriggertest
lucyzhang929 8af6573
try running only csharp
lucyzhang929 e082672
try running js
lucyzhang929 9942620
comment out column values check temporarily
lucyzhang929 76ef1bc
skip date and byte checks
lucyzhang929 0038f0e
fix build error
lucyzhang929 cd449da
skip byte check
lucyzhang929 123673c
remove date/time, add back binary
lucyzhang929 720f379
fix build error
lucyzhang929 a95cc08
remove only binary check
lucyzhang929 40c1456
remove only nchar and nvarchar
lucyzhang929 fc57c44
check equality of nchar and nvarchar
lucyzhang929 91874b8
fix tests
lucyzhang929 59060ce
change nchar to test
lucyzhang929 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using DotnetIsolatedTests.Common; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Azure.Functions.Worker.Extensions.Sql; | ||
|
||
namespace DotnetIsolatedTests | ||
{ | ||
public static class ProductsColumnTypesTrigger | ||
{ | ||
/// <summary> | ||
/// Simple trigger function used to verify different column types are serialized correctly. | ||
/// </summary> | ||
[Function(nameof(ProductsColumnTypesTrigger))] | ||
public static void Run( | ||
[SqlTrigger("[dbo].[ProductsColumnTypes]", "SqlConnectionString")] | ||
IReadOnlyList<SqlChange<ProductColumnTypes>> changes, | ||
FunctionContext context) | ||
{ | ||
ILogger logger = context.GetLogger("ProductsColumnTypesTrigger"); | ||
logger.LogInformation("SQL Changes: " + Utils.JsonSerializeObject(changes)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
test/Integration/test-csharp/ProductsColumnTypesTrigger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Common; | ||
using Microsoft.Extensions.Logging; | ||
|
||
|
||
namespace Microsoft.Azure.WebJobs.Extensions.Sql.Tests.Integration | ||
{ | ||
public static class ProductsColumnTypesTrigger | ||
{ | ||
/// <summary> | ||
/// Simple trigger function used to verify different column types are serialized correctly. | ||
/// </summary> | ||
[FunctionName(nameof(ProductsColumnTypesTrigger))] | ||
public static void Run( | ||
[SqlTrigger("[dbo].[ProductsColumnTypes]", "SqlConnectionString")] | ||
IReadOnlyList<SqlChange<ProductColumnTypes>> changes, | ||
ILogger logger) | ||
{ | ||
logger.LogInformation("SQL Changes: " + Utils.JsonSerializeObject(changes)); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/Integration/test-csx/ProductsColumnTypesTrigger/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "changes", | ||
"type": "sqlTrigger", | ||
"direction": "in", | ||
"tableName": "dbo.ProductsColumnTypes", | ||
"connectionStringSetting": "SqlConnectionString" | ||
} | ||
], | ||
"disabled": false | ||
} |
14 changes: 14 additions & 0 deletions
14
test/Integration/test-csx/ProductsColumnTypesTrigger/run.csx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#load "../Common/Product.csx" | ||
#r "Newtonsoft.Json" | ||
#r "Microsoft.Azure.WebJobs.Extensions.Sql" | ||
|
||
using System.Net; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Primitives; | ||
using Newtonsoft.Json; | ||
using Microsoft.Azure.WebJobs.Extensions.Sql; | ||
|
||
public static void Run(IReadOnlyList<SqlChange<ProductColumnTypes>> changes, ILogger log) | ||
{ | ||
log.LogInformation("SQL Changes: " + Microsoft.Azure.WebJobs.Extensions.Sql.Utils.JsonSerializeObject(changes)); | ||
} |
36 changes: 36 additions & 0 deletions
36
.../Integration/test-java/src/main/java/com/function/Common/SqlChangeProductColumnTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.function.Common; | ||
|
||
public class SqlChangeProductColumnTypes { | ||
private SqlChangeOperation Operation; | ||
private ProductColumnTypes Item; | ||
|
||
public SqlChangeProductColumnTypes() { | ||
} | ||
|
||
public SqlChangeProductColumnTypes(SqlChangeOperation operation, ProductColumnTypes item) { | ||
this.Operation = operation; | ||
this.Item = item; | ||
} | ||
|
||
public SqlChangeOperation getOperation() { | ||
return Operation; | ||
} | ||
|
||
public void setOperation(SqlChangeOperation operation) { | ||
this.Operation = operation; | ||
} | ||
|
||
public ProductColumnTypes getItem() { | ||
return Item; | ||
} | ||
|
||
public void setItem(ProductColumnTypes item) { | ||
this.Item = item; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
test/Integration/test-java/src/main/java/com/function/ProductsColumnTypesTrigger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.function; | ||
|
||
import com.function.Common.SqlChangeProductColumnTypes; | ||
import com.google.gson.Gson; | ||
import com.microsoft.azure.functions.ExecutionContext; | ||
import com.microsoft.azure.functions.annotation.FunctionName; | ||
import com.microsoft.azure.functions.sql.annotation.SQLTrigger; | ||
|
||
import java.util.logging.Level; | ||
|
||
public class ProductsColumnTypesTrigger { | ||
@FunctionName("ProductsColumnTypesTrigger") | ||
public void run( | ||
@SQLTrigger( | ||
name = "changes", | ||
tableName = "[dbo].[ProductsColumnTypes]", | ||
connectionStringSetting = "SqlConnectionString") | ||
SqlChangeProductColumnTypes[] changes, | ||
ExecutionContext context) throws Exception { | ||
|
||
context.getLogger().log(Level.INFO, "SQL Changes: " + new Gson().toJson(changes)); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/Integration/test-js/ProductsColumnTypesTrigger/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "changes", | ||
"type": "sqlTrigger", | ||
"direction": "in", | ||
"tableName": "dbo.ProductsColumnTypes", | ||
"connectionStringSetting": "SqlConnectionString" | ||
} | ||
], | ||
"disabled": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
module.exports = async function (context, changes) { | ||
context.log(`SQL Changes: ${JSON.stringify(changes)}`) | ||
} |
12 changes: 12 additions & 0 deletions
12
test/Integration/test-powershell/ProductsColumnTypesTrigger/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "changes", | ||
"type": "sqlTrigger", | ||
"direction": "in", | ||
"tableName": "dbo.ProductsColumnTypes", | ||
"connectionStringSetting": "SqlConnectionString" | ||
} | ||
], | ||
"disabled": false | ||
} |
9 changes: 9 additions & 0 deletions
9
test/Integration/test-powershell/ProductsColumnTypesTrigger/run.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using namespace System.Net | ||
|
||
param($changes) | ||
|
||
$changesJson = $changes | ConvertTo-Json -Compress -AsArray | ||
Write-Host "SQL Changes: $changesJson" |
7 changes: 7 additions & 0 deletions
7
test/Integration/test-python/ProductsColumnTypesTrigger/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import logging | ||
|
||
def main(changes): | ||
logging.info("SQL Changes: %s", changes) |
12 changes: 12 additions & 0 deletions
12
test/Integration/test-python/ProductsColumnTypesTrigger/function.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "changes", | ||
"type": "sqlTrigger", | ||
"direction": "in", | ||
"tableName": "dbo.ProductsColumnTypes", | ||
"connectionStringSetting": "SqlConnectionString" | ||
} | ||
], | ||
"disabled": false | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I used NCHAR(0xD84C) here instead of 'test' (which is what we do in the input/output binding tests) the test failed in the pipeline but passed locally on my machine. Will try to keep investigating why it was failing in the pipelines but using 'test' for now so I can get the test in first.