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

Intersection Types Cannot Be Used to Database Operations #4283

Open
ThisaruGuruge opened this issue Mar 29, 2023 · 0 comments
Open

Intersection Types Cannot Be Used to Database Operations #4283

ThisaruGuruge opened this issue Mar 29, 2023 · 0 comments
Labels
module/sql Team/DIU Data, IO, and Util packages related issues Type/Bug

Comments

@ThisaruGuruge
Copy link
Member

Description:

If a database operation is used with readonly types, the type inferring fails with the following error:

Expected type to be \'(test:record {| string foo |} & readonly)\' but found \'record{}\'.

Use the following code:

import ballerina/sql;

final mysql:Client dbClient = check new (...);

type Foo readonly & record {
    string foo;   
};

isolated function getPosts(string? userId) returns stream<Foo, error?> {
    sql:ParameterizedQuery query = `SELECT * FROM post`;
    return dbClient->query(query);
}
@ThisaruGuruge ThisaruGuruge added Type/Bug module/sql Team/DIU Data, IO, and Util packages related issues labels Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/sql Team/DIU Data, IO, and Util packages related issues Type/Bug
Projects
None yet
Development

No branches or pull requests

1 participant