@@ -362,7 +362,7 @@ public struct Query {
362
362
363
363
}
364
364
365
- private func insertStatement( values : [ Setter ] , or: OnConflict ? = nil ) -> Statement {
365
+ private func insertStatement( or: OnConflict ? = nil , _ values : [ Setter ] ) -> Statement {
366
366
var insertClause = " INSERT "
367
367
if let or = or { insertClause = " \( insertClause) OR \( or. rawValue) " }
368
368
var expressions : [ Expressible ] = [ Expression < ( ) > ( literal: " \( insertClause) INTO \( tableName. unaliased. SQL) " ) ]
@@ -434,41 +434,55 @@ public struct Query {
434
434
435
435
/// Runs an INSERT statement against the query.
436
436
///
437
- /// :param: values A list of values to set.
437
+ /// :param: action An action to run in case of a conflict.
438
+ /// :param: value A value to set.
439
+ /// :param: more A list of additional values to set.
438
440
///
439
441
/// :returns: The statement.
440
- public func insert( value: Setter , _ more: Setter ... ) -> Statement { return insert ( [ value] + more) . statement }
442
+ public func insert( or action: OnConflict ? = nil , _ value: Setter , _ more: Setter ... ) -> Statement {
443
+ return insert ( [ value] + more) . statement
444
+ }
441
445
442
446
/// Runs an INSERT statement against the query.
443
447
///
444
- /// :param: values A list of values to set.
448
+ /// :param: action An action to run in case of a conflict.
449
+ /// :param: value A value to set.
450
+ /// :param: more A list of additional values to set.
445
451
///
446
452
/// :returns: The rowid.
447
- public func insert( value: Setter , _ more: Setter ... ) -> Int64 ? { return insert ( [ value] + more) . rowid }
453
+ public func insert( or action: OnConflict ? = nil , _ value: Setter , _ more: Setter ... ) -> Int64 ? {
454
+ return insert ( or: action, [ value] + more) . rowid
455
+ }
448
456
449
457
/// Runs an INSERT statement against the query.
450
458
///
451
- /// :param: values A list of values to set.
459
+ /// :param: action An action to run in case of a conflict.
460
+ /// :param: value A value to set.
461
+ /// :param: more A list of additional values to set.
452
462
///
453
463
/// :returns: The rowid and statement.
454
- public func insert( value: Setter , _ more: Setter ... ) -> ( rowid: Int64 ? , statement: Statement ) {
455
- return insert ( [ value] + more)
464
+ public func insert( or action : OnConflict ? = nil , _ value: Setter , _ more: Setter ... ) -> ( rowid: Int64 ? , statement: Statement ) {
465
+ return insert ( or : action , [ value] + more)
456
466
}
457
467
458
468
/// Runs an INSERT statement against the query.
459
469
///
470
+ /// :param: action An action to run in case of a conflict.
460
471
/// :param: values An array of values to set.
461
472
///
462
473
/// :returns: The rowid.
463
- public func insert( values: [ Setter ] ) -> Int64 ? { return insert ( values) . rowid }
474
+ public func insert( or action: OnConflict ? = nil , _ values: [ Setter ] ) -> Int64 ? {
475
+ return insert ( or: action, values) . rowid
476
+ }
464
477
465
478
/// Runs an INSERT statement against the query.
466
479
///
480
+ /// :param: action An action to run in case of a conflict.
467
481
/// :param: values An array of values to set.
468
482
///
469
483
/// :returns: The rowid and statement.
470
- public func insert( values: [ Setter ] ) -> ( rowid: Int64 ? , statement: Statement ) {
471
- let statement = insertStatement ( values) . run ( )
484
+ public func insert( or action : OnConflict ? = nil , _ values: [ Setter ] ) -> ( rowid: Int64 ? , statement: Statement ) {
485
+ let statement = insertStatement ( or : action , values) . run ( )
472
486
return ( statement. failed ? nil : database. lastInsertRowid, statement)
473
487
}
474
488
@@ -491,46 +505,6 @@ public struct Query {
491
505
return ( statement. failed ? nil : database. lastInsertRowid, statement)
492
506
}
493
507
494
- /// Runs a REPLACE statement against the query.
495
- ///
496
- /// :param: values A list of values to set.
497
- ///
498
- /// :returns: The statement.
499
- public func replace( values: Setter ... ) -> Statement { return replace ( values) . statement }
500
-
501
- /// Runs a REPLACE statement against the query.
502
- ///
503
- /// :param: values A list of values to set.
504
- ///
505
- /// :returns: The rowid.
506
- public func replace( values: Setter ... ) -> Int64 ? { return replace ( values) . rowid }
507
-
508
- /// Runs a REPLACE statement against the query.
509
- ///
510
- /// :param: values A list of values to set.
511
- ///
512
- /// :returns: The rowid and statement.
513
- public func replace( values: Setter ... ) -> ( rowid: Int64 ? , statement: Statement ) {
514
- return replace ( values)
515
- }
516
-
517
- /// Runs a REPLACE statement against the query.
518
- ///
519
- /// :param: values An array of values to set.
520
- ///
521
- /// :returns: The rowid.
522
- public func replace( values: [ Setter ] ) -> Int64 ? { return replace ( values) . rowid }
523
-
524
- /// Runs a REPLACE statement against the query.
525
- ///
526
- /// :param: values An array of values to set.
527
- ///
528
- /// :returns: The rowid and statement.
529
- public func replace( values: [ Setter ] ) -> ( rowid: Int64 ? , statement: Statement ) {
530
- let statement = insertStatement ( values, or: . Replace) . run ( )
531
- return ( statement. failed ? nil : database. lastInsertRowid, statement)
532
- }
533
-
534
508
/// Runs an UPDATE statement against the query.
535
509
///
536
510
/// :param: values A list of values to set.
0 commit comments