Pomelo.EntityFrameworkCore.MySql icon indicating copy to clipboard operation
Pomelo.EntityFrameworkCore.MySql copied to clipboard

Integer division (DIV) not supported

Open meriturva opened this issue 1 year ago • 1 comments

Just an easy request, is it possible to support the DIV Integer division operator?

https://dev.mysql.com/doc/refman/8.4/en/arithmetic-functions.html#operator_div

https://mariadb.com/kb/en/div/

I usually use Math.Truncate and sometimes Math.Floor but we have direct support of integer division on MySql and MariaDb and I guess it will be nice to support it.

Thanks.

meriturva avatar Jul 15 '24 10:07 meriturva

We already support and use it internally with MySqlBinaryExpression, with https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/fde68289cfe3d8ace93dc3a949b8ccd3143d06d9/src/EFCore.MySql/Query/Internal/MySqlSqlExpressionFactory.cs#L204-L212

and

https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/fde68289cfe3d8ace93dc3a949b8ccd3143d06d9/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlQuerySqlGenerator.cs#L837-L872

The simplest way to expose it publicly would probably be to make it available as an extension method on EF.Functions.

lauxjpn avatar Dec 08 '24 04:12 lauxjpn