Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion java-library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-library-sql</artifactId>
<version>0.1.1</version> <!-- Update the dependency version in samples-java/pom.xml and test-java/pom.xml if this version is updated. -->
<version>2.0.0-preview</version> <!-- Update the dependency version in samples-java/pom.xml and test-java/pom.xml if this version is updated. -->
<packaging>jar</packaging>

<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
/**
* Query string or name of stored procedure to be run.
*/
String commandText() default "";
String commandText();

/**
* Text or Stored Procedure.
*/
String commandType() default "";
String commandType();
Copy link
Contributor

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

Copy link
Contributor Author

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

public SqlAttribute(string commandText, string connectionStringSetting) : this(commandText, connectionStringSetting, CommandType.Text, null) { }
and sets the parameter to null.

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.


/**
* Parameters to the query or stored procedure. This string must follow the format
Expand All @@ -42,5 +42,5 @@
/**
* Setting name for SQL connection string.
*/
String connectionStringSetting() default "";
String connectionStringSetting();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
/**
* Name of the table to upsert data to.
*/
String commandText() default "";
String commandText();

/**
* Setting name for SQL connection string.
*/
String connectionStringSetting() default "";
String connectionStringSetting();
}
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();
}