Laraue.EfCoreTriggers
Laraue.EfCoreTriggers copied to clipboard
Support for mapped JSON types in Postgres
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<T> : 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");
}
} `