arel-helpers 2.9.1 → 2.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -14
- data/README.md +28 -2
- data/arel-helpers.gemspec +15 -12
- data/lib/arel-helpers/join_association.rb +87 -29
- data/lib/arel-helpers/query_builder.rb +15 -0
- data/lib/arel-helpers/version.rb +1 -1
- data/spec/aliases_spec.rb +5 -7
- data/spec/arel_table_spec.rb +11 -13
- data/spec/env/models.rb +2 -6
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/internal/db/schema.rb +34 -0
- data/spec/internal/log/test.log +393 -0
- data/spec/join_association_spec.rb +101 -57
- data/spec/query_builder_spec.rb +31 -18
- data/spec/spec_helper.rb +10 -20
- metadata +94 -9
- data/spec/env/migrations.rb +0 -75
- data/spec/env.rb +0 -44
Binary file
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
ActiveRecord::Schema.define do
|
4
|
+
create_table :posts do |t|
|
5
|
+
t.column :title, :string
|
6
|
+
end
|
7
|
+
|
8
|
+
create_table :comments do |t|
|
9
|
+
t.references :post
|
10
|
+
end
|
11
|
+
|
12
|
+
create_table :authors do |t|
|
13
|
+
t.references :comment
|
14
|
+
t.references :collab_posts
|
15
|
+
end
|
16
|
+
|
17
|
+
create_table :favorites do |t|
|
18
|
+
t.references :post
|
19
|
+
end
|
20
|
+
|
21
|
+
create_table :collab_posts do |t|
|
22
|
+
t.references :authors
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table :cards
|
26
|
+
|
27
|
+
create_table :card_locations do |t|
|
28
|
+
t.references :location
|
29
|
+
t.references :card, polymorphic: true
|
30
|
+
end
|
31
|
+
|
32
|
+
create_table :locations
|
33
|
+
create_table :community_tickets
|
34
|
+
end
|
@@ -0,0 +1,393 @@
|
|
1
|
+
[1m[35m (1.9ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
2
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
3
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE TABLE "posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar)[0m
|
4
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE TABLE "comments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "post_id" integer)[0m
|
5
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_comments_on_post_id" ON "comments" ("post_id")[0m
|
6
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "authors" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "comment_id" integer, "collab_posts_id" integer)[0m
|
7
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_authors_on_comment_id" ON "authors" ("comment_id")[0m
|
8
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_authors_on_collab_posts_id" ON "authors" ("collab_posts_id")[0m
|
9
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE TABLE "favorites" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "post_id" integer)[0m
|
10
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE INDEX "index_favorites_on_post_id" ON "favorites" ("post_id")[0m
|
11
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "collab_posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "authors_id" integer)[0m
|
12
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "index_collab_posts_on_authors_id" ON "collab_posts" ("authors_id")[0m
|
13
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "cards" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)[0m
|
14
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "card_locations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "location_id" integer, "card_type" varchar, "card_id" integer)[0m
|
15
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE INDEX "index_card_locations_on_location_id" ON "card_locations" ("location_id")[0m
|
16
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "index_card_locations_on_card" ON "card_locations" ("card_type", "card_id")[0m
|
17
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "locations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)[0m
|
18
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "community_tickets" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)[0m
|
19
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL)[0m
|
20
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
21
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
22
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.4ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "test"], ["created_at", "2021-08-26 17:33:23.741476"], ["updated_at", "2021-08-26 17:33:23.741476"]]
|
23
|
+
[1m[36mTRANSACTION (0.9ms)[0m [1m[36mcommit transaction[0m
|
24
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
25
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
26
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
27
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA foreign_keys[0m
|
28
|
+
[1m[35m (0.1ms)[0m [1m[35mPRAGMA defer_foreign_keys[0m
|
29
|
+
[1m[35m (0.1ms)[0m [1m[35mPRAGMA defer_foreign_keys = ON[0m
|
30
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA foreign_keys = OFF[0m
|
31
|
+
[1m[35m (1.1ms)[0m [1m[31mDELETE FROM "posts";[0m
|
32
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
33
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'posts';[0m
|
34
|
+
[1m[35m (1.2ms)[0m [1m[31mDELETE FROM "comments";[0m
|
35
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
36
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'comments';[0m
|
37
|
+
[1m[35m (1.1ms)[0m [1m[31mDELETE FROM "authors";[0m
|
38
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
39
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'authors';[0m
|
40
|
+
[1m[35m (1.0ms)[0m [1m[31mDELETE FROM "favorites";[0m
|
41
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
42
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'favorites';[0m
|
43
|
+
[1m[35m (1.0ms)[0m [1m[31mDELETE FROM "collab_posts";[0m
|
44
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
45
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'collab_posts';[0m
|
46
|
+
[1m[35m (0.9ms)[0m [1m[31mDELETE FROM "cards";[0m
|
47
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
48
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'cards';[0m
|
49
|
+
[1m[35m (1.0ms)[0m [1m[31mDELETE FROM "card_locations";[0m
|
50
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
51
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'card_locations';[0m
|
52
|
+
[1m[35m (0.9ms)[0m [1m[31mDELETE FROM "locations";[0m
|
53
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
54
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'locations';[0m
|
55
|
+
[1m[35m (0.8ms)[0m [1m[31mDELETE FROM "community_tickets";[0m
|
56
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
57
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'community_tickets';[0m
|
58
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA defer_foreign_keys = 0[0m
|
59
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA foreign_keys = 1[0m
|
60
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
61
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
62
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "I'm a little teapot"]]
|
63
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
64
|
+
[1m[36mComment Load (0.1ms)[0m [1m[34mSELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ?[0m [["post_id", 1]]
|
65
|
+
[1m[36mTRANSACTION (0.2ms)[0m [1m[31mrollback transaction[0m
|
66
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
67
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
68
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "I'm a little teapot"]]
|
69
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
70
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
71
|
+
[1m[36mComment Create (0.2ms)[0m [1m[32mINSERT INTO "comments" ("post_id") VALUES (?)[0m [["post_id", 1]]
|
72
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
73
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT ?[0m [["id", 1], ["LIMIT", 1]]
|
74
|
+
[1m[36mComment Load (0.0ms)[0m [1m[34mSELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ?[0m [["post_id", 1]]
|
75
|
+
[1m[36mTRANSACTION (0.4ms)[0m [1m[31mrollback transaction[0m
|
76
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
77
|
+
[1m[36mPost Load (0.2ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
78
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
79
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "foo"]]
|
80
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
81
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
82
|
+
[1m[36mTRANSACTION (0.4ms)[0m [1m[31mrollback transaction[0m
|
83
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
84
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
85
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
86
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
87
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
88
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[31mrollback transaction[0m
|
89
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
90
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
91
|
+
[1m[36mLocation Create (0.4ms)[0m [1m[32mINSERT INTO "locations" DEFAULT VALUES[0m
|
92
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
93
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
94
|
+
[1m[36mCommunityTicket Create (0.1ms)[0m [1m[32mINSERT INTO "community_tickets" DEFAULT VALUES[0m
|
95
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
96
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
97
|
+
[1m[36mCardLocation Create (0.3ms)[0m [1m[32mINSERT INTO "card_locations" ("location_id", "card_type", "card_id") VALUES (?, ?, ?)[0m [["location_id", 1], ["card_type", "CommunityTicket"], ["card_id", 1]]
|
98
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
99
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT COUNT(*) FROM "locations" INNER JOIN "card_locations" ON "card_locations"."card_type" = ? AND "card_locations"."location_id" = "locations"."id" INNER JOIN "community_tickets" ON "community_tickets"."id" = "card_locations"."card_id"[0m [["card_type", "CommunityTicket"]]
|
100
|
+
[1m[36mLocation Load (0.1ms)[0m [1m[34mSELECT "locations".* FROM "locations" INNER JOIN "card_locations" ON "card_locations"."card_type" = ? AND "card_locations"."location_id" = "locations"."id" INNER JOIN "community_tickets" ON "community_tickets"."id" = "card_locations"."card_id"[0m [["card_type", "CommunityTicket"]]
|
101
|
+
[1m[36mTRANSACTION (0.5ms)[0m [1m[31mrollback transaction[0m
|
102
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
103
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
104
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "Foobar"]]
|
105
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
106
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
107
|
+
[1m[36mTRANSACTION (0.3ms)[0m [1m[31mrollback transaction[0m
|
108
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
109
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
110
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "Foobar"]]
|
111
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
112
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
113
|
+
[1m[36mTRANSACTION (0.4ms)[0m [1m[31mrollback transaction[0m
|
114
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
115
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
116
|
+
[1m[36mPost Create (0.5ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "Foobar"]]
|
117
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
118
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
119
|
+
[1m[36mTRANSACTION (0.3ms)[0m [1m[31mrollback transaction[0m
|
120
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
121
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT COUNT(*) FROM "posts"[0m
|
122
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[31mrollback transaction[0m
|
123
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
124
|
+
[1m[36mPost Load (0.2ms)[0m [1m[34mSELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT ?[0m [["LIMIT", 1]]
|
125
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[31mrollback transaction[0m
|
126
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
127
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT ?[0m [["LIMIT", 1]]
|
128
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
129
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
130
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
131
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
132
|
+
[1m[35m (1.2ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
133
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
134
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE TABLE "posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar)[0m
|
135
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "comments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "post_id" integer)[0m
|
136
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE INDEX "index_comments_on_post_id" ON "comments" ("post_id")[0m
|
137
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE TABLE "authors" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "comment_id" integer, "collab_posts_id" integer)[0m
|
138
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE INDEX "index_authors_on_comment_id" ON "authors" ("comment_id")[0m
|
139
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "index_authors_on_collab_posts_id" ON "authors" ("collab_posts_id")[0m
|
140
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "favorites" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "post_id" integer)[0m
|
141
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "index_favorites_on_post_id" ON "favorites" ("post_id")[0m
|
142
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE TABLE "collab_posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "authors_id" integer)[0m
|
143
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE INDEX "index_collab_posts_on_authors_id" ON "collab_posts" ("authors_id")[0m
|
144
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE TABLE "cards" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)[0m
|
145
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "card_locations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "location_id" integer, "card_type" varchar, "card_id" integer)[0m
|
146
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_card_locations_on_location_id" ON "card_locations" ("location_id")[0m
|
147
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE INDEX "index_card_locations_on_card" ON "card_locations" ("card_type", "card_id")[0m
|
148
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "locations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)[0m
|
149
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "community_tickets" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)[0m
|
150
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL)[0m
|
151
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
152
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
153
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.4ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "test"], ["created_at", "2021-08-26 17:55:10.184260"], ["updated_at", "2021-08-26 17:55:10.184260"]]
|
154
|
+
[1m[36mTRANSACTION (1.0ms)[0m [1m[36mcommit transaction[0m
|
155
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
156
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
157
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
158
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA foreign_keys[0m
|
159
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA defer_foreign_keys[0m
|
160
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA defer_foreign_keys = ON[0m
|
161
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA foreign_keys = OFF[0m
|
162
|
+
[1m[35m (1.1ms)[0m [1m[31mDELETE FROM "posts";[0m
|
163
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
164
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'posts';[0m
|
165
|
+
[1m[35m (1.2ms)[0m [1m[31mDELETE FROM "comments";[0m
|
166
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
167
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'comments';[0m
|
168
|
+
[1m[35m (1.1ms)[0m [1m[31mDELETE FROM "authors";[0m
|
169
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
170
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'authors';[0m
|
171
|
+
[1m[35m (1.0ms)[0m [1m[31mDELETE FROM "favorites";[0m
|
172
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
173
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'favorites';[0m
|
174
|
+
[1m[35m (1.1ms)[0m [1m[31mDELETE FROM "collab_posts";[0m
|
175
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
176
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'collab_posts';[0m
|
177
|
+
[1m[35m (1.0ms)[0m [1m[31mDELETE FROM "cards";[0m
|
178
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
179
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'cards';[0m
|
180
|
+
[1m[35m (1.0ms)[0m [1m[31mDELETE FROM "card_locations";[0m
|
181
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
182
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'card_locations';[0m
|
183
|
+
[1m[35m (0.8ms)[0m [1m[31mDELETE FROM "locations";[0m
|
184
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
185
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'locations';[0m
|
186
|
+
[1m[35m (1.0ms)[0m [1m[31mDELETE FROM "community_tickets";[0m
|
187
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
188
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'community_tickets';[0m
|
189
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA defer_foreign_keys = 0[0m
|
190
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA foreign_keys = 1[0m
|
191
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
192
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
193
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "I'm a little teapot"]]
|
194
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
195
|
+
[1m[36mComment Load (0.1ms)[0m [1m[34mSELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ?[0m [["post_id", 1]]
|
196
|
+
[1m[36mTRANSACTION (0.3ms)[0m [1m[31mrollback transaction[0m
|
197
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
198
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
199
|
+
[1m[36mPost Create (0.5ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "I'm a little teapot"]]
|
200
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
201
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
202
|
+
[1m[36mComment Create (0.2ms)[0m [1m[32mINSERT INTO "comments" ("post_id") VALUES (?)[0m [["post_id", 1]]
|
203
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
204
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT ?[0m [["id", 1], ["LIMIT", 1]]
|
205
|
+
[1m[36mComment Load (0.1ms)[0m [1m[34mSELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ?[0m [["post_id", 1]]
|
206
|
+
[1m[36mTRANSACTION (0.3ms)[0m [1m[31mrollback transaction[0m
|
207
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
208
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
209
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
210
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "foo"]]
|
211
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
212
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
213
|
+
[1m[36mTRANSACTION (0.4ms)[0m [1m[31mrollback transaction[0m
|
214
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
215
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
216
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
217
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[31mrollback transaction[0m
|
218
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
219
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[31mrollback transaction[0m
|
220
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
221
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
222
|
+
[1m[36mLocation Create (0.4ms)[0m [1m[32mINSERT INTO "locations" DEFAULT VALUES[0m
|
223
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
224
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
225
|
+
[1m[36mCommunityTicket Create (0.1ms)[0m [1m[32mINSERT INTO "community_tickets" DEFAULT VALUES[0m
|
226
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
227
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
228
|
+
[1m[36mCardLocation Create (0.2ms)[0m [1m[32mINSERT INTO "card_locations" ("location_id", "card_type", "card_id") VALUES (?, ?, ?)[0m [["location_id", 1], ["card_type", "CommunityTicket"], ["card_id", 1]]
|
229
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
230
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT COUNT(*) FROM "locations" INNER JOIN "card_locations" ON "card_locations"."card_type" = ? AND "card_locations"."location_id" = "locations"."id" INNER JOIN "community_tickets" ON "community_tickets"."id" = "card_locations"."card_id"[0m [["card_type", "CommunityTicket"]]
|
231
|
+
[1m[36mLocation Load (0.1ms)[0m [1m[34mSELECT "locations".* FROM "locations" INNER JOIN "card_locations" ON "card_locations"."card_type" = ? AND "card_locations"."location_id" = "locations"."id" INNER JOIN "community_tickets" ON "community_tickets"."id" = "card_locations"."card_id"[0m [["card_type", "CommunityTicket"]]
|
232
|
+
[1m[36mTRANSACTION (0.4ms)[0m [1m[31mrollback transaction[0m
|
233
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
234
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
235
|
+
[1m[36mPost Create (0.5ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "Foobar"]]
|
236
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
237
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
238
|
+
[1m[36mTRANSACTION (0.4ms)[0m [1m[31mrollback transaction[0m
|
239
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
240
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
241
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "Foobar"]]
|
242
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
243
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
244
|
+
[1m[36mTRANSACTION (0.3ms)[0m [1m[31mrollback transaction[0m
|
245
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
246
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
247
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "Foobar"]]
|
248
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
249
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
250
|
+
[1m[36mTRANSACTION (0.3ms)[0m [1m[31mrollback transaction[0m
|
251
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
252
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT COUNT(*) FROM "posts"[0m
|
253
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[31mrollback transaction[0m
|
254
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
255
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT ?[0m [["LIMIT", 1]]
|
256
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
257
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
258
|
+
[1m[36mPost Load (0.2ms)[0m [1m[34mSELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT ?[0m [["LIMIT", 1]]
|
259
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
260
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
261
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
262
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
263
|
+
[1m[35m (1.5ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
264
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
265
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE TABLE "posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar)[0m
|
266
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "comments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "post_id" integer)[0m
|
267
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "index_comments_on_post_id" ON "comments" ("post_id")[0m
|
268
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "authors" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "comment_id" integer, "collab_posts_id" integer)[0m
|
269
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "index_authors_on_comment_id" ON "authors" ("comment_id")[0m
|
270
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "index_authors_on_collab_posts_id" ON "authors" ("collab_posts_id")[0m
|
271
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "favorites" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "post_id" integer)[0m
|
272
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE INDEX "index_favorites_on_post_id" ON "favorites" ("post_id")[0m
|
273
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "collab_posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "authors_id" integer)[0m
|
274
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE INDEX "index_collab_posts_on_authors_id" ON "collab_posts" ("authors_id")[0m
|
275
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "cards" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)[0m
|
276
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "card_locations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "location_id" integer, "card_type" varchar, "card_id" integer)[0m
|
277
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE INDEX "index_card_locations_on_location_id" ON "card_locations" ("location_id")[0m
|
278
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE INDEX "index_card_locations_on_card" ON "card_locations" ("card_type", "card_id")[0m
|
279
|
+
[1m[35m (0.9ms)[0m [1m[35mCREATE TABLE "locations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)[0m
|
280
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "community_tickets" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)[0m
|
281
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL)[0m
|
282
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
283
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
284
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.4ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?)[0m [["key", "environment"], ["value", "test"], ["created_at", "2021-08-26 17:57:07.842116"], ["updated_at", "2021-08-26 17:57:07.842116"]]
|
285
|
+
[1m[36mTRANSACTION (0.8ms)[0m [1m[36mcommit transaction[0m
|
286
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)[0m
|
287
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ?[0m [["key", "environment"], ["LIMIT", 1]]
|
288
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
289
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA foreign_keys[0m
|
290
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA defer_foreign_keys[0m
|
291
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA defer_foreign_keys = ON[0m
|
292
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA foreign_keys = OFF[0m
|
293
|
+
[1m[35m (0.9ms)[0m [1m[31mDELETE FROM "posts";[0m
|
294
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
295
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'posts';[0m
|
296
|
+
[1m[35m (0.8ms)[0m [1m[31mDELETE FROM "comments";[0m
|
297
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
298
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'comments';[0m
|
299
|
+
[1m[35m (0.8ms)[0m [1m[31mDELETE FROM "authors";[0m
|
300
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
301
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'authors';[0m
|
302
|
+
[1m[35m (0.8ms)[0m [1m[31mDELETE FROM "favorites";[0m
|
303
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
304
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'favorites';[0m
|
305
|
+
[1m[35m (0.6ms)[0m [1m[31mDELETE FROM "collab_posts";[0m
|
306
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
307
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'collab_posts';[0m
|
308
|
+
[1m[35m (0.8ms)[0m [1m[31mDELETE FROM "cards";[0m
|
309
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
310
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'cards';[0m
|
311
|
+
[1m[35m (1.0ms)[0m [1m[31mDELETE FROM "card_locations";[0m
|
312
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
313
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'card_locations';[0m
|
314
|
+
[1m[35m (0.6ms)[0m [1m[31mDELETE FROM "locations";[0m
|
315
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
316
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'locations';[0m
|
317
|
+
[1m[35m (1.0ms)[0m [1m[31mDELETE FROM "community_tickets";[0m
|
318
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';[0m
|
319
|
+
[1m[35m (0.1ms)[0m [1m[31mDELETE FROM sqlite_sequence where name = 'community_tickets';[0m
|
320
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA defer_foreign_keys = 0[0m
|
321
|
+
[1m[35m (0.0ms)[0m [1m[35mPRAGMA foreign_keys = 1[0m
|
322
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
323
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
324
|
+
[1m[36mPost Create (0.3ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "I'm a little teapot"]]
|
325
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
326
|
+
[1m[36mComment Load (0.1ms)[0m [1m[34mSELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ?[0m [["post_id", 1]]
|
327
|
+
[1m[36mTRANSACTION (0.3ms)[0m [1m[31mrollback transaction[0m
|
328
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
329
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
330
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "I'm a little teapot"]]
|
331
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
332
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
333
|
+
[1m[36mComment Create (0.2ms)[0m [1m[32mINSERT INTO "comments" ("post_id") VALUES (?)[0m [["post_id", 1]]
|
334
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
335
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT ?[0m [["id", 1], ["LIMIT", 1]]
|
336
|
+
[1m[36mComment Load (0.0ms)[0m [1m[34mSELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ?[0m [["post_id", 1]]
|
337
|
+
[1m[36mTRANSACTION (0.4ms)[0m [1m[31mrollback transaction[0m
|
338
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
339
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
340
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
341
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "foo"]]
|
342
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
343
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
344
|
+
[1m[36mTRANSACTION (0.2ms)[0m [1m[31mrollback transaction[0m
|
345
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
346
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
347
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
348
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
349
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
350
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[31mrollback transaction[0m
|
351
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
352
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
353
|
+
[1m[36mLocation Create (0.4ms)[0m [1m[32mINSERT INTO "locations" DEFAULT VALUES[0m
|
354
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
355
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
356
|
+
[1m[36mCommunityTicket Create (0.1ms)[0m [1m[32mINSERT INTO "community_tickets" DEFAULT VALUES[0m
|
357
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
358
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
359
|
+
[1m[36mCardLocation Create (0.3ms)[0m [1m[32mINSERT INTO "card_locations" ("location_id", "card_type", "card_id") VALUES (?, ?, ?)[0m [["location_id", 1], ["card_type", "CommunityTicket"], ["card_id", 1]]
|
360
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
361
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT COUNT(*) FROM "locations" INNER JOIN "card_locations" ON "card_locations"."card_type" = ? AND "card_locations"."location_id" = "locations"."id" INNER JOIN "community_tickets" ON "community_tickets"."id" = "card_locations"."card_id"[0m [["card_type", "CommunityTicket"]]
|
362
|
+
[1m[36mLocation Load (0.1ms)[0m [1m[34mSELECT "locations".* FROM "locations" INNER JOIN "card_locations" ON "card_locations"."card_type" = ? AND "card_locations"."location_id" = "locations"."id" INNER JOIN "community_tickets" ON "community_tickets"."id" = "card_locations"."card_id"[0m [["card_type", "CommunityTicket"]]
|
363
|
+
[1m[36mTRANSACTION (0.4ms)[0m [1m[31mrollback transaction[0m
|
364
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
365
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
366
|
+
[1m[36mPost Create (0.5ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "Foobar"]]
|
367
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
368
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
369
|
+
[1m[36mTRANSACTION (0.2ms)[0m [1m[31mrollback transaction[0m
|
370
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
371
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
372
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "Foobar"]]
|
373
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
374
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
375
|
+
[1m[36mTRANSACTION (0.3ms)[0m [1m[31mrollback transaction[0m
|
376
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
377
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mSAVEPOINT active_record_1[0m
|
378
|
+
[1m[36mPost Create (0.4ms)[0m [1m[32mINSERT INTO "posts" ("title") VALUES (?)[0m [["title", "Foobar"]]
|
379
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
|
380
|
+
[1m[36mPost Load (0.0ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
381
|
+
[1m[36mTRANSACTION (0.2ms)[0m [1m[31mrollback transaction[0m
|
382
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
383
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT COUNT(*) FROM "posts"[0m
|
384
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
385
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
386
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT ?[0m [["LIMIT", 1]]
|
387
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
388
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
389
|
+
[1m[36mPost Load (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT ?[0m [["LIMIT", 1]]
|
390
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
391
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[36mbegin transaction[0m
|
392
|
+
[1m[35m (0.1ms)[0m [1m[34mSELECT "posts".* FROM "posts"[0m
|
393
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
@@ -1,94 +1,137 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require 'spec_helper'
|
4
2
|
|
5
3
|
describe ArelHelpers do
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
Post.joins(ArelHelpers.join_association(Post, :comments)).to_sql.
|
9
|
-
'SELECT "posts".* FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"'
|
4
|
+
describe '#join_association' do
|
5
|
+
it 'should work for a directly associated model' do
|
6
|
+
expect(Post.joins(ArelHelpers.join_association(Post, :comments)).to_sql).to(
|
7
|
+
eq('SELECT "posts".* FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"')
|
8
|
+
)
|
10
9
|
end
|
11
10
|
|
12
|
-
it
|
13
|
-
Post.joins(ArelHelpers.join_association(Post, :comments, Arel::Nodes::OuterJoin)).to_sql.
|
14
|
-
'SELECT "posts".* FROM "posts" LEFT OUTER JOIN "comments" ON "comments"."post_id" = "posts"."id"'
|
11
|
+
it 'should work with an outer join' do
|
12
|
+
expect(Post.joins(ArelHelpers.join_association(Post, :comments, Arel::Nodes::OuterJoin)).to_sql).to(
|
13
|
+
eq('SELECT "posts".* FROM "posts" LEFT OUTER JOIN "comments" ON "comments"."post_id" = "posts"."id"')
|
14
|
+
)
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
Post.joins(ArelHelpers.join_association(Post, :comments) do |
|
17
|
+
it 'should allow adding additional join conditions' do
|
18
|
+
sql = Post.joins(ArelHelpers.join_association(Post, :comments) do |_assoc_name, join_conditions|
|
19
19
|
join_conditions.and(Comment[:id].eq(10))
|
20
|
-
end).to_sql
|
21
|
-
|
20
|
+
end).to_sql
|
21
|
+
|
22
|
+
expect(sql).to eq <<-SQL.squish
|
23
|
+
SELECT "posts".* FROM "posts"
|
24
|
+
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id" AND "comments"."id" = 10
|
25
|
+
SQL
|
22
26
|
end
|
23
27
|
|
24
|
-
it
|
25
|
-
Post
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
it 'should work for two models, one directly associated and the other indirectly' do
|
29
|
+
sql = Post
|
30
|
+
.joins(ArelHelpers.join_association(Post, :comments))
|
31
|
+
.joins(ArelHelpers.join_association(Comment, :author))
|
32
|
+
.to_sql
|
33
|
+
|
34
|
+
expect(sql).to eq <<-SQL.squish
|
35
|
+
SELECT "posts".* FROM "posts"
|
36
|
+
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
|
37
|
+
INNER JOIN "authors" ON "authors"."id" = "comments"."author_id"
|
38
|
+
SQL
|
30
39
|
end
|
31
40
|
|
32
|
-
it
|
33
|
-
Post
|
34
|
-
|
35
|
-
|
36
|
-
|
41
|
+
it 'should work for a nested hash of association names' do
|
42
|
+
sql = Post
|
43
|
+
.joins(ArelHelpers.join_association(Post, { comments: :author }))
|
44
|
+
.to_sql
|
45
|
+
|
46
|
+
expect(sql).to eq <<-SQL.squish
|
47
|
+
SELECT "posts".* FROM "posts"
|
48
|
+
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
|
49
|
+
INNER JOIN "authors" ON "authors"."id" = "comments"."author_id"
|
50
|
+
SQL
|
37
51
|
end
|
38
52
|
|
39
|
-
it
|
40
|
-
Post
|
41
|
-
|
42
|
-
|
43
|
-
|
53
|
+
it 'should work with outer joins when given a nested hash of association names' do
|
54
|
+
sql = Post.joins(ArelHelpers.join_association(Post, { comments: :author }, Arel::Nodes::OuterJoin)).to_sql
|
55
|
+
|
56
|
+
expect(sql).to eq <<-SQL.squish
|
57
|
+
SELECT "posts".* FROM "posts"
|
58
|
+
LEFT OUTER JOIN "comments" ON "comments"."post_id" = "posts"."id"
|
59
|
+
LEFT OUTER JOIN "authors" ON "authors"."id" = "comments"."author_id"
|
60
|
+
SQL
|
44
61
|
end
|
45
62
|
|
46
|
-
it
|
47
|
-
Post.joins(ArelHelpers.join_association(Post, [
|
48
|
-
|
63
|
+
it 'should be able to handle multiple associations' do
|
64
|
+
expect(Post.joins(ArelHelpers.join_association(Post, %i[comments favorites])).to_sql).to(
|
65
|
+
eq <<-SQL.squish
|
66
|
+
SELECT "posts".* FROM "posts"
|
67
|
+
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
|
68
|
+
INNER JOIN "favorites" ON "favorites"."post_id" = "posts"."id"
|
69
|
+
SQL
|
70
|
+
)
|
49
71
|
end
|
50
72
|
|
51
|
-
it
|
52
|
-
Post.joins(ArelHelpers.join_association(Post, [
|
73
|
+
it 'should yield once for each association' do
|
74
|
+
sql = Post.joins(ArelHelpers.join_association(Post, %i[comments favorites]) do |assoc_name, join_conditions|
|
53
75
|
case assoc_name
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
76
|
+
when :favorites
|
77
|
+
join_conditions.or(Favorite[:amount].eq('lots'))
|
78
|
+
when :comments
|
79
|
+
join_conditions.and(Comment[:text].eq('Awesome post!'))
|
58
80
|
end
|
59
|
-
end).to_sql
|
60
|
-
|
81
|
+
end).to_sql
|
82
|
+
|
83
|
+
expect(sql).to eq <<-SQL.squish
|
84
|
+
SELECT "posts".* FROM "posts"
|
85
|
+
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id" AND "comments"."text" = 'Awesome post!'
|
86
|
+
INNER JOIN "favorites" (ON "favorites"."post_id" = "posts"."id" OR "favorites"."amount" = 'lots')
|
87
|
+
SQL
|
61
88
|
end
|
62
89
|
|
63
90
|
it 'should be able to handle has_and_belongs_to_many associations' do
|
64
|
-
CollabPost.joins(ArelHelpers.join_association(CollabPost, :authors)).to_sql
|
65
|
-
|
91
|
+
sql = CollabPost.joins(ArelHelpers.join_association(CollabPost, :authors)).to_sql
|
92
|
+
|
93
|
+
expect(sql).to eq <<-SQL.squish
|
94
|
+
SELECT "collab_posts".* FROM "collab_posts"
|
95
|
+
INNER JOIN "authors_collab_posts" ON "authors_collab_posts"."collab_post_id" = "collab_posts"."id"
|
96
|
+
INNER JOIN "authors" ON "authors"."id" = "authors_collab_posts"."author_id"
|
97
|
+
SQL
|
66
98
|
end
|
67
99
|
|
68
|
-
it
|
100
|
+
it 'allows adding a custom alias to the joined table' do
|
69
101
|
Comment.aliased_as(:foo) do |foo|
|
70
|
-
Post.joins(
|
71
|
-
|
102
|
+
sql = Post.joins(
|
103
|
+
ArelHelpers.join_association(Post, :comments, Arel::Nodes::InnerJoin, aliases: [foo])
|
104
|
+
).to_sql
|
105
|
+
|
106
|
+
expect(sql).to eq 'SELECT "posts".* FROM "posts" INNER JOIN "comments" "foo" ON "foo"."post_id" = "posts"."id"'
|
72
107
|
end
|
73
108
|
end
|
74
109
|
|
75
|
-
it
|
110
|
+
it 'allows aliasing multiple associations' do
|
76
111
|
Comment.aliased_as(:foo) do |foo|
|
77
112
|
Favorite.aliased_as(:bar) do |bar|
|
78
|
-
Post.joins(
|
79
|
-
|
113
|
+
sql = Post.joins(
|
114
|
+
ArelHelpers.join_association(Post, %i[comments favorites], Arel::Nodes::InnerJoin, aliases: [foo, bar])
|
115
|
+
).to_sql
|
116
|
+
|
117
|
+
expect(sql).to eq <<-SQL.squish
|
118
|
+
SELECT "posts".* FROM "posts"
|
119
|
+
INNER JOIN "comments" "foo" ON "foo"."post_id" = "posts"."id"
|
120
|
+
INNER JOIN "favorites" "bar" ON "bar"."post_id" = "posts"."id"
|
121
|
+
SQL
|
80
122
|
end
|
81
123
|
end
|
82
124
|
end
|
83
125
|
|
84
126
|
it 'handles polymorphic through associations' do
|
85
|
-
|
86
|
-
|
87
|
-
|
127
|
+
location = Location.create!
|
128
|
+
ticket = CommunityTicket.create!
|
129
|
+
CardLocation.create! card: ticket, location: location
|
130
|
+
|
131
|
+
relation = Location.joins(ArelHelpers.join_association(Location, :community_tickets))
|
88
132
|
|
89
|
-
relation.
|
90
|
-
|
91
|
-
'INNER JOIN "community_tickets" ON "community_tickets"."id" = "card_locations"."card_id"'
|
133
|
+
expect(relation.count).to eq 1
|
134
|
+
expect(relation.to_a).to include location
|
92
135
|
end
|
93
136
|
end
|
94
137
|
end
|
@@ -98,8 +141,9 @@ describe ArelHelpers::JoinAssociation do
|
|
98
141
|
include ArelHelpers::JoinAssociation
|
99
142
|
end
|
100
143
|
|
101
|
-
it
|
102
|
-
AssocPost.joins(AssocPost.join_association(:comments)).to_sql.
|
103
|
-
|
144
|
+
it 'should provide the join_association method and use the parent class as the model to join on' do
|
145
|
+
expect(AssocPost.joins(AssocPost.join_association(:comments)).to_sql).to eq <<-SQL.squish
|
146
|
+
SELECT "posts".* FROM "posts" INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
|
147
|
+
SQL
|
104
148
|
end
|
105
149
|
end
|