Skip to content

Commit cec9334

Browse files
committed
Do not force json
We are using scaffolding to create our database classes. Sadly, the scaffold does not support json on the json field, instead opting for string. This change will let the user use JSON functions more freely
1 parent 14c2cd5 commit cec9334

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

src/EFCore.MySql/Query/ExpressionTranslators/Internal/MySqlJsonDbFunctionsTranslator.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,7 @@ public virtual SqlExpression Translate(
145145

146146
return result;
147147

148-
SqlExpression Json(SqlExpression e) => _sqlExpressionFactory.ApplyTypeMapping(EnsureJson(e), _sqlExpressionFactory.FindMapping(e.Type, "json"));
149-
150-
static SqlExpression EnsureJson(SqlExpression e)
151-
=> e.TypeMapping is MySqlJsonTypeMapping ||
152-
e is MySqlJsonTraversalExpression
153-
? e
154-
: throw new InvalidOperationException("The JSON method requires a JSON parameter but none was found.");
148+
SqlExpression Json(SqlExpression e) => _sqlExpressionFactory.ApplyTypeMapping(e, _sqlExpressionFactory.FindMapping(e.Type, "json"));
155149

156150
static SqlExpression RemoveConvert(SqlExpression e)
157151
{

0 commit comments

Comments
 (0)