Skip to content
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

Issue: Persist Generates DB Client Before Pulling Dependencies #7388

Open
chathushkaayash opened this issue Nov 20, 2024 · 0 comments
Open

Comments

@chathushkaayash
Copy link

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 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

  1. Clear the Ballerina cache

  2. Create a new Ballerina project:

    • Initialize the project using the following command:
      bal new persist-sample
    • Navigate to the project directory:
      cd persist-sample
  3. Initialize Ballerina Persist:

    • Run the following command to add Persist to the project:
      bal persist init
  4. 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;  
    |};
    
  5. Run the build command:

    bal build
    
    

Version

Ballerina version: 2201.10.2

Environment Details (with versions)

Ballerina version: 2201.10.2
OS: Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants