Add order automation sample - #142
Conversation
📝 WalkthroughOverviewThis pull request adds a complete order management automation sample to the integration-samples repository. The sample demonstrates a scheduled automation workflow that processes customer orders using Ballerina. ChangesAdded a new Project Configuration
Automation Logic
Data Models
Documentation & Configuration
ImpactThis sample provides a complete, runnable example of an order processing automation that integrates database operations with email notifications, serving as a reference for building similar integration workflows. WalkthroughA new Ballerina sample, 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a new Ballerina sample package under integrator-default-profile/samples/order-management-automation that demonstrates reading “PLACED” orders from MySQL (via Persist), emailing customers, and advancing orders to “PROCESSING”.
Changes:
- Introduces a new Ballerina package (
orderprocessingautomation) with Persist model + automation logic. - Adds documentation and workspace metadata for running the sample.
- Adds Choreo context metadata for the sample workspace.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/automation.bal | Implements the order-processing loop (read placed orders, email, update status, log). |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/connections.bal | Creates MySQL (Persist) and SMTP clients from configurable values. |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/types.bal | Defines record types used to represent orders and related entities. |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/persist/ordersDB/model.bal | Defines Persist entity model for orders/customers/products. |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/config.bal | Adds configurable DB + SMTP settings. |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/README.md | Documents setup (DB schema seed), configuration, and how to run the sample. |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/Ballerina.toml | Defines the package and Persist tool configuration. |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/Dependencies.toml | Locks dependency versions for the new package. |
| integrator-default-profile/samples/order-management-automation/Ballerina.toml | Adds a workspace definition for the sample. |
| integrator-default-profile/samples/order-management-automation/.choreo/context.yaml | Adds Choreo project context metadata. |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/.gitignore | Ignores build output and local config files for the sample. |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/main.bal | Currently empty module file (added by template). |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/functions.bal | Currently empty module file (added by template). |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/data_mappings.bal | Currently empty module file (added by template). |
| integrator-default-profile/samples/order-management-automation/orderprocessingautomation/agents.bal | Currently empty module file (added by template). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| final ordersdb:Client ordersDB = check new (ordersDBHost, ordersDBPort, ordersDBUser, ordersDBPassword, ordersDBDatabase); | ||
|
|
||
| final email:SmtpClient emailSmtpclient = check new (string `${emailHost}`, string `${emailUserName}`, string `${emailPassword}`, port = emailPort, security = "START_TLS_NEVER"); |
| PlacedOrdersProductType product; | ||
| |}; | ||
|
|
||
| public type PlacedOrdersCustomerType record {| |
| string name; | ||
| string email; | ||
| string address; | ||
| |}; |
| string address; | ||
| |}; | ||
|
|
||
| public type PlacedOrdersProductType record {| |
| string productName; | ||
| string category; | ||
| decimal price; | ||
| |}; |
| ordersdb:Order updatedOrder = check ordersDB->/orders/[placedOrder.orderId].put({status: "PROCESSING"}); | ||
| check emailSmtpclient->sendMessage({ | ||
| to: placedOrder.customer.email, | ||
| subject: placedOrder.orderId + ": status update", | ||
| body: "Your order bearing id :" + placedOrder.orderId + " is now under process" | ||
| }); |
| [[dependency]] | ||
| org = "ballerina" | ||
| name = "tool.persist" | ||
| version = "1.9.1" |
| - org: pasindufernando | ||
| project: order-management-automation | ||
| local: true |
| configurable string emailHost = "127.0.0.1"; | ||
| configurable string emailUserName = "orders@example.com"; | ||
| configurable string emailPassword = ?; | ||
| configurable int emailPort = 2525; No newline at end of file |
| @@ -0,0 +1,106 @@ | |||
| # Order Management Automation | |||
|
|
|||
| A scheduled automation that processes newly placed orders. On each run it reads every order still in the `PLACED` state from a MySQL `orders_db`, emails the customer that their order is being handled, advances the order to `PROCESSING`, and logs a summary. When nothing is waiting, the run exits early. | |||
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
integrator-default-profile/samples/order-management-automation/orderprocessingautomation/README.md (1)
79-89: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winClarify Config.toml example for local vs. external SMTP.
The Configuration example shows
emailHost = "smtp.example.com"andemailPort = 465, which align with external SMTP services. However, the documented prerequisites describe a local setup (MySQL on localhost), and the actual default configuration in code uses127.0.0.1:2525(local test SMTP). Users following the README may be confused about whether to use the example values or the defaults. Either align the example with the documented local defaults or explicitly state when the example is for external SMTP and explain the difference.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/README.md` around lines 79 - 89, The Configuration section in the README shows a Config.toml example with external SMTP values (emailHost = "smtp.example.com" and emailPort = 465), but this conflicts with the actual code defaults which use local test SMTP (127.0.0.1:2525). Update the Config.toml example block to either replace the external SMTP values with the local defaults (127.0.0.1 and port 2525) that match the code implementation, or alternatively add two separate configuration examples clearly labeled "Local Development Setup" and "External SMTP Setup" with explanations of when to use each, ensuring users understand which values to use for their environment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/automation.bal`:
- Around line 13-18: The order status is being updated to "PROCESSING" before
the email notification is sent, which causes an inconsistent state if the email
sending fails. Reorder the operations by moving the
emailSmtpclient->sendMessage() call before the
ordersDB->/orders/[placedOrder.orderId].put() call. This ensures the email is
sent first, and only if successful does the order status transition to
"PROCESSING", preserving the ability to retry the entire operation without
leaving the system in an inconsistent state.
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/Ballerina.toml`:
- Around line 19-22: The version field for the tool.persist dependency in the
dependency block does not match the resolved version in Dependencies.toml.
Update the version property of the tool.persist dependency from "1.9.1" to
"1.9.2" to ensure consistency between Ballerina.toml and the actual resolved
dependency version, which improves reproducibility and prevents version
mismatches.
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/connections.bal`:
- Line 7: The SMTP security mode is hardcoded as "START_TLS_NEVER" in the
emailSmtpclient initialization, while other connection parameters like
emailHost, emailPort, emailUserName, and emailPassword are configurable. Extract
the hardcoded security value into a configurable variable (e.g., emailSecurity)
defined in config.bal alongside the other email configuration parameters, then
replace "START_TLS_NEVER" in the emailSmtpclient initialization with this new
configurable variable to allow different security modes for different deployment
environments.
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/persist/ordersDB/model.bal`:
- Line 8: The Ballerina model defines ID fields with `@sql`:Varchar {length: 36},
but the database schema specifies VARCHAR(20) for order_id, customer_id, and
product_id. Update all three ID field annotations to use length: 20 instead of
length: 36 to match the SQL schema definition and prevent data truncation. This
applies to the annotations on the order_id field, customer_id field, and
product_id field in the model.
- Line 33: The `@sql`:Varchar annotation on the customerId field specifies a
length of 36, but the actual database schema defines the customer_id column as
VARCHAR(20), creating a mismatch. Update the length parameter in the
`@sql`:Varchar annotation for the customerId field to match the database schema
definition of 20 characters instead of 36. This ensures the model definition is
consistent with the underlying database constraints.
- Line 47: The productId field in the model has an `@sql`:Varchar annotation with
length set to 36, but the corresponding database column product_id is defined as
VARCHAR(20). Update the length parameter in the `@sql`:Varchar annotation from 36
to 20 to ensure the model definition matches the actual database schema
definition.
---
Nitpick comments:
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/README.md`:
- Around line 79-89: The Configuration section in the README shows a Config.toml
example with external SMTP values (emailHost = "smtp.example.com" and emailPort
= 465), but this conflicts with the actual code defaults which use local test
SMTP (127.0.0.1:2525). Update the Config.toml example block to either replace
the external SMTP values with the local defaults (127.0.0.1 and port 2525) that
match the code implementation, or alternatively add two separate configuration
examples clearly labeled "Local Development Setup" and "External SMTP Setup"
with explanations of when to use each, ensuring users understand which values to
use for their environment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e7b35d30-2a8c-4a43-a6b4-46be15515c77
📒 Files selected for processing (15)
integrator-default-profile/samples/order-management-automation/.choreo/context.yamlintegrator-default-profile/samples/order-management-automation/Ballerina.tomlintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/.gitignoreintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/Ballerina.tomlintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/Dependencies.tomlintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/README.mdintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/agents.balintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/automation.balintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/config.balintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/connections.balintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/data_mappings.balintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/functions.balintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/main.balintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/persist/ordersDB/model.balintegrator-default-profile/samples/order-management-automation/orderprocessingautomation/types.bal
| ordersdb:Order updatedOrder = check ordersDB->/orders/[placedOrder.orderId].put({status: "PROCESSING"}); | ||
| check emailSmtpclient->sendMessage({ | ||
| to: placedOrder.customer.email, | ||
| subject: placedOrder.orderId + ": status update", | ||
| body: "Your order bearing id :" + placedOrder.orderId + " is now under process" | ||
| }); |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Reorder processing at Line 13-18: send notification before status transition.
The current flow updates the order to PROCESSING before sending the email. If sending fails, the order state is already advanced, which breaks the intended processing contract and retry behavior.
Proposed change
foreach PlacedOrdersType placedOrder in placedOrders {
- ordersdb:Order updatedOrder = check ordersDB->/orders/[placedOrder.orderId].put({status: "PROCESSING"});
check emailSmtpclient->sendMessage({
to: placedOrder.customer.email,
subject: placedOrder.orderId + ": status update",
body: "Your order bearing id :" + placedOrder.orderId + " is now under process"
});
+ ordersdb:Order updatedOrder = check ordersDB->/orders/[placedOrder.orderId].put({status: "PROCESSING"});
log:printInfo(string `Order advanced to PROCESSING: ${updatedOrder.orderId}`);
}As per path instructions, this focuses on correctness and high-level safety behavior without speculative detail.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ordersdb:Order updatedOrder = check ordersDB->/orders/[placedOrder.orderId].put({status: "PROCESSING"}); | |
| check emailSmtpclient->sendMessage({ | |
| to: placedOrder.customer.email, | |
| subject: placedOrder.orderId + ": status update", | |
| body: "Your order bearing id :" + placedOrder.orderId + " is now under process" | |
| }); | |
| check emailSmtpclient->sendMessage({ | |
| to: placedOrder.customer.email, | |
| subject: placedOrder.orderId + ": status update", | |
| body: "Your order bearing id :" + placedOrder.orderId + " is now under process" | |
| }); | |
| ordersdb:Order updatedOrder = check ordersDB->/orders/[placedOrder.orderId].put({status: "PROCESSING"}); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/automation.bal`
around lines 13 - 18, The order status is being updated to "PROCESSING" before
the email notification is sent, which causes an inconsistent state if the email
sending fails. Reorder the operations by moving the
emailSmtpclient->sendMessage() call before the
ordersDB->/orders/[placedOrder.orderId].put() call. This ensures the email is
sent first, and only if successful does the order status transition to
"PROCESSING", preserving the ability to retry the entire operation without
leaving the system in an inconsistent state.
Source: Path instructions
| [[dependency]] | ||
| org = "ballerina" | ||
| name = "tool.persist" | ||
| version = "1.9.1" |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify tool.persist version consistency between manifests
echo "=== Ballerina.toml declared version ==="
rg -A1 'name = "tool.persist"' integrator-default-profile/samples/order-management-automation/orderprocessingautomation/Ballerina.toml
echo "=== Dependencies.toml resolved version ==="
rg -A1 'name = "tool.persist"' integrator-default-profile/samples/order-management-automation/orderprocessingautomation/Dependencies.tomlRepository: wso2/integration-samples
Length of output: 325
Update tool.persist version in Ballerina.toml to match the resolved version.
The declared version is 1.9.1, but Dependencies.toml resolved to 1.9.2. Update Ballerina.toml line 22 to version = "1.9.2" for consistency and reproducibility.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/Ballerina.toml`
around lines 19 - 22, The version field for the tool.persist dependency in the
dependency block does not match the resolved version in Dependencies.toml.
Update the version property of the tool.persist dependency from "1.9.1" to
"1.9.2" to ensure consistency between Ballerina.toml and the actual resolved
dependency version, which improves reproducibility and prevents version
mismatches.
|
|
||
| final ordersdb:Client ordersDB = check new (ordersDBHost, ordersDBPort, ordersDBUser, ordersDBPassword, ordersDBDatabase); | ||
|
|
||
| final email:SmtpClient emailSmtpclient = check new (string `${emailHost}`, string `${emailUserName}`, string `${emailPassword}`, port = emailPort, security = "START_TLS_NEVER"); |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
find . -name "connections.bal" -o -name "*.bal" | grep -E "(connections|order)" | head -20Repository: wso2/integration-samples
Length of output: 1890
🏁 Script executed:
cat integrator-default-profile/samples/order-management-automation/orderprocessingautomation/connections.balRepository: wso2/integration-samples
Length of output: 533
🏁 Script executed:
cat -n integrator-default-profile/samples/order-management-automation/orderprocessingautomation/connections.balRepository: wso2/integration-samples
Length of output: 582
🏁 Script executed:
find integrator-default-profile/samples/order-management-automation -type f \( -name "*.toml" -o -name "*.bal" \) | head -30Repository: wso2/integration-samples
Length of output: 1383
🏁 Script executed:
cat integrator-default-profile/samples/order-management-automation/Config.toml 2>/dev/null || echo "No Config.toml found"Repository: wso2/integration-samples
Length of output: 183
🏁 Script executed:
cat -n integrator-default-profile/samples/order-management-automation/orderprocessingautomation/config.balRepository: wso2/integration-samples
Length of output: 639
🌐 Web query:
Ballerina email SMTP client security parameter options START_TLS STARTTLS
💡 Result:
The Ballerina email module provides robust transport-level security for SMTP clients through the security enum field within the SmtpConfiguration record [1][2][3]. The available options for the security parameter are: * SSL: Uses the default TLS/SSL protocol [2][4][3]. * START_TLS_NEVER: Disables both TLS/SSL and STARTTLS, allowing only unencrypted communication [1][2][3]. * START_TLS_ALWAYS: Mandates the use of the secure STARTTLS protocol [1][2][3]. * START_TLS_AUTO: Enables STARTTLS but falls back to unencrypted communication if the server does not support STARTTLS [1][2][3]. By default, TLS/SSL is enabled [1][2][3]. For deep-level transport security configuration, such as custom certificates, you can also use the secureSocket field in your SmtpConfiguration [1][2][3]. When choosing a security mode, ensure the port number matches the protocol requirements. Common standards include: * SSL: Port 465 [1][2][3]. * STARTTLS: Port 587 [1][2][3]. * Unsecured: Ports 25 or 587 [1][2][3]. Example configuration using START_TLS_AUTO: email:SmtpConfiguration smtpConfig = { port: 587, secureSocket: { // Transport level configuration }, security: email:START_TLS_AUTO };
Citations:
- 1: https://central.ballerina.io/ballerina/email/latest
- 2: https://github.com/ballerina-platform/module-ballerina-email
- 3: https://central.ballerina.io/ballerina/email/2.13.0
- 4: https://github.com/ballerina-platform/module-ballerina-email/blob/master/README.md
Make SMTP security mode configurable at line 7.
The security = "START_TLS_NEVER" parameter is hard-coded while emailHost, emailPort, emailUserName, and emailPassword are all configurable. Since START_TLS_NEVER disables encryption, this parameter should also be configurable to enable safer transport modes for production deployments.
Proposed change
- final email:SmtpClient emailSmtpclient = check new (string `${emailHost}`, string `${emailUserName}`, string `${emailPassword}`, port = emailPort, security = "START_TLS_NEVER");
+ final email:SmtpClient emailSmtpclient = check new (
+ string `${emailHost}`,
+ string `${emailUserName}`,
+ string `${emailPassword}`,
+ port = emailPort,
+ security = emailSecurity
+ );Add to config.bal:
+ configurable string emailSecurity = "START_TLS_NEVER";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| final email:SmtpClient emailSmtpclient = check new (string `${emailHost}`, string `${emailUserName}`, string `${emailPassword}`, port = emailPort, security = "START_TLS_NEVER"); | |
| final email:SmtpClient emailSmtpclient = check new ( | |
| string `${emailHost}`, | |
| string `${emailUserName}`, | |
| string `${emailPassword}`, | |
| port = emailPort, | |
| security = emailSecurity | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/connections.bal`
at line 7, The SMTP security mode is hardcoded as "START_TLS_NEVER" in the
emailSmtpclient initialization, while other connection parameters like
emailHost, emailPort, emailUserName, and emailPassword are configurable. Extract
the hardcoded security value into a configurable variable (e.g., emailSecurity)
defined in config.bal alongside the other email configuration parameters, then
replace "START_TLS_NEVER" in the emailSmtpclient initialization with this new
configurable variable to allow different security modes for different deployment
environments.
Source: Path instructions
| @sql:Name {value: "orders"} | ||
| public type Order record {| | ||
| @sql:Name {value: "order_id"} | ||
| @sql:Varchar {length: 36} |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win
Schema mismatch: VARCHAR lengths exceed database definition.
The model defines ID fields with length: 36, but the README's SQL schema specifies VARCHAR(20) for order_id, customer_id, and product_id. IDs longer than 20 characters will be truncated, causing data corruption and referential integrity violations.
🔧 Proposed fix to align with SQL schema
`@sql`:Name {value: "order_id"}
- `@sql`:Varchar {length: 36}
+ `@sql`:Varchar {length: 20}
readonly string orderId;
`@sql`:Name {value: "customer_id"}
- `@sql`:Varchar {length: 36}
+ `@sql`:Varchar {length: 20}
`@sql`:Index {name: "customer_id"}
string customerId;
`@sql`:Name {value: "product_id"}
- `@sql`:Varchar {length: 36}
+ `@sql`:Varchar {length: 20}
`@sql`:Index {name: "product_id"}
string productId;Also applies to: 11-11, 15-15
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/persist/ordersDB/model.bal`
at line 8, The Ballerina model defines ID fields with `@sql`:Varchar {length: 36},
but the database schema specifies VARCHAR(20) for order_id, customer_id, and
product_id. Update all three ID field annotations to use length: 20 instead of
length: 36 to match the SQL schema definition and prevent data truncation. This
applies to the annotations on the order_id field, customer_id field, and
product_id field in the model.
| @sql:Name {value: "customers"} | ||
| public type Customer record {| | ||
| @sql:Name {value: "customer_id"} | ||
| @sql:Varchar {length: 36} |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win
Schema mismatch: customer_id VARCHAR length exceeds database definition.
The model defines customerId with length: 36, but the SQL schema specifies VARCHAR(20). Ensure consistency with the database schema.
🔧 Proposed fix
`@sql`:Name {value: "customer_id"}
- `@sql`:Varchar {length: 36}
+ `@sql`:Varchar {length: 20}
readonly string customerId;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @sql:Varchar {length: 36} | |
| `@sql`:Name {value: "customer_id"} | |
| `@sql`:Varchar {length: 20} | |
| readonly string customerId; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/persist/ordersDB/model.bal`
at line 33, The `@sql`:Varchar annotation on the customerId field specifies a
length of 36, but the actual database schema defines the customer_id column as
VARCHAR(20), creating a mismatch. Update the length parameter in the
`@sql`:Varchar annotation for the customerId field to match the database schema
definition of 20 characters instead of 36. This ensures the model definition is
consistent with the underlying database constraints.
| @sql:Name {value: "products"} | ||
| public type Product record {| | ||
| @sql:Name {value: "product_id"} | ||
| @sql:Varchar {length: 36} |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win
Schema mismatch: product_id VARCHAR length exceeds database definition.
The model defines productId with length: 36, but the SQL schema specifies VARCHAR(20). Ensure consistency with the database schema.
🔧 Proposed fix
`@sql`:Name {value: "product_id"}
- `@sql`:Varchar {length: 36}
+ `@sql`:Varchar {length: 20}
readonly string productId;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @sql:Varchar {length: 36} | |
| `@sql`:Name {value: "product_id"} | |
| `@sql`:Varchar {length: 20} | |
| readonly string productId; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@integrator-default-profile/samples/order-management-automation/orderprocessingautomation/persist/ordersDB/model.bal`
at line 47, The productId field in the model has an `@sql`:Varchar annotation with
length set to 36, but the corresponding database column product_id is defined as
VARCHAR(20). Update the length parameter in the `@sql`:Varchar annotation from 36
to 20 to ensure the model definition matches the actual database schema
definition.
Purpose
Add order automation sample