skip_activerecord_callbacks 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ v0.1.2
2
+
3
+ * Corrects update_without_callbacks to skip :create and :update
4
+
1
5
  v0.1.1
2
6
 
3
7
  * Adds destroy_without_callbacks
data/README.md CHANGED
@@ -14,6 +14,7 @@ little while longer. I'm sorry.
14
14
  ## Usage
15
15
 
16
16
  product.update_without_callbacks
17
+ product.destroy_without_callbacks
17
18
 
18
19
  ## Implementation
19
20
 
@@ -24,6 +25,9 @@ which case it deletes itself, replaces the original `run_callbacks`
24
25
  method, and yields to the given block to do the work of saving the
25
26
  model.
26
27
 
28
+ The `destroy_without_callbacks` method does the same ninja editing for
29
+ `destroy`.
30
+
27
31
  ## Seriously?
28
32
 
29
33
  Yeah, I know. But it seems to work just fine. The undecoration is the first
@@ -33,3 +37,26 @@ the only way this could not work is if ActiveRecord failed to call the
33
37
  method twice in a save for some reason. Or if ActiveSupport stopped
34
38
  implementing callbacks with the `run_callbacks method`, but the tests
35
39
  should catch that.
40
+
41
+ ## What Could Possibly Go Wrong?
42
+
43
+ `destroy_without_callbacks` seems to behave a little bit differently
44
+ than the Rails 2 version. In Rails 2, it would apparently not call the
45
+ model's `destroy` method if it happened to define one. In the project
46
+ for which I wrote this, we had a guard protecting models from being
47
+ destroyed except via `destroy_without_callbacks`:
48
+
49
+ def destroy
50
+ raise "hell"
51
+ end
52
+
53
+ This is trivially fixable by moving the guard to a `before_destroy`
54
+ callback, or more correctly by moving the persistent object lifecycle
55
+ concerns up into a service model.
56
+
57
+ `update_without_callbacks` used to save the model without updating its
58
+ dirty attribute changes hash. This is no longer the case. I regard the
59
+ new behavior as more correct, to the extent that a hack built on a pile
60
+ of hacks can be considered to exhibit correctness, but if it's
61
+ problematic, it would be relatively easy to clone the changes hash and
62
+ push it back afterwards.
@@ -11,18 +11,19 @@ module SkipActiveRecordCallbacks
11
11
  end
12
12
  end
13
13
 
14
- # TODO: The cut and paste is sad
15
14
  class ModelDecorator
16
15
  def self.override_run_callbacks_to_skip_save_once(model)
17
16
  class << model
18
17
  alias :run_callbacks_orig :run_callbacks
19
18
  def run_callbacks(name, &block)
20
- if name == :save
19
+ if name == :update || name == :create
21
20
  class << self
22
21
  undef :run_callbacks
23
22
  alias :run_callbacks :run_callbacks_orig
24
23
  end
25
24
  yield
25
+ elsif name == :save
26
+ yield
26
27
  else
27
28
  run_callbacks_orig(name, &block)
28
29
  end
@@ -1,3 +1,3 @@
1
1
  module SkipActiverecordCallbacks
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -524,3 +524,900 @@ undefined local variable or method `action' for #<Product id: nil, name: "foo">
524
524
   (0.0ms) begin transaction
525
525
  SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
526
526
   (0.0ms) commit transaction
527
+  (0.0ms) begin transaction
528
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
529
+  (0.0ms) commit transaction
530
+  (0.0ms) begin transaction
531
+ SQL (2.9ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
532
+  (0.0ms) commit transaction
533
+  (0.0ms) begin transaction
534
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
535
+  (0.0ms) commit transaction
536
+  (0.0ms) begin transaction
537
+  (0.1ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 2
538
+  (0.0ms) commit transaction
539
+  (0.0ms) begin transaction
540
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
541
+  (0.0ms) commit transaction
542
+  (0.0ms) begin transaction
543
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
544
+  (0.0ms) commit transaction
545
+  (0.0ms) begin transaction
546
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 4
547
+  (0.0ms) commit transaction
548
+  (0.0ms) begin transaction
549
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
550
+  (0.0ms) commit transaction
551
+  (0.0ms) begin transaction
552
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 5]]
553
+  (0.0ms) commit transaction
554
+  (0.0ms) begin transaction
555
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
556
+  (0.0ms) commit transaction
557
+  (0.0ms) begin transaction
558
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
559
+  (0.0ms) commit transaction
560
+  (0.0ms) begin transaction
561
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
562
+  (0.0ms) commit transaction
563
+  (0.0ms) begin transaction
564
+ SQL (3.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
565
+  (0.0ms) commit transaction
566
+  (0.0ms) begin transaction
567
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
568
+  (0.0ms) commit transaction
569
+  (0.0ms) begin transaction
570
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
571
+  (0.0ms) commit transaction
572
+  (0.0ms) begin transaction
573
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
574
+  (0.0ms) commit transaction
575
+  (0.0ms) begin transaction
576
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 3
577
+  (0.0ms) commit transaction
578
+  (0.0ms) begin transaction
579
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
580
+  (0.0ms) commit transaction
581
+  (0.0ms) begin transaction
582
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
583
+  (0.0ms) commit transaction
584
+  (0.0ms) begin transaction
585
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 5]]
586
+  (0.0ms) commit transaction
587
+  (0.0ms) begin transaction
588
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
589
+  (0.0ms) commit transaction
590
+  (0.0ms) begin transaction
591
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
592
+  (0.0ms) commit transaction
593
+  (0.0ms) begin transaction
594
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 7
595
+  (0.0ms) commit transaction
596
+  (0.0ms) begin transaction
597
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
598
+  (0.0ms) commit transaction
599
+  (0.0ms) begin transaction
600
+ SQL (2.2ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
601
+  (0.0ms) commit transaction
602
+  (0.1ms) begin transaction
603
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
604
+  (0.0ms) commit transaction
605
+  (0.0ms) begin transaction
606
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
607
+  (0.0ms) commit transaction
608
+  (0.0ms) begin transaction
609
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
610
+  (0.0ms) commit transaction
611
+  (0.0ms) begin transaction
612
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
613
+  (0.0ms) commit transaction
614
+  (0.0ms) begin transaction
615
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 4
616
+  (0.0ms) commit transaction
617
+  (0.0ms) begin transaction
618
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
619
+  (0.0ms) commit transaction
620
+  (0.0ms) begin transaction
621
+  (0.0ms) rollback transaction
622
+  (0.0ms) begin transaction
623
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
624
+  (0.0ms) commit transaction
625
+  (0.0ms) begin transaction
626
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
627
+  (0.0ms) commit transaction
628
+  (0.0ms) begin transaction
629
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
630
+  (0.0ms) commit transaction
631
+  (0.0ms) begin transaction
632
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
633
+  (0.0ms) commit transaction
634
+  (0.0ms) begin transaction
635
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
636
+  (0.0ms) commit transaction
637
+  (0.0ms) begin transaction
638
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
639
+  (0.0ms) commit transaction
640
+  (0.0ms) begin transaction
641
+ SQL (2.4ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
642
+  (0.0ms) commit transaction
643
+  (0.0ms) begin transaction
644
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
645
+  (0.0ms) commit transaction
646
+  (0.0ms) begin transaction
647
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
648
+  (0.0ms) commit transaction
649
+  (0.0ms) begin transaction
650
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
651
+  (0.0ms) commit transaction
652
+  (0.0ms) begin transaction
653
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
654
+  (0.0ms) commit transaction
655
+  (0.0ms) begin transaction
656
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 4
657
+  (0.0ms) commit transaction
658
+  (0.0ms) begin transaction
659
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
660
+  (0.0ms) commit transaction
661
+  (0.0ms) begin transaction
662
+  (0.0ms) rollback transaction
663
+  (0.0ms) begin transaction
664
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
665
+  (0.0ms) commit transaction
666
+  (0.0ms) begin transaction
667
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
668
+  (0.0ms) commit transaction
669
+  (0.0ms) begin transaction
670
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
671
+  (0.0ms) commit transaction
672
+  (0.0ms) begin transaction
673
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
674
+  (0.0ms) commit transaction
675
+  (0.0ms) begin transaction
676
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
677
+  (0.0ms) commit transaction
678
+  (0.0ms) begin transaction
679
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
680
+  (0.0ms) commit transaction
681
+  (0.0ms) begin transaction
682
+ SQL (1.5ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
683
+  (0.0ms) commit transaction
684
+  (0.0ms) begin transaction
685
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
686
+  (0.0ms) commit transaction
687
+  (0.0ms) begin transaction
688
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
689
+  (0.0ms) commit transaction
690
+  (0.0ms) begin transaction
691
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
692
+  (0.0ms) commit transaction
693
+  (0.0ms) begin transaction
694
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
695
+  (0.0ms) commit transaction
696
+  (0.0ms) begin transaction
697
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 4
698
+  (0.0ms) commit transaction
699
+  (0.0ms) begin transaction
700
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
701
+  (0.0ms) commit transaction
702
+  (0.0ms) begin transaction
703
+  (0.0ms) rollback transaction
704
+  (0.0ms) begin transaction
705
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
706
+  (0.0ms) commit transaction
707
+  (0.0ms) begin transaction
708
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
709
+  (0.0ms) commit transaction
710
+  (0.0ms) begin transaction
711
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
712
+  (0.0ms) commit transaction
713
+  (0.0ms) begin transaction
714
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
715
+  (0.0ms) commit transaction
716
+  (0.0ms) begin transaction
717
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
718
+  (0.0ms) commit transaction
719
+  (0.0ms) begin transaction
720
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
721
+  (0.0ms) commit transaction
722
+  (0.0ms) begin transaction
723
+ SQL (9.9ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
724
+  (0.1ms) commit transaction
725
+  (0.1ms) begin transaction
726
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
727
+  (0.0ms) commit transaction
728
+  (0.0ms) begin transaction
729
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
730
+  (0.0ms) commit transaction
731
+  (0.0ms) begin transaction
732
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
733
+  (0.0ms) commit transaction
734
+  (0.0ms) begin transaction
735
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
736
+  (0.0ms) commit transaction
737
+  (0.0ms) begin transaction
738
+  (0.1ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 4
739
+  (0.0ms) commit transaction
740
+  (0.0ms) begin transaction
741
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
742
+  (0.0ms) commit transaction
743
+  (0.0ms) begin transaction
744
+  (0.0ms) rollback transaction
745
+  (0.0ms) begin transaction
746
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
747
+  (0.0ms) commit transaction
748
+  (0.0ms) begin transaction
749
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
750
+  (0.0ms) commit transaction
751
+  (0.0ms) begin transaction
752
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
753
+  (0.0ms) commit transaction
754
+  (0.0ms) begin transaction
755
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
756
+  (0.0ms) commit transaction
757
+  (0.0ms) begin transaction
758
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
759
+  (0.0ms) commit transaction
760
+  (0.0ms) begin transaction
761
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
762
+  (0.0ms) commit transaction
763
+  (0.0ms) begin transaction
764
+ SQL (1.6ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
765
+  (0.0ms) commit transaction
766
+  (0.0ms) begin transaction
767
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
768
+  (0.0ms) commit transaction
769
+  (0.0ms) begin transaction
770
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
771
+  (0.0ms) commit transaction
772
+  (0.0ms) begin transaction
773
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
774
+  (0.0ms) commit transaction
775
+  (0.0ms) begin transaction
776
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
777
+  (0.0ms) commit transaction
778
+  (0.0ms) begin transaction
779
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 4
780
+  (0.0ms) commit transaction
781
+  (0.0ms) begin transaction
782
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
783
+  (0.0ms) commit transaction
784
+  (0.0ms) begin transaction
785
+  (0.0ms) rollback transaction
786
+  (0.0ms) begin transaction
787
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
788
+  (0.0ms) commit transaction
789
+  (0.0ms) begin transaction
790
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
791
+  (0.0ms) commit transaction
792
+  (0.0ms) begin transaction
793
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
794
+  (0.0ms) commit transaction
795
+  (0.0ms) begin transaction
796
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 7
797
+  (0.0ms) commit transaction
798
+  (0.0ms) begin transaction
799
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
800
+  (0.0ms) commit transaction
801
+  (0.0ms) begin transaction
802
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
803
+  (0.0ms) commit transaction
804
+  (0.0ms) begin transaction
805
+ SQL (1.5ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
806
+  (0.0ms) commit transaction
807
+  (0.0ms) begin transaction
808
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
809
+  (0.0ms) commit transaction
810
+  (0.0ms) begin transaction
811
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
812
+  (0.0ms) commit transaction
813
+  (0.0ms) begin transaction
814
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
815
+  (0.0ms) commit transaction
816
+  (0.0ms) begin transaction
817
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
818
+  (0.0ms) commit transaction
819
+  (0.0ms) begin transaction
820
+  (0.0ms) rollback transaction
821
+  (0.0ms) begin transaction
822
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
823
+  (0.0ms) commit transaction
824
+  (0.0ms) begin transaction
825
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 5
826
+  (0.0ms) commit transaction
827
+  (0.0ms) begin transaction
828
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
829
+  (0.0ms) commit transaction
830
+  (0.0ms) begin transaction
831
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
832
+  (0.0ms) commit transaction
833
+  (0.0ms) begin transaction
834
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
835
+  (0.0ms) commit transaction
836
+  (0.0ms) begin transaction
837
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 7
838
+  (0.0ms) commit transaction
839
+  (0.0ms) begin transaction
840
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
841
+  (0.0ms) commit transaction
842
+  (0.0ms) begin transaction
843
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
844
+  (0.0ms) commit transaction
845
+  (0.0ms) begin transaction
846
+ SQL (1.5ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
847
+  (0.0ms) commit transaction
848
+  (0.0ms) begin transaction
849
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
850
+  (0.0ms) commit transaction
851
+  (0.0ms) begin transaction
852
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
853
+  (0.0ms) commit transaction
854
+  (0.0ms) begin transaction
855
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
856
+  (0.0ms) commit transaction
857
+  (0.0ms) begin transaction
858
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
859
+  (0.0ms) commit transaction
860
+  (0.0ms) begin transaction
861
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 4
862
+  (0.0ms) commit transaction
863
+  (0.0ms) begin transaction
864
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
865
+  (0.0ms) commit transaction
866
+  (0.0ms) begin transaction
867
+  (0.0ms) rollback transaction
868
+  (0.0ms) begin transaction
869
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
870
+  (0.0ms) commit transaction
871
+  (0.0ms) begin transaction
872
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
873
+  (0.0ms) commit transaction
874
+  (0.0ms) begin transaction
875
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
876
+  (0.0ms) commit transaction
877
+  (0.0ms) begin transaction
878
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
879
+  (0.0ms) commit transaction
880
+  (0.0ms) begin transaction
881
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
882
+  (0.0ms) commit transaction
883
+  (0.0ms) begin transaction
884
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
885
+  (0.0ms) commit transaction
886
+  (0.0ms) begin transaction
887
+ SQL (1.5ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
888
+  (0.0ms) commit transaction
889
+  (0.1ms) begin transaction
890
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
891
+  (0.0ms) commit transaction
892
+  (0.0ms) begin transaction
893
+  (0.0ms) commit transaction
894
+  (0.1ms) begin transaction
895
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
896
+  (0.0ms) commit transaction
897
+  (0.0ms) begin transaction
898
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
899
+  (0.0ms) commit transaction
900
+  (0.0ms) begin transaction
901
+  (0.0ms) rollback transaction
902
+  (0.0ms) begin transaction
903
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
904
+  (0.0ms) commit transaction
905
+  (0.0ms) begin transaction
906
+  (0.1ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 5
907
+  (0.0ms) commit transaction
908
+  (0.0ms) begin transaction
909
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
910
+  (0.0ms) commit transaction
911
+  (0.0ms) begin transaction
912
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
913
+  (0.0ms) commit transaction
914
+  (0.0ms) begin transaction
915
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
916
+  (0.0ms) commit transaction
917
+  (0.0ms) begin transaction
918
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
919
+  (0.0ms) commit transaction
920
+  (0.0ms) begin transaction
921
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
922
+  (0.0ms) commit transaction
923
+  (0.0ms) begin transaction
924
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
925
+  (0.0ms) commit transaction
926
+  (0.0ms) begin transaction
927
+ SQL (1.6ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
928
+  (0.0ms) commit transaction
929
+  (0.0ms) begin transaction
930
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
931
+  (0.0ms) commit transaction
932
+  (0.0ms) begin transaction
933
+  (0.0ms) commit transaction
934
+  (0.1ms) begin transaction
935
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
936
+  (0.0ms) commit transaction
937
+  (0.0ms) begin transaction
938
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
939
+  (0.0ms) commit transaction
940
+  (0.0ms) begin transaction
941
+  (0.0ms) rollback transaction
942
+  (0.0ms) begin transaction
943
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
944
+  (0.0ms) commit transaction
945
+  (0.0ms) begin transaction
946
+  (0.1ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 5
947
+  (0.0ms) commit transaction
948
+  (0.0ms) begin transaction
949
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
950
+  (0.0ms) commit transaction
951
+  (0.0ms) begin transaction
952
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
953
+  (0.0ms) commit transaction
954
+  (0.0ms) begin transaction
955
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
956
+  (0.0ms) commit transaction
957
+  (0.0ms) begin transaction
958
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
959
+  (0.0ms) commit transaction
960
+  (0.0ms) begin transaction
961
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
962
+  (0.0ms) commit transaction
963
+  (0.0ms) begin transaction
964
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
965
+  (0.0ms) commit transaction
966
+  (0.0ms) begin transaction
967
+ SQL (1.6ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
968
+  (0.0ms) commit transaction
969
+  (0.0ms) begin transaction
970
+  (0.0ms) rollback transaction
971
+  (0.0ms) begin transaction
972
+  (0.0ms) rollback transaction
973
+  (0.1ms) begin transaction
974
+  (0.0ms) rollback transaction
975
+  (0.0ms) begin transaction
976
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
977
+  (0.0ms) commit transaction
978
+  (0.0ms) begin transaction
979
+  (0.0ms) rollback transaction
980
+  (0.0ms) begin transaction
981
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
982
+  (0.0ms) commit transaction
983
+  (0.0ms) begin transaction
984
+  (0.0ms) rollback transaction
985
+  (0.0ms) begin transaction
986
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
987
+  (0.0ms) commit transaction
988
+  (0.0ms) begin transaction
989
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 4]]
990
+  (0.0ms) commit transaction
991
+  (0.0ms) begin transaction
992
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
993
+  (0.0ms) commit transaction
994
+  (0.0ms) begin transaction
995
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 5
996
+  (0.0ms) commit transaction
997
+  (0.0ms) begin transaction
998
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
999
+  (0.0ms) commit transaction
1000
+  (0.0ms) begin transaction
1001
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1002
+  (0.0ms) commit transaction
1003
+  (0.0ms) begin transaction
1004
+ SQL (1.6ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
1005
+  (0.0ms) commit transaction
1006
+  (0.0ms) begin transaction
1007
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
1008
+  (0.0ms) commit transaction
1009
+  (0.0ms) begin transaction
1010
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
1011
+  (0.0ms) commit transaction
1012
+  (0.0ms) begin transaction
1013
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
1014
+  (0.0ms) commit transaction
1015
+  (0.0ms) begin transaction
1016
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1017
+  (0.0ms) commit transaction
1018
+  (0.0ms) begin transaction
1019
+  (0.0ms) rollback transaction
1020
+  (0.0ms) begin transaction
1021
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1022
+  (0.0ms) commit transaction
1023
+  (0.0ms) begin transaction
1024
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 5
1025
+  (0.0ms) commit transaction
1026
+  (0.0ms) begin transaction
1027
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1028
+  (0.0ms) commit transaction
1029
+  (0.0ms) begin transaction
1030
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
1031
+  (0.0ms) commit transaction
1032
+  (0.0ms) begin transaction
1033
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1034
+  (0.0ms) commit transaction
1035
+  (0.0ms) begin transaction
1036
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1037
+  (0.0ms) commit transaction
1038
+  (0.0ms) begin transaction
1039
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
1040
+  (0.0ms) commit transaction
1041
+  (0.0ms) begin transaction
1042
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1043
+  (0.0ms) commit transaction
1044
+  (0.0ms) begin transaction
1045
+ SQL (1.6ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
1046
+  (0.0ms) commit transaction
1047
+  (0.1ms) begin transaction
1048
+  (0.0ms) commit transaction
1049
+  (0.0ms) begin transaction
1050
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1051
+  (0.0ms) commit transaction
1052
+  (0.0ms) begin transaction
1053
+  (0.0ms) commit transaction
1054
+  (0.1ms) begin transaction
1055
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1056
+  (0.0ms) commit transaction
1057
+  (0.0ms) begin transaction
1058
+  (0.0ms) commit transaction
1059
+  (0.0ms) begin transaction
1060
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1061
+  (0.0ms) commit transaction
1062
+  (0.0ms) begin transaction
1063
+  (0.0ms) commit transaction
1064
+  (0.0ms) begin transaction
1065
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1066
+  (0.0ms) commit transaction
1067
+  (0.0ms) begin transaction
1068
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 5]]
1069
+  (0.0ms) commit transaction
1070
+  (0.0ms) begin transaction
1071
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1072
+  (0.0ms) commit transaction
1073
+  (0.0ms) begin transaction
1074
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1075
+  (0.0ms) commit transaction
1076
+  (0.0ms) begin transaction
1077
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 7
1078
+  (0.0ms) commit transaction
1079
+  (0.0ms) begin transaction
1080
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1081
+  (0.0ms) commit transaction
1082
+  (0.0ms) begin transaction
1083
+ SQL (1.5ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
1084
+  (0.0ms) commit transaction
1085
+  (0.0ms) begin transaction
1086
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
1087
+  (0.0ms) commit transaction
1088
+  (0.0ms) begin transaction
1089
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
1090
+  (0.0ms) commit transaction
1091
+  (0.0ms) begin transaction
1092
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
1093
+  (0.0ms) commit transaction
1094
+  (0.0ms) begin transaction
1095
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1096
+  (0.0ms) commit transaction
1097
+  (0.0ms) begin transaction
1098
+  (0.0ms) commit transaction
1099
+  (0.0ms) begin transaction
1100
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1101
+  (0.0ms) commit transaction
1102
+  (0.0ms) begin transaction
1103
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 5
1104
+  (0.0ms) commit transaction
1105
+  (0.0ms) begin transaction
1106
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1107
+  (0.0ms) commit transaction
1108
+  (0.0ms) begin transaction
1109
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
1110
+  (0.0ms) commit transaction
1111
+  (0.0ms) begin transaction
1112
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1113
+  (0.0ms) commit transaction
1114
+  (0.0ms) begin transaction
1115
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1116
+  (0.0ms) commit transaction
1117
+  (0.0ms) begin transaction
1118
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
1119
+  (0.0ms) commit transaction
1120
+  (0.0ms) begin transaction
1121
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1122
+  (0.0ms) commit transaction
1123
+  (0.0ms) begin transaction
1124
+ SQL (1.6ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
1125
+  (0.1ms) commit transaction
1126
+  (0.0ms) begin transaction
1127
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
1128
+  (0.0ms) commit transaction
1129
+  (0.0ms) begin transaction
1130
+  (0.1ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 2
1131
+  (0.0ms) commit transaction
1132
+  (0.0ms) begin transaction
1133
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "foo"]]
1134
+  (0.0ms) commit transaction
1135
+  (0.0ms) begin transaction
1136
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1137
+  (0.0ms) commit transaction
1138
+  (0.0ms) begin transaction
1139
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 4
1140
+  (0.0ms) commit transaction
1141
+  (0.0ms) begin transaction
1142
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1143
+  (0.0ms) commit transaction
1144
+  (0.0ms) begin transaction
1145
+  (0.0ms) commit transaction
1146
+  (0.0ms) begin transaction
1147
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1148
+  (0.0ms) commit transaction
1149
+  (0.0ms) begin transaction
1150
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 6]]
1151
+  (0.0ms) commit transaction
1152
+  (0.0ms) begin transaction
1153
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1154
+  (0.0ms) commit transaction
1155
+  (0.0ms) begin transaction
1156
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", "bar"]]
1157
+  (0.0ms) commit transaction
1158
+  (0.0ms) begin transaction
1159
+  (0.0ms) UPDATE "products" SET "name" = 'bar' WHERE "products"."id" = 8
1160
+  (0.0ms) commit transaction
1161
+  (0.0ms) begin transaction
1162
+ SQL (1.6ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1163
+  (0.0ms) rollback transaction
1164
+  (0.0ms) begin transaction
1165
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1166
+  (0.0ms) rollback transaction
1167
+  (0.0ms) begin transaction
1168
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1169
+  (0.0ms) commit transaction
1170
+  (0.0ms) begin transaction
1171
+  (0.0ms) rollback transaction
1172
+  (0.0ms) begin transaction
1173
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1174
+  (0.0ms) commit transaction
1175
+  (0.0ms) begin transaction
1176
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1177
+  (0.0ms) commit transaction
1178
+  (0.0ms) begin transaction
1179
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1180
+  (0.0ms) rollback transaction
1181
+  (0.0ms) begin transaction
1182
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1183
+  (0.0ms) rollback transaction
1184
+  (0.0ms) begin transaction
1185
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1186
+  (0.0ms) rollback transaction
1187
+  (0.0ms) begin transaction
1188
+ SQL (1.7ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1189
+  (0.0ms) rollback transaction
1190
+  (0.0ms) begin transaction
1191
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1192
+  (0.0ms) rollback transaction
1193
+  (0.0ms) begin transaction
1194
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1195
+  (0.0ms) commit transaction
1196
+  (0.0ms) begin transaction
1197
+  (0.0ms) rollback transaction
1198
+  (0.0ms) begin transaction
1199
+ SQL (0.1ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1200
+  (0.0ms) commit transaction
1201
+  (0.0ms) begin transaction
1202
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1203
+  (0.0ms) commit transaction
1204
+  (0.0ms) begin transaction
1205
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1206
+  (0.0ms) rollback transaction
1207
+  (0.0ms) begin transaction
1208
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1209
+  (0.0ms) rollback transaction
1210
+  (0.0ms) begin transaction
1211
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1212
+  (0.0ms) rollback transaction
1213
+  (0.0ms) begin transaction
1214
+ SQL (1.6ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1215
+  (0.0ms) commit transaction
1216
+  (0.0ms) begin transaction
1217
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
1218
+  (0.0ms) commit transaction
1219
+  (0.0ms) begin transaction
1220
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1221
+  (0.0ms) commit transaction
1222
+  (0.0ms) begin transaction
1223
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 2]]
1224
+  (0.0ms) commit transaction
1225
+  (0.0ms) begin transaction
1226
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1227
+  (0.0ms) commit transaction
1228
+  (0.0ms) begin transaction
1229
+  (0.0ms) commit transaction
1230
+  (0.0ms) begin transaction
1231
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1232
+  (0.0ms) commit transaction
1233
+  (0.0ms) begin transaction
1234
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1235
+  (0.0ms) commit transaction
1236
+  (0.0ms) begin transaction
1237
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1238
+  (0.0ms) commit transaction
1239
+  (0.0ms) begin transaction
1240
+  (0.1ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 6
1241
+  (0.0ms) commit transaction
1242
+  (0.0ms) begin transaction
1243
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1244
+  (0.0ms) commit transaction
1245
+  (0.0ms) begin transaction
1246
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 7
1247
+  (0.0ms) commit transaction
1248
+  (0.0ms) begin transaction
1249
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1250
+  (0.0ms) commit transaction
1251
+  (0.0ms) begin transaction
1252
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 8
1253
+  (0.0ms) commit transaction
1254
+  (0.0ms) begin transaction
1255
+ SQL (1.6ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1256
+  (0.0ms) commit transaction
1257
+  (0.0ms) begin transaction
1258
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
1259
+  (0.0ms) commit transaction
1260
+  (0.0ms) begin transaction
1261
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1262
+  (0.0ms) commit transaction
1263
+  (0.0ms) begin transaction
1264
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 2]]
1265
+  (0.0ms) commit transaction
1266
+  (0.0ms) begin transaction
1267
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1268
+  (0.0ms) commit transaction
1269
+  (0.0ms) begin transaction
1270
+  (0.0ms) commit transaction
1271
+  (0.0ms) begin transaction
1272
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1273
+  (0.0ms) commit transaction
1274
+  (0.0ms) begin transaction
1275
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1276
+  (0.0ms) commit transaction
1277
+  (0.0ms) begin transaction
1278
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1279
+  (0.0ms) commit transaction
1280
+  (0.0ms) begin transaction
1281
+  (0.1ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 6
1282
+  (0.0ms) commit transaction
1283
+  (0.0ms) begin transaction
1284
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1285
+  (0.0ms) commit transaction
1286
+  (0.0ms) begin transaction
1287
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 7
1288
+  (0.0ms) commit transaction
1289
+  (0.0ms) begin transaction
1290
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1291
+  (0.0ms) commit transaction
1292
+  (0.0ms) begin transaction
1293
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 8
1294
+  (0.0ms) commit transaction
1295
+  (0.0ms) begin transaction
1296
+ SQL (1.6ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1297
+  (0.0ms) commit transaction
1298
+  (0.0ms) begin transaction
1299
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
1300
+  (0.0ms) commit transaction
1301
+  (0.0ms) begin transaction
1302
+ SQL (30.9ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1303
+  (0.0ms) commit transaction
1304
+  (0.0ms) begin transaction
1305
+ SQL (0.0ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 2]]
1306
+  (0.0ms) commit transaction
1307
+  (0.0ms) begin transaction
1308
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1309
+  (0.0ms) commit transaction
1310
+  (0.0ms) begin transaction
1311
+  (0.0ms) commit transaction
1312
+  (0.0ms) begin transaction
1313
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1314
+  (0.0ms) commit transaction
1315
+  (0.0ms) begin transaction
1316
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1317
+  (0.0ms) commit transaction
1318
+  (0.0ms) begin transaction
1319
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1320
+  (0.0ms) commit transaction
1321
+  (0.0ms) begin transaction
1322
+  (0.1ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 6
1323
+  (0.0ms) commit transaction
1324
+  (0.0ms) begin transaction
1325
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1326
+  (0.0ms) commit transaction
1327
+  (0.0ms) begin transaction
1328
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 7
1329
+  (0.0ms) commit transaction
1330
+  (0.0ms) begin transaction
1331
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1332
+  (0.0ms) commit transaction
1333
+  (0.0ms) begin transaction
1334
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 8
1335
+  (0.0ms) commit transaction
1336
+  (0.0ms) begin transaction
1337
+ SQL (1.6ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1338
+  (0.0ms) commit transaction
1339
+  (0.0ms) begin transaction
1340
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
1341
+  (0.0ms) commit transaction
1342
+  (0.0ms) begin transaction
1343
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1344
+  (0.0ms) commit transaction
1345
+  (0.1ms) begin transaction
1346
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 2]]
1347
+  (0.0ms) commit transaction
1348
+  (0.0ms) begin transaction
1349
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1350
+  (0.0ms) commit transaction
1351
+  (0.0ms) begin transaction
1352
+  (0.0ms) commit transaction
1353
+  (0.0ms) begin transaction
1354
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1355
+  (0.0ms) commit transaction
1356
+  (0.0ms) begin transaction
1357
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1358
+  (0.0ms) commit transaction
1359
+  (0.0ms) begin transaction
1360
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1361
+  (0.0ms) commit transaction
1362
+  (0.0ms) begin transaction
1363
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1364
+  (0.0ms) commit transaction
1365
+  (0.0ms) begin transaction
1366
+  (0.1ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 7
1367
+  (0.0ms) commit transaction
1368
+  (0.0ms) begin transaction
1369
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1370
+  (0.0ms) commit transaction
1371
+  (0.0ms) begin transaction
1372
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 8
1373
+  (0.0ms) commit transaction
1374
+  (0.0ms) begin transaction
1375
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1376
+  (0.0ms) commit transaction
1377
+  (0.0ms) begin transaction
1378
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 9
1379
+  (0.0ms) commit transaction
1380
+  (0.0ms) begin transaction
1381
+ SQL (1.7ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1382
+  (0.0ms) commit transaction
1383
+  (0.0ms) begin transaction
1384
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 1]]
1385
+  (0.0ms) commit transaction
1386
+  (0.0ms) begin transaction
1387
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1388
+  (0.0ms) commit transaction
1389
+  (0.1ms) begin transaction
1390
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = ? [["id", 2]]
1391
+  (0.0ms) commit transaction
1392
+  (0.0ms) begin transaction
1393
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1394
+  (0.0ms) commit transaction
1395
+  (0.0ms) begin transaction
1396
+  (0.0ms) commit transaction
1397
+  (0.0ms) begin transaction
1398
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1399
+  (0.0ms) commit transaction
1400
+  (0.0ms) begin transaction
1401
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1402
+  (0.0ms) commit transaction
1403
+  (0.0ms) begin transaction
1404
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1405
+  (0.0ms) commit transaction
1406
+  (0.0ms) begin transaction
1407
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1408
+  (0.0ms) commit transaction
1409
+  (0.0ms) begin transaction
1410
+  (0.1ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 7
1411
+  (0.0ms) commit transaction
1412
+  (0.0ms) begin transaction
1413
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1414
+  (0.0ms) commit transaction
1415
+  (0.0ms) begin transaction
1416
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 8
1417
+  (0.0ms) commit transaction
1418
+  (0.0ms) begin transaction
1419
+ SQL (0.0ms) INSERT INTO "products" ("name") VALUES (?) [["name", nil]]
1420
+  (0.0ms) commit transaction
1421
+  (0.0ms) begin transaction
1422
+  (0.0ms) UPDATE "products" SET "name" = 'foo' WHERE "products"."id" = 9
1423
+  (0.0ms) commit transaction
@@ -1,74 +1,100 @@
1
1
  require 'test_helper'
2
2
 
3
- class DestructionNotifier
3
+ class Notifier
4
+ def self.product_was_saved(product)
5
+ end
6
+
7
+ def self.product_was_updated(product)
8
+ end
9
+
10
+ def self.product_was_created(product)
11
+ end
12
+
4
13
  def self.product_was_destroyed(product)
5
14
  end
6
15
  end
7
16
 
8
17
  class Product < ActiveRecord::Base
9
- attr_accessible :name
18
+ after_save do |product|
19
+ Notifier.product_was_saved(product)
20
+ end
10
21
 
11
- before_save do |product|
12
- product.name = 'bar'
22
+ after_update do |product|
23
+ Notifier.product_was_updated(product)
13
24
  end
14
25
 
15
- after_save do |product|
16
- product.name = product.name.titleize
26
+ after_create do |product|
27
+ Notifier.product_was_created(product)
17
28
  end
18
29
 
19
30
  after_destroy do |product|
20
- DestructionNotifier.product_was_destroyed(product)
31
+ Notifier.product_was_destroyed(product)
21
32
  end
22
33
  end
23
34
 
24
35
  describe SkipActiverecordCallbacks do
25
- let(:product) { Product.new(:name => 'foo') }
26
-
27
- describe "normal save" do
28
- it "sets the product name to 'Bar'" do
29
- product.save
30
- product.name.must_equal 'Bar'
31
- product.new_record?.must_equal false
32
- end
33
- end
36
+ let(:product) { Product.new }
34
37
 
35
38
  describe "#update_without_callbacks" do
36
- it "saves a record without running its save callbacks" do
37
- product.update_without_callbacks
38
- product.name.must_equal 'foo'
39
- product.new_record?.must_equal false
39
+ describe "on create" do
40
+ it "saves the record" do
41
+ product.update_without_callbacks
42
+ product.new_record?.must_equal false
43
+ end
44
+
45
+ it "skips the :save callbacks" do
46
+ Notifier.expects(:product_was_saved).never
47
+ product.update_without_callbacks
48
+ end
49
+
50
+ it "skips the :create callbacks" do
51
+ Notifier.expects(:product_was_created).never
52
+ product.update_without_callbacks
53
+ end
40
54
  end
41
55
 
42
- it "updates a record without running its save callbacks" do
43
- product.save
44
- product.name = 'foo'
45
- product.update_without_callbacks
46
- product.name.must_equal 'foo'
47
- product.new_record?.must_equal false
56
+ describe "update" do
57
+ before do
58
+ product.save
59
+ product.name = 'foo'
60
+ end
61
+
62
+ it "saves the record" do
63
+ product.update_without_callbacks
64
+ product.changes.empty?.must_equal true
65
+ end
66
+
67
+ it "skips the :save callbacks" do
68
+ Notifier.expects(:product_was_saved).never
69
+ product.update_without_callbacks
70
+ end
71
+
72
+ it "skips the :update callbacks" do
73
+ Notifier.expects(:product_was_updated).never
74
+ product.update_without_callbacks
75
+ end
48
76
  end
49
77
 
50
78
  it "restores the callbacks afterwards" do
51
79
  product.update_without_callbacks
80
+ Notifier.expects(:product_was_saved).with(product)
52
81
  product.save
53
- product.name.must_equal 'Bar'
54
82
  end
55
83
  end
56
84
 
57
- describe "normal destroy" do
58
- it "destroys the model and runs the callbacks" do
85
+ describe "#destroy_without_callbacks" do
86
+ before do
59
87
  product.save
60
- DestructionNotifier.expects(:product_was_destroyed).with(product)
61
- product.destroy
62
- assert product.destroyed?
63
88
  end
64
- end
65
89
 
66
- describe "#destroy_without_callbacks" do
67
- it "destroys a record without running the callbacks" do
68
- product.save
69
- DestructionNotifier.expects(:product_was_destroyed).never
90
+ it "destroys the model" do
91
+ product.destroy_without_callbacks
92
+ product.destroyed?.must_equal true
93
+ end
94
+
95
+ it "skips the :destroy callbacks" do
96
+ Notifier.expects(:product_was_destroyed).never
70
97
  product.destroy_without_callbacks
71
- assert product.destroyed?
72
98
  end
73
99
  end
74
100
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skip_activerecord_callbacks
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Donald Ball
@@ -15,12 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-16 00:00:00 Z
18
+ date: 2012-04-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- type: :runtime
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
22
  none: false
25
23
  requirements:
26
24
  - - ~>
@@ -31,11 +29,11 @@ dependencies:
31
29
  - 2
32
30
  version: "3.2"
33
31
  name: rails
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- type: :development
32
+ type: :runtime
37
33
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
37
  none: false
40
38
  requirements:
41
39
  - - ">="
@@ -45,11 +43,11 @@ dependencies:
45
43
  - 0
46
44
  version: "0"
47
45
  name: sqlite3
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
46
  type: :development
51
47
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirement: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
51
  none: false
54
52
  requirements:
55
53
  - - ">="
@@ -59,11 +57,11 @@ dependencies:
59
57
  - 0
60
58
  version: "0"
61
59
  name: minitest
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
60
  type: :development
65
61
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
62
+ requirement: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ version_requirements: &id004 !ruby/object:Gem::Requirement
67
65
  none: false
68
66
  requirements:
69
67
  - - ">="
@@ -73,7 +71,9 @@ dependencies:
73
71
  - 0
74
72
  version: "0"
75
73
  name: mocha
76
- version_requirements: *id004
74
+ type: :development
75
+ prerelease: false
76
+ requirement: *id004
77
77
  description: Provides support for the deprecated update_without_callbacks method from rails 2
78
78
  email:
79
79
  - donald.ball@gmail.com
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  requirements: []
154
154
 
155
155
  rubyforge_project:
156
- rubygems_version: 1.8.17
156
+ rubygems_version: 1.8.21
157
157
  signing_key:
158
158
  specification_version: 3
159
159
  summary: Lets you save activerecord models without callbacks