File tree Expand file tree Collapse file tree 4 files changed +26
-7
lines changed
Expand file tree Collapse file tree 4 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export const CONSTANTS = {
2828 RAVEN_JS_TYPE : "Raven-Node-Type" ,
2929 CHANGE_VECTOR : "@change-vector" ,
3030 EXPIRES : "@expires" ,
31+ ALL_DOCUMENTS_COLLECTION : "@all_docs" ,
3132 EMPTY_COLLECTION : "@empty" ,
3233 NESTED_OBJECT_TYPES : "@nested-object-types" ,
3334 IGNORE_CASE_TRANSFORM_REGEX :
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { DocumentConventions } from "./Conventions/DocumentConventions";
2020import { ServerNode } from "../Http/ServerNode" ;
2121import { AbstractCallback } from "../Types/Callbacks" ;
2222import { passResultToCallback } from "../Utility/PromiseUtil" ;
23+ import { BatchOperation } from "./Session/Operations/BatchOperation" ;
2324
2425export class BulkInsertOperation {
2526 private readonly _generateEntityIdOnTheClient : GenerateEntityIdOnTheClient ;
@@ -191,7 +192,23 @@ export class BulkInsertOperation {
191192 }
192193
193194 const jsonString = JsonSerializer . getDefault ( ) . serialize ( json ) ;
194- this . _currentWriter . push ( `{"Id":"${ id } ","Type":"PUT","Document":${ jsonString } }` ) ;
195+ this . _currentWriter . push ( `{"Id":"${ BulkInsertOperation . _writeId ( id ) } ","Type":"PUT","Document":${ jsonString } }` ) ;
196+ }
197+
198+ private static _writeId ( input : string ) : string {
199+ let result = "" ;
200+ for ( let i = 0 ; i < input . length ; i ++ ) {
201+ const c = input [ i ] ;
202+ if ( `"` === c ) {
203+ if ( i === 0 || input [ i - 1 ] !== `\\` ) {
204+ result += `\\` ;
205+ }
206+ }
207+
208+ result += c ;
209+ }
210+
211+ return result ;
195212 }
196213
197214 private async _checkIfBulkInsertWasAborted ( ) {
Original file line number Diff line number Diff line change @@ -17,17 +17,15 @@ export class ConfigureRevisionsOperation implements IMaintenanceOperation<Config
1717 }
1818
1919 public getCommand ( conventions : DocumentConventions ) : RavenCommand < ConfigureRevisionsOperationResult > {
20- return new ConfigureRevisionsCommand ( conventions , this . _configuration ) ;
20+ return new ConfigureRevisionsCommand ( this . _configuration ) ;
2121 }
2222}
2323
2424export class ConfigureRevisionsCommand extends RavenCommand < ConfigureRevisionsOperationResult > {
25- private readonly _conventions : DocumentConventions ;
2625 private readonly _configuration : RevisionsConfiguration ;
2726
28- public constructor ( conventions : DocumentConventions , configuration : RevisionsConfiguration ) {
27+ public constructor ( configuration : RevisionsConfiguration ) {
2928 super ( ) ;
30- this . _conventions = conventions ;
3129 this . _configuration = configuration ;
3230 }
3331
Original file line number Diff line number Diff line change @@ -400,7 +400,9 @@ export class DocumentSession extends InMemoryDocumentSessionOperations
400400 }
401401
402402 const patchRequest = new PatchRequest ( ) ;
403- patchRequest . script = "this." + path + " += args.val_" + this . _valsCount + ";" ;
403+ const variable = `this.${ path } ` ;
404+ const value = `args.val_${ this . _valsCount } ` ;
405+ patchRequest . script = `${ variable } = ${ variable } ? ${ variable } + ${ value } : ${ value } ;` ;
404406 const valKey = "val_" + this . _valsCount ;
405407 patchRequest . values = { [ valKey ] : valueToAdd } ;
406408
@@ -546,7 +548,8 @@ export class DocumentSession extends InMemoryDocumentSessionOperations
546548
547549 if ( ! isIndex && ! isCollection ) {
548550 const entityType = this . conventions . findEntityType ( opts . documentType ) ;
549- collection = this . conventions . getCollectionNameForType ( entityType ) ;
551+ collection = this . conventions . getCollectionNameForType ( entityType )
552+ || CONSTANTS . Documents . Metadata . ALL_DOCUMENTS_COLLECTION ;
550553 }
551554
552555 return { indexName, collection } ;
You can’t perform that action at this time.
0 commit comments