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

Support for mapped JSON types in Postgres #99

Open
bhavishyachandra opened this issue Feb 14, 2024 · 0 comments
Open

Support for mapped JSON types in Postgres #99

bhavishyachandra opened this issue Feb 14, 2024 · 0 comments

Comments

@bhavishyachandra
Copy link

Looks like the json properties are mapped as navigation properties instead of scalar properties, despite being in the same table. Would be great if the GetColumnName() could also look at these navigation properties for determining the column name in such circurmstances.

My temporary solution for now was to make the column a string as I don't plan on querying it for now. I could see how this can get inconvenient as more people start using the native json column implementation in EF Core. I tried to implement a custom DbSchemaRetriever but was running into some strange errors during the design time. It'd also be great if we could add an inbuilt jsonb comparer for nested properties to check for equality on json objects in postgres. Thanks for creating this wonderful package, everything just works as expected.

`public class JsonbMethodCallConverter : IMethodCallVisitor
{
private readonly IExpressionVisitorFactory _visitorFactory;

public JsonbMethodCallConverter(IExpressionVisitorFactory visitorFactory)
{
    _visitorFactory = visitorFactory;
}


public bool IsApplicable(MethodCallExpression expression)
{
    return expression.Method.ReflectedType == typeof(JsonbEfCoreDesignTriggerExtensions) && expression.Method.Name == "ToJsonbNoOpEfComparer";
}


public SqlBuilder Visit(MethodCallExpression expression, VisitedMembers visitedMembers)
{
    var sqlBuilder = _visitorFactory.Visit(expression.Arguments.First(), visitedMembers);
    return sqlBuilder.Append("::jsonb");
}

}
`

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

When branches are created from issues, their pull requests are automatically linked.

1 participant