casbin-net / efcore-adapter

Entity Framework Core Adapter for Casbin.NET
https://github.com/casbin/Casbin.NET
Apache License 2.0
48 stars 21 forks source link

Fix for #35 Update CasbinRuleExtenstion.cs #36

Closed kbsiva closed 3 years ago

kbsiva commented 3 years ago

Fix: https://github.com/casbin-net/EFCore-Adapter/issues/35

hsluoyz commented 3 years ago

@Sagilio please review.

/cc @huazhikui @xcaptain

sagilio commented 3 years ago

The "=" (Equals) is different from "like" (Contains). I think these changes will impact the DB that is not SQL Server. The best way to fix this error is to change the field type "text" to "vchar" at the migration file. What do you think about this PR? @xcaptain .

hsluoyz commented 3 years ago

@xcaptain @huazhikui

kbsiva commented 3 years ago

Hi @Sagilio, if we use String.Equals again it generates below query and we get the same error.

DECLARE @__policyType_0 nvarchar(4000) = N'p'; DECLARE @__field_1 nvarchar(4000) = N'PRLEdit';

SELECT [c].[Id], [c].[PType], [c].[V0], [c].[V1], [c].[V2], [c].[V3], [c].[V4], [c].[V5] FROM [CasbinRule] AS [c] WHERE ([c].[PType] = @__policyType_0) AND ([c].[V3] = @__field_1)

The data types text and nvarchar are incompatible in the equal to operator.

hope we need to try with data type change only. sorry for the delay in response.

On Fri, 22 Jan 2021 at 01:18, Sagilio notifications@github.com wrote:

@Sagilio commented on this pull request.

Can changing to "Equals" fix your issue? The same SQL will be generated by using "==" or "Equals".

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/casbin-net/EFCore-Adapter/pull/36#pullrequestreview-573680569, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGTE4TXDIN4ITGPD3J4CEELS3CAJDANCNFSM4WGZMOSA .

hsluoyz commented 3 years ago

@Sagilio

sagilio commented 3 years ago

Hi @Sagilio, if we use String.Equals again it generates below query and we get the same error. DECLARE @policyType_0 nvarchar(4000) = N'p'; DECLARE @__field_1 nvarchar(4000) = N'PRLEdit'; SELECT [c].[Id], [c].[PType], [c].[V0], [c].[V1], [c].[V2], [c].[V3], [c].[V4], [c].[V5] FROM [CasbinRule] AS [c] WHERE ([c].[PType] = @policyType_0) AND ([c].[V3] = @__field_1) The data types text and nvarchar are incompatible in the equal to operator. hope we need to try with data type change only. sorry for the delay in response. On Fri, 22 Jan 2021 at 01:18, Sagilio @.**> wrote: @Sagilio* commented on this pull request. Can changing to "Equals" fix your issue? The same SQL will be generated by using "==" or "Equals". — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#36 (review)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGTE4TXDIN4ITGPD3J4CEELS3CAJDANCNFSM4WGZMOSA .

Yes, it just needs you to change the migration file. I will close this PR because we do not need this.