devatwork / Premotion-Mansion

Developement project for the Premotion Mansion Framework
MIT License
3 stars 0 forks source link

OrSpecification does not work #167

Closed Erikvl87 closed 10 years ago

Erikvl87 commented 10 years ago

The OrSpecification is not working properly.

The following will not return any results:

<retrieveChildNodeset
        parentPointer="1"
        target="Results"
        where="{OrSpecification( IsSpecification( 'type', 'ContentIndexRoot' ), IsSpecification( 'type', 'Site' ) )}"
        bypassAuthorization="true">
        <loopNodeset source="{$Results}" target="Node">
            <renderText>#{Node.name}#</renderText>
        </loopNodeset>
    </retrieveChildNodeset>

While the following two specifications will work separately: {OrSpecification( IsSpecification( 'type', 'ContentIndexRoot' ) )} {OrSpecification( IsSpecification( 'type', 'Site' ) )}

For the above example an alternative would be the following: {InSpecification( 'type', 'ContentIndexRoot,Site' )}

But in my case I need to select the nodes where 'property A = value' or 'property B = value'.

devatwork commented 10 years ago

@Erikvl87 Can you add the generated SQL to this issue?

devatwork commented 10 years ago

I think I found the source of the issue: https://github.com/devatwork/Premotion-Mansion/blob/master/src/Premotion.Mansion.Repository.SqlServer/Queries/SqlStringBuilder.cs#L137-L139

Lets discus the right approach to fix this first.

Erikvl87 commented 10 years ago

Hi @devatwork, that's exactly were I ended my debug session yesterday. The solution was unclear though, as it seem to miss the right specification. I will contact you by mail.

Erikvl87 commented 10 years ago

@devatwork Here is the generated SQL you requested.

The abstract query that is generated:

{where:allowed-role-ids:any_where:child-of=1&1_cache-enabled:True_where:(type == ContentIndexRoottype == Site or )_sort:order asc}

That will generate the following MSSQL query:

SELECT [Nodes].*  FROM [Nodes] WHERE ([Nodes].[parentId] = @0) AND (( [Nodes].[type] = @1) AND ( [Nodes].[type] = @2)) ORDER BY [Nodes].[order] ASC;
SELECT COUNT(1) AS [TotalCount] FROM [Nodes] WHERE ([Nodes].[parentId] = @0) AND (( [Nodes].[type] = @1) AND ( [Nodes].[type] = @2));

Parameters:
@0      1
@1      "ContentIndexRoot"
@2      "Site"