public ScriptInput(Transformation transformation) { DefaultCollections = new HashSet <string>(transformation.Collections, StringComparer.OrdinalIgnoreCase); if (string.IsNullOrEmpty(transformation.Script)) { return; } Transformation = new PatchRequest(transformation.Script, PatchRequestType.RavenEtl); LoadToCollections = transformation.GetCollectionsFromScript(); foreach (var collection in LoadToCollections) { IdPrefixForCollection[collection] = DocumentConventions.DefaultTransformCollectionNameToDocumentIdPrefix(collection); } if (transformation.Collections == null) { return; } _collectionNameComparisons = new Dictionary <string, Dictionary <string, bool> >(transformation.Collections.Count); foreach (var sourceCollection in transformation.Collections) { _collectionNameComparisons[sourceCollection] = new Dictionary <string, bool>(transformation.Collections.Count); foreach (var loadToCollection in LoadToCollections) { _collectionNameComparisons[sourceCollection][loadToCollection] = string.Compare(sourceCollection, loadToCollection, StringComparison.OrdinalIgnoreCase) == 0; } } }
public ScriptInput(Transformation transformation) { DefaultCollections = new HashSet <string>(transformation.Collections, StringComparer.OrdinalIgnoreCase); if (string.IsNullOrWhiteSpace(transformation.Script)) { return; } if (transformation.IsEmptyScript == false) { Transformation = new PatchRequest(transformation.Script, PatchRequestType.RavenEtl); } if (transformation.CollectionToLoadCounterBehaviorFunction != null) { _collectionToLoadCounterBehaviorFunction = transformation.CollectionToLoadCounterBehaviorFunction; } if (transformation.CollectionToDeleteDocumentsBehaviorFunction != null) { _collectionToDeleteDocumentBehaviorFunction = transformation.CollectionToDeleteDocumentsBehaviorFunction; } if (HasLoadCounterBehaviors || HasDeleteDocumentsBehaviors) { BehaviorFunctions = new PatchRequest(transformation.Script, PatchRequestType.EtlBehaviorFunctions); } if (transformation.IsEmptyScript == false) { LoadToCollections = transformation.GetCollectionsFromScript(); } foreach (var collection in LoadToCollections) { IdPrefixForCollection[collection] = DocumentConventions.DefaultTransformCollectionNameToDocumentIdPrefix(collection); } if (transformation.Collections == null) { return; } _collectionNameComparisons = new Dictionary <string, Dictionary <string, bool> >(transformation.Collections.Count); foreach (var sourceCollection in transformation.Collections) { _collectionNameComparisons[sourceCollection] = new Dictionary <string, bool>(transformation.Collections.Count); foreach (var loadToCollection in LoadToCollections) { _collectionNameComparisons[sourceCollection][loadToCollection] = string.Compare(sourceCollection, loadToCollection, StringComparison.OrdinalIgnoreCase) == 0; } } }
private void EnsureQueryHasOnlyFromClause(QueryMetadata metadata, string collection) { if (metadata.IsCollectionQuery == false || metadata.Query.Select != null || metadata.Query.Include != null || metadata.Query.From.Filter != null) { var docPrefix = $"{DocumentConventions.DefaultTransformCollectionNameToDocumentIdPrefix(collection)}"; throw new BadRequestException("Patch and delete documents by a dynamic query is supported only for queries having just FROM clause " + "and optionally simple WHERE filtering using '=' or 'IN' operators on document identifiers, " + $"e.g. FROM {collection}, FROM {collection} WHERE id() = '{docPrefix}/1', FROM {collection} WHERE id() IN ('{docPrefix}/1', '{docPrefix}/2'). " + "If you need to perform different filtering please issue the query to the static index."); } }