I'm getting some possibly erroneous sql generation. Given expression building code equivalent to:
var allPermissions = GetFlattenedPermissions<Account>(user, operationName); var instanceLevel = allPermissions.Where(p=>p.EntitySecurityKey != null).Select(x=>x.EntitySecurityKey).Cast<Guid>(); var typeLevel = allPermissions.Where(p=>p.EntitySecurityKey == null); var result = accounts.Where(a=> typeLevel.Any() || instanceLevel.Contains(a.SecurityKey)); I'm getting the following sql: select account0_.Id as Id0_, account0_.SecurityKey as Security2_0_, account0_.Name as Name0_ from Accounts account0_ where exists ( select permission1_.Id from security_PermissionsFlattened permission1_ where permission1_.Allow=1 and permission1_.Operation='/Account/Edit' and permission1_."User"=1 and permission1_.EntityTypeName='Rhino.Security.Tests.Account, Rhino.Security.Tests' and (permission1_.EntitySecurityKey is null)) or exists ( select permission2_.EntitySecurityKey from security_PermissionsFlattened permission2_ where permission2_.Allow=1 and permission2_.Operation='/Account/Edit' and permission2_."User"=1 and permission2_.EntityTypeName='Rhino.Security.Tests.Account, Rhino.Security.Tests' and (permission2_.EntitySecurityKey is not null) and permission2_.Id=account0_.SecurityKey) I'm at a loss as to why permission2_Id is being involved here at all. I would have expected that last clause to look more like: or account0_.SecurityKey ( select permission2_.EntitySecurityKey from security_PermissionsFlattened permission2_ where permission2_.Allow=1 and permission2_.Operation='/Account/Edit' and permission2_."User"=1 and permission2_.EntityTypeName='Rhino.Security.Tests.Account, Rhino.Security.Tests' and (permission2_.EntitySecurityKey is not null)) I've pushed the linq stuff up to https://github.com/jeffreyabecker/rhino-security in hopes someone might be able to suggest something. Alternatively I could try dropping the view but I'm not sure how that would help. On Thu, Sep 22, 2011 at 8:46 AM, Jeffrey Becker <[email protected]>wrote: > I'm having some issues wrt the flattened permissions / linq at the moment > once I get that working sans ints I'll submit a pull request. > > As for the int's thing: I dont see how it can ever be anything but a > branch. The code changes are minimal (replace Guid with int/long) but are > something that has to be done at compile time. There are slight mapping > changes as well: the guidcomb generators are replaced with identities and > the unique key on EntityReference.EntitySecurityKey is expanded to include > EntityType. > > > On Wed, Sep 21, 2011 at 10:45 PM, Nathan Stott <[email protected]> wrote: > >> That sounds great, Jeff. Look forward to seeing it. >> >> The ID change if it breaks backwards compatibility is not good though. >> I'd have no problem merging something into master that made that an option >> though. >> >> >> On Wed, Sep 21, 2011 at 11:10 AM, Jeff <[email protected]>wrote: >> >>> I have will have _a_ version in github soon. However I was crappy >>> about commits and it has the following features munged in: >>> * convert Id's to bigint/long/Int64 (I lost the guid battle at work) >>> * Upgrade to 3.2 (referenced github repo is 3.1) -- this seams to >>> have broken the hell out of the tests due to sqlite driver / dialect >>> issues in 3.2. I'm confident this is a non-issue as using sql server >>> for testing continues to break in consistent ways. >>> * Integration of the flattened security views I posted about last >>> year. -- This simplifies the query from a subselect to a simple in >>> against a view which should improve performance in cases where the >>> result-set is large however I'm not sure how cross-db the referenced >>> sql is. >>> >>> On Sep 20, 5:27 pm, sabanito <[email protected]> wrote: >>> > Do you have it in Github to take a look at it? >>> > >>> > On 20 sep, 12:22, Jeff <[email protected]> wrote: >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > > Hi, I'm in the middle of my own rhino-security / NH 3.x issues. It >>> > > seems upgrading the NH version to 3.2 causes some issues: >>> > >>> > > * Rhino.Commons doesn't seem to be available against 3.x which >>> means >>> > > the active record assembly is pretty much toast >>> > > * There seem to be a significant number of test failures due to >>> what >>> > > look like sql generation bugs in sqlite. switching over to using >>> > > mssql for the tests seems to fix most (but not all) of these but >>> makes >>> > > the tests painful >>> > >>> > > I was looking at a syntax like: >>> > > _session.Query<Widget>().WithPermissions(currentUser, "frob") >>> > >>> > > On Sep 20, 11:13 am, sabanito <[email protected]> wrote: >>> > >>> > > > Hi There, >>> > >>> > > > I'm using Rhino Security with NH 2.1.2. I'm using NH.Linq for all >>> my >>> > > > queries, and since I needed to use the "AddPermissionsToQuery" I >>> used >>> > > > the same that NH.Linq uses to convert Linq to ICriteria (http:// >>> > > > >>> stackoverflow.com/questions/684696/nhibernate-linq-and-multicriteria). >>> > > > I'm thinking to upgrade my NH to 3.0, and I've read that it no >>> longer >>> > > > converts Linq to ICriteria, since its Linq was rewritten. >>> > >>> > > > I'm willing to extend Rhino Security to add permissions to an >>> > > > IQueryable >>> > >>> > > > Any guidance there? >>> > >>> > > > Thx! >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Rhino Tools Dev" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/rhino-tools-dev?hl=en. >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Rhino Tools Dev" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/rhino-tools-dev?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en.
