@@ -42,7 +42,12 @@ public class CrudSource(
4242 string [ ] ? includeNames = null ,
4343 string [ ] ? excludeNames = null ,
4444 string ? query = null ,
45- CrudCommandType crudTypes = CrudCommandType . All ) : IRoutineSource
45+ CrudCommandType crudTypes = CrudCommandType . All ,
46+ string returningUrlPattern = "{0}/returning" ,
47+ string onConflictDoNothingUrlPattern = "{0}/on-conflict-do-nothing" ,
48+ string onConflictDoNothingReturningUrlPattern = "{0}/on-conflict-do-nothing/returning" ,
49+ string onConflictDoUpdateUrlPattern = "{0}/on-conflict-do-update" ,
50+ string onConflictDoUpdateReturningUrlPattern = "{0}/on-conflict-do-update/returning" ) : IRoutineSource
4651{
4752 private readonly IRoutineSourceParameterFormatter _selectParameterFormatter = new SelectParameterFormatter ( ) ;
4853 private readonly IRoutineSourceParameterFormatter _updateParameterFormatter = new UpdateParameterFormatter ( ) ;
@@ -69,6 +74,11 @@ public class CrudSource(
6974 public bool InsertOnConflictDoUpdateReturning { get ; init ; } = ( crudTypes & CrudCommandType . InsertOnConflictDoUpdateReturning ) == CrudCommandType . InsertOnConflictDoUpdateReturning ;
7075 public bool Delete { get ; init ; } = ( crudTypes & CrudCommandType . Delete ) == CrudCommandType . Delete ;
7176 public bool DeleteReturning { get ; init ; } = ( crudTypes & CrudCommandType . DeleteReturning ) == CrudCommandType . DeleteReturning ;
77+ public string ReturningUrlPattern { get ; init ; } = returningUrlPattern ;
78+ public string OnConflictDoNothingUrlPattern { get ; init ; } = onConflictDoNothingUrlPattern ;
79+ public string OnConflictDoNothingReturningUrlPattern { get ; init ; } = onConflictDoNothingReturningUrlPattern ;
80+ public string OnConflictDoUpdateUrlPattern { get ; init ; } = onConflictDoUpdateUrlPattern ;
81+ public string OnConflictDoUpdateReturningUrlPattern { get ; init ; } = onConflictDoUpdateReturningUrlPattern ;
7282
7383 public IEnumerable < ( Routine , IRoutineSourceParameterFormatter ) > Read ( NpgsqlRestOptions options )
7484 {
@@ -232,7 +242,7 @@ Routine CreateRoutine(
232242 fullDefinition : string . Concat ( updateDef , returningExp ) ,
233243 simpleDefinition : string . Concat ( updateSimple , returningExp ) ,
234244 isVoid : false ,
235- formatUrlPattern : "{0}/returning" ) ,
245+ formatUrlPattern : ReturningUrlPattern ) ,
236246 _updateParameterFormatter ) ;
237247 }
238248
@@ -272,7 +282,7 @@ Routine CreateRoutine(
272282 fullDefinition : string . Concat ( insertDef , returningExp ) ,
273283 simpleDefinition : string . Concat ( insertSimple , returningExp ) ,
274284 isVoid : false ,
275- formatUrlPattern : "{0}/returning" ) ,
285+ formatUrlPattern : ReturningUrlPattern ) ,
276286 _insertParameterFormatter ) ;
277287 }
278288
@@ -296,7 +306,7 @@ Routine CreateRoutine(
296306 fullDefinition : string . Concat ( insertDef , onConflict , "do nothing" ) ,
297307 simpleDefinition : string . Concat ( insertSimple , onConflict , "do nothing" ) ,
298308 isVoid : true ,
299- formatUrlPattern : "{0}/on-conflict-do-nothing" ) ,
309+ formatUrlPattern : OnConflictDoNothingUrlPattern ) ,
300310 _insertParameterFormatter ) ;
301311 }
302312
@@ -309,7 +319,7 @@ Routine CreateRoutine(
309319 fullDefinition : string . Concat ( insertDef , onConflict , "do nothing" , returningExp ) ,
310320 simpleDefinition : string . Concat ( insertSimple , onConflict , "do nothing" , returningExp ) ,
311321 isVoid : false ,
312- formatUrlPattern : "{0}/on-conflict-do-nothing/returning" ) ,
322+ formatUrlPattern : OnConflictDoNothingReturningUrlPattern ) ,
313323 _insertParameterFormatter ) ;
314324 }
315325
@@ -328,7 +338,7 @@ Routine CreateRoutine(
328338 fullDefinition : string . Concat ( insertDef , onConflict , doUpdate ) ,
329339 simpleDefinition : string . Concat ( insertSimple , onConflict , doUpdate ) ,
330340 isVoid : true ,
331- formatUrlPattern : "{0}/on-conflict-do-update" ) ,
341+ formatUrlPattern : OnConflictDoUpdateUrlPattern ) ,
332342 _insertParameterFormatter ) ;
333343 }
334344
@@ -341,7 +351,7 @@ Routine CreateRoutine(
341351 fullDefinition : string . Concat ( insertDef , onConflict , doUpdate , returningExp ) ,
342352 simpleDefinition : string . Concat ( insertSimple , onConflict , doUpdate , returningExp ) ,
343353 isVoid : false ,
344- formatUrlPattern : "{0}/on-conflict-do-update/returning" ) ,
354+ formatUrlPattern : OnConflictDoUpdateReturningUrlPattern ) ,
345355 _insertParameterFormatter ) ;
346356 }
347357 }
0 commit comments