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

Allow to clone expressions #61

Open
viceice opened this issue Dec 6, 2022 · 2 comments
Open

Allow to clone expressions #61

viceice opened this issue Dec 6, 2022 · 2 comments

Comments

@viceice
Copy link
Contributor

viceice commented Dec 6, 2022

We currently do some parallel queries and those use some general expressions.
We can't simply reuse them, we need to clone them.
One workaround is to use lodash.deepClone, but i want to get rid of that library.
So for now i always need to recreate the partial expressionen for every query.

sample

import caml from 'camljs';

const w1 = new caml().View(['ID']).Query().Where();
const w2 = new caml().View(['ID']).Query().Where();
const expr = [caml.Expression().IntegerField('FSObjType').EqualTo(1)];

const q1 = w1.All(expr);
const q2 = w2.All(expr);

console.assert(q1.get_viewXml() === q2.get_viewXml(), "Error: query mismatch");
@andrei-markeev
Copy link
Owner

I tested a bit and if I create an expression, I can reuse it to create multiple other queries without any issues.

The example you provided, well it doesn't work because there's no get_viewXml method on the CamlBuilder object, but if I use ToString(), it works fine.

Can you provide a different example or improve this one so that it can be used to reproduce the problem? 🙏

@viceice
Copy link
Contributor Author

viceice commented Dec 6, 2022

sorry, will check again. forgot the toCamlQuery call 😅

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

No branches or pull requests

2 participants