@@ -362,7 +362,7 @@ public struct Query {
362362
363363 }
364364
365- private func insertStatement( values : [ Setter ] , or: OnConflict ? = nil ) -> Statement {
365+ private func insertStatement( or: OnConflict ? = nil , _ values : [ Setter ] ) -> Statement {
366366 var insertClause = " INSERT "
367367 if let or = or { insertClause = " \( insertClause) OR \( or. rawValue) " }
368368 var expressions : [ Expressible ] = [ Expression < ( ) > ( literal: " \( insertClause) INTO \( tableName. unaliased. SQL) " ) ]
@@ -434,41 +434,55 @@ public struct Query {
434434
435435 /// Runs an INSERT statement against the query.
436436 ///
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.
438440 ///
439441 /// :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+ }
441445
442446 /// Runs an INSERT statement against the query.
443447 ///
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.
445451 ///
446452 /// :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+ }
448456
449457 /// Runs an INSERT statement against the query.
450458 ///
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.
452462 ///
453463 /// :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)
456466 }
457467
458468 /// Runs an INSERT statement against the query.
459469 ///
470+ /// :param: action An action to run in case of a conflict.
460471 /// :param: values An array of values to set.
461472 ///
462473 /// :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+ }
464477
465478 /// Runs an INSERT statement against the query.
466479 ///
480+ /// :param: action An action to run in case of a conflict.
467481 /// :param: values An array of values to set.
468482 ///
469483 /// :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 ( )
472486 return ( statement. failed ? nil : database. lastInsertRowid, statement)
473487 }
474488
@@ -491,46 +505,6 @@ public struct Query {
491505 return ( statement. failed ? nil : database. lastInsertRowid, statement)
492506 }
493507
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-
534508 /// Runs an UPDATE statement against the query.
535509 ///
536510 /// :param: values A list of values to set.
0 commit comments