Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex queries #4

Open
dlid opened this issue Oct 27, 2017 · 2 comments
Open

Complex queries #4

dlid opened this issue Oct 27, 2017 · 2 comments
Labels

Comments

@dlid
Copy link
Owner

dlid commented Oct 27, 2017

Complex groups will break

SELECT * FROM [Decisions] WHERE [Title] LIKE ? AND (([Motivation] IS NULL AND [IsBoss] = ?) or (P = ? AND P2 < ?))

@dlid
Copy link
Owner Author

dlid commented Nov 1, 2017

Yes, quite broken... This is the generated xml

<View>
    <Query>
        <Where>
            <And>
                <Contains>
                    <FieldRef Name="Title" />
                    <Value Type="Text">summer</Value>
                </Contains>
                <And>
                    <IsNull>
                        <FieldRef Name="Motivation" />
                    </IsNull>
                    <Or>
                        <Eq>
                            <FieldRef Name="IsBoss" />
                            <Value Type="Text">did</Value>
                        </Eq>
                        <And>
                            <Eq>
                                <FieldRef Name="P" />
                                <Value Type="Number">10</Value>
                            </Eq>
                            <Lt>
                                <FieldRef Name="P2" />
                                <Value Type="Number">6</Value>
                            </Lt>
                        </And>
                    </Or>
                </And>
            </And>
        </Where>
    </Query>
</View>

There should be an OR in there... I have to think about what this should look like when it's not so late...

@dlid dlid added the bug label Nov 1, 2017
@dlid
Copy link
Owner Author

dlid commented Nov 5, 2017

Hm, I think it should actually look like this...

<View>
    <Query>
        <Where>
            <And>
                <Contains>
                    <FieldRef Name="Title" />
                    <Value Type="Text">The title</Value>
                </Contains>
                <Or>
                    <And>
                        <IsNull>
                            <FieldRef Name="Motivation" />
                        </IsNull>
                        <Eq>
                            <FieldRef Name="IsBoss" />
                            <Value Type="Text">He-Man</Value>
                        </Eq>
                    </And>
                    <And>
                        <Eq>
                            <FieldRef Name="P" />
                            <Value Type="Number">1000</Value>
                        </Eq>
                        <Lt>
                            <FieldRef Name="P2" />
                            <Value Type="Number">3500</Value>
                        </Lt>
                    </And>
                </Or>
            </And>
        </Where>
    </Query>
</View>

This result is from removing the () from the second part of the where statement:

camlsql.prepare('SELECT * FROM [Decisions] WHERE [Title] LIKE ? AND ([Motivation] IS NULL AND [IsBoss] = ?) or (P = ? AND P2 < ?)', ['The title', 'He-Man', 1000, 3500])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant