Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@
*/
public class CodeAnalyzer extends NodeVisitor {

public static final String PARAMETERIZED_QUERY = "ParameterizedQuery";
public static final String PARAMETERIZED_QUERY = "sql:ParameterizedQuery";
public static final String PARAMETERIZED_CALL_QUERY = "sql:ParameterizedCallQuery";
// Readonly fields
private final Project project;
private final SemanticModel semanticModel;
Expand Down Expand Up @@ -1391,7 +1392,8 @@ private void buildPropertyType(Property.Builder<?> builder, ParameterData paramD
builder.type(Property.ValueType.MAPPING_EXPRESSION_SET);
} else {
String ballerinaType = CommonUtils.getTypeSignature(paramData.typeSymbol(), moduleInfo);
if (ballerinaType != null && ballerinaType.contains(PARAMETERIZED_QUERY)) {
if (ballerinaType != null && (ballerinaType.contains(PARAMETERIZED_QUERY)
|| ballerinaType.contains(PARAMETERIZED_CALL_QUERY))) {
// Handle SQL query parameters with SQL_QUERY as primary option
builder.type()
.fieldType(Property.ValueType.SQL_QUERY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public record Property(Metadata metadata, List<PropertyType> types, Object value
public static final TypeToken<List<Property>> LIST_PROPERTY_TYPE_TOKEN = new TypeToken<List<Property>>() {
};
public static final String SQL_PARAMETERIZED_QUERY = "sql:ParameterizedQuery";
public static final String SQL_CALL_QUERY = "sql:ParameterizedCallQuery";

@SuppressWarnings("unchecked")
public <T> T valueAsType(TypeToken<T> typeToken) {
Expand Down Expand Up @@ -708,7 +709,7 @@ private String getSelectedType(Node value, SemanticModel semanticModel) {

private boolean handlePrimitiveType(TypeSymbol typeSymbol, String ballerinaType) {
// Check for SQL query types first
if (SQL_PARAMETERIZED_QUERY.equals(ballerinaType)) {
if (SQL_PARAMETERIZED_QUERY.equals(ballerinaType) || SQL_CALL_QUERY.equals(ballerinaType)) {
type().fieldType(ValueType.SQL_QUERY).ballerinaType(ballerinaType).selected(true).stepOut();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
{
"source": "local_connector/main.bal",
"position": {
"line": 79,
"offset": 8
},
"description": "Resource function with single path parameter and inferred type - get album by id",
"codedata": {
"node": "REMOTE_ACTION_CALL",
"org": "ballerinax",
"module": "mssql",
"packageName": "mssql",
"object": "Client",
"symbol": "call",
"version": "1.16.1",
"parentSymbol": "dbClient",
"resourcePath": "/albums/[albumId]"
},
"output": {
"id": "31",
"metadata": {
"label": "call",
"description": "Calls a stored procedure with the given SQL query.\nOnce the results are processed, invoke the `close` method on the `sql:ProcedureCallResult`.\n",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_mssql_1.16.1.png"
},
"codedata": {
"node": "REMOTE_ACTION_CALL",
"org": "ballerinax",
"module": "mssql",
"packageName": "mssql",
"object": "Client",
"symbol": "call",
"version": "1.16.1",
"isNew": true
},
"returning": false,
"properties": {
"connection": {
"metadata": {
"label": "Connection",
"description": "Connection to use"
},
"types": [
{
"fieldType": "EXPRESSION",
"ballerinaType": "mssql:Client",
"selected": false
}
],
"value": "dbClient",
"optional": false,
"editable": false,
"advanced": false,
"hidden": true
},
"sqlQuery": {
"metadata": {
"label": "SQL Query",
"description": "SQL query to call the procedure (e.g., `` `CALL sp_GetAlbums()` ``)"
},
"types": [
{
"fieldType": "SQL_QUERY",
"ballerinaType": "sql:ParameterizedCallQuery",
"selected": true
},
{
"fieldType": "EXPRESSION",
"ballerinaType": "sql:ParameterizedCallQuery",
"selected": false
}
],
"placeholder": "object {}",
"optional": false,
"editable": true,
"advanced": false,
"hidden": false,
"codedata": {
"kind": "REQUIRED",
"originalName": "sqlQuery"
},
"imports": {
"sql": "ballerina/sql"
}
},
"rowTypes": {
"metadata": {
"label": "Row Types",
"description": "`typedesc` array of the records to which the results should be mapped"
},
"types": [
{
"fieldType": "EXPRESSION",
"ballerinaType": "typedesc<record {|anydata...;|}>[]",
"selected": false
}
],
"placeholder": "[]",
"optional": true,
"editable": true,
"advanced": true,
"hidden": false,
"codedata": {
"kind": "DEFAULTABLE",
"originalName": "rowTypes"
},
"defaultValue": "[]"
},
"type": {
"metadata": {
"label": "Result Type",
"description": "Type of the variable"
},
"types": [
{
"fieldType": "TYPE",
"selected": true
}
],
"value": "sql:ProcedureCallResult",
"placeholder": "var",
"optional": false,
"editable": false,
"advanced": false,
"hidden": false,
"codedata": {},
"imports": {
"sql": "ballerina/sql"
}
},
"variable": {
"metadata": {
"label": "Result",
"description": "Name of the result variable"
},
"types": [
{
"fieldType": "IDENTIFIER",
"selected": true
}
],
"value": "sqlProcedurecallresult",
"optional": false,
"editable": true,
"advanced": false,
"hidden": false
},
"checkError": {
"metadata": {
"label": "Check Error",
"description": "Trigger error flow"
},
"types": [
{
"fieldType": "FLAG",
"selected": true
}
],
"value": true,
"optional": false,
"editable": true,
"advanced": true,
"hidden": true
}
},
"flags": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function customFnWithImportedType(http:ClientConfiguration config, Address addre
function function1(string a1) {
do {
stream<record {|anydata...;|}, sql:Error?> streamRowtypeSqlError = mssqlClient->query(`SELECT * from users`);
sql:ProcedureCallResult sqlProcedurecallresult = check mysqlClient->call(`Call get_user()`);

} on fail {

Expand Down
Loading