-
Notifications
You must be signed in to change notification settings - Fork 63
Add SQLTrigger annotation to java library #783
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
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
34 changes: 34 additions & 0 deletions
34
java-library/src/main/java/com/microsoft/azure/functions/sql/annotation/SQLTrigger.java
This file contains hidden or 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,34 @@ | ||
| /** | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for | ||
| * license information. | ||
| */ | ||
|
|
||
| package com.microsoft.azure.functions.sql.annotation; | ||
|
|
||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.Target; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.ElementType; | ||
|
|
||
| import com.microsoft.azure.functions.annotation.CustomBinding; | ||
|
|
||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target(ElementType.PARAMETER) | ||
| @CustomBinding(direction = "in", name = "", type = "sqlTrigger") | ||
| public @interface SQLTrigger { | ||
| /** | ||
| * The variable name used in function.json. | ||
| */ | ||
| String name(); | ||
|
|
||
| /** | ||
| * Name of the table to watch for changes. | ||
| */ | ||
| String tableName(); | ||
|
|
||
| /** | ||
| * Setting name for SQL connection string. | ||
| */ | ||
| String connectionStringSetting(); | ||
| } |
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.
This we should default to Text if possible - that's the default we do for the other langs
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.
I tried removing commandType from non-CSharp samples that include parameters and the parameters were not getting set correctly. When I debugged the GetProducts function, it hits this constructor
azure-functions-sql-extension/src/SqlAttribute.cs
Line 39 in f01ffa4
I think we need to add another constructor that includes parameters. I will send a PR out for that.
Right now our docs and samples still note that commandType is required in non-CSharp languages. https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-azure-sql-input?tabs=in-process&pivots=programming-language-javascript#configuration
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.
Gotcha, yeah we can make that improvement. But you should still be able to give this a default value here, right? It'll end up having a value - it's just one the user doesn't necessarily need to specify.
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.
For some reason when I put a default value (CommandType.Text), the GetProducts function still uses the SqlAttribute constructor that sets the parameters to null. Once I add a new constructor that sets parameters, I'll update the java library to include a default value for CommandType.