Giter Club home page Giter Club logo

Comments (4)

maratbakirov avatar maratbakirov commented on July 18, 2024

here is the caml query i got the first time
caml query : <View Scope="RecursiveAll"><ViewFields><FieldRef Name="ID" /><FieldRef Name="Created" /></ViewFields><RowLimit Paged="TRUE">10</RowLimit><Query> <Where><And><Geq><FieldRef Name="Created" /><Value IncludeTimeValue="True" Type="DateTime">2008-12-31T15:00:00.000Z</Value></Geq><Leq><FieldRef Name="Created" /><Value IncludeTimeValue="True" Type="DateTime">2020-01-01T16:00:00.000Z</Value></Leq></And></Where></Query></View>

here is the one i got a second time

caml query : <View Scope="RecursiveAll"><ViewFields><FieldRef Name="ID" /><FieldRef Name="Created" /></ViewFields><RowLimit Paged="TRUE">10</RowLimit><Query> <Where><And><And><Geq><FieldRef Name="Created" /><Value IncludeTimeValue="True" Type="DateTime">2008-12-31T15:00:00.000Z</Value></Geq><Leq><FieldRef Name="Created" /><Value IncludeTimeValue="True" Type="DateTime">2020-01-01T16:00:00.000Z</Value></Leq></And></And></Where></Query>

note the extra opening and closing And that made the caml query invalid.

from camljs.

maratbakirov avatar maratbakirov commented on July 18, 2024

might be related to #14

from camljs.

andrei-markeev avatar andrei-markeev commented on July 18, 2024

Thanks for reporting, will look into this soon!

from camljs.

andrei-markeev avatar andrei-markeev commented on July 18, 2024

Issue happens because CamlBuilder is stateful, so you cannot really reuse it to produce several queries, rather, you would need to create a new CamlBuilder for each query. So after you call ToString() or ToCamlQuery(), the builder shouldn't be used anymore.

So what happened in your particular case, you essentially did something like this:

new CamlBuilder()
       .View(["ID", "Created"])
       .RowLimit(pageSize, true)
       .Scope(CamlBuilder.ViewScope.RecursiveAll).Query().Where()
       .All(this.expressions)
       .All(this.expressions) // notice the second "All", this is of course invalid
       .ToString();

For now, I am planning to add a check so that people aren't getting confused and will get some human-friendly error message instead of silently getting a potentially incorrect query.

There's of course an option to make a deep copy of the state every time when returning the object in every chain call, but it is quite bad for performance.

from camljs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.