When building a Ballerina project with the persist module, the build process attempts to generate the database client (persist(generate-db-client)) before pulling dependencies. This causes following errors when dependencies like ballerinax/persist.sql are missing, especially on systems or environments without a cache (e.g., Choreo deployments).
Executing Build Tools
persist(generate-db-client)
ERROR [Ballerina.toml:(1:1,22:1)] unexpected error occurred while generating the client
the model definition file(model.bal) has errors.
ERROR [model.bal:(3:1,3:31)] cannot resolve module ballerinax/persist.sql as sql
ERROR [model.bal:(6:5,6:19)] undefined annotation Generated
ERROR [model.bal:(6:5,6:19)] undefined module sql
ERROR [model.bal:(29:5,29:19)] undefined annotation Generated
ERROR [model.bal:(29:5,29:19)] undefined module sql
Steps to Reproduce
Steps to Reproduce
Clear the Ballerina cache
Create a new Ballerina project:
Initialize the project using the following command:
bal new persist-sample
Navigate to the project directory:
cd persist-sample
Initialize Ballerina Persist:
Run the following command to add Persist to the project:
bal persist init
Add a model.bal file with the following content:
import ballerina/persist as _;
import ballerina/time;
import ballerinax/persist.sql;
type User record {|
@sql:Generated
readonly int id;
string name;
string email;
string password;
string number;
string profilePic;
string role;
string status;
time:Civil? lastLogin;
time:Civil createdAt;
time:Civil updatedAt;
time:Civil? deletedAt;
|};
Description
Issue Description
When building a Ballerina project with the persist module, the build process attempts to generate the database client (
persist(generate-db-client)
) before pulling dependencies. This causes following errors when dependencies likeballerinax/persist.sql
are missing, especially on systems or environments without a cache (e.g., Choreo deployments).Steps to Reproduce
Steps to Reproduce
Clear the Ballerina cache
Create a new Ballerina project:
Initialize Ballerina Persist:
Add a
model.bal
file with the following content:Run the build command:
Version
Ballerina version: 2201.10.2
Environment Details (with versions)
Ballerina version: 2201.10.2 OS: Windows