arel-helpers 2.12.1 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20ee0a4bd3c483dbe5dc58fa930700f36a09e593faf1982f0c578e5adb4736e4
4
- data.tar.gz: 26195a43b12121bb2ef5d4bbee9ebe9e95ce70769e24206892a04cd04d76cc25
3
+ metadata.gz: afe6ddeb4e41b56b59f08d6b2ac09bfd832e66b995355169b756ed22d11a2136
4
+ data.tar.gz: 944d2e1730143abe055f2dad7efe9d01b9ddafabab2080811714d72405177446
5
5
  SHA512:
6
- metadata.gz: 6e40a55ba798ac3c094a44aaf0d9dce31cf6ce12adca9a5e2b45f225696f69dfcbc1cb8b517ea984113ad888392b519b4d98538fd904f3cb4bdbfe7772cac5c7
7
- data.tar.gz: 409ebbdbaedef2216bc68579f562dcfa44dfb2dcf7b0b4275599fee2c11f3e165674237cf882c4aef31e651069079649a04e583ac15a06a9ebfc39c3b0b48b98
6
+ metadata.gz: 5f03ab5b864494bcc5cfb2bc7558c315a18e6460cd815c34855b2b3f0ac9d2696a49b3bd3755543c9124e2ef0667e4d774ae4164cd0317705f74556696c6cfc3
7
+ data.tar.gz: e3f704bb25be566eb5797f81804d4446b9c3c96b5df84129afb5bdeec16b91fb420d2cc7ff901648e8dab03a818d2036a5288fa6a11c95d14231b6cd9ed74b97
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![Unit Tests](https://github.com/camertron/arel-helpers/actions/workflows/unit_tests.yml/badge.svg?branch=master)
2
2
 
3
- ## arel-helpers [![Build Status](https://secure.travis-ci.org/camertron/arel-helpers.png?branch=master)](http://travis-ci.org/camertron/arel-helpers)
3
+ ## arel-helpers
4
4
 
5
5
  Useful tools to help construct database queries with ActiveRecord and Arel.
6
6
 
@@ -9,7 +9,7 @@ module ArelHelpers
9
9
  include Enumerable
10
10
 
11
11
  attr_reader :query
12
- def_delegators :@query, :to_a, :to_sql, :each
12
+ def_delegators :@query, :to_a, :to_sql, :each, :empty?, :size
13
13
 
14
14
  TERMINAL_METHODS = [:count, :first, :last]
15
15
  TERMINAL_METHODS << :pluck if ActiveRecord::VERSION::MAJOR >= 4
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module ArelHelpers
4
- VERSION = '2.12.1'
4
+ VERSION = '2.13.0'
5
5
  end
@@ -391,3 +391,140 @@
391
391
  TRANSACTION (0.0ms) begin transaction
392
392
   (0.1ms) SELECT "posts".* FROM "posts"
393
393
  TRANSACTION (0.0ms) rollback transaction
394
+  (1.3ms) SELECT sqlite_version(*)
395
+  (0.0ms) SELECT sqlite_version(*)
396
+  (1.0ms) CREATE TABLE "posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar)
397
+  (1.0ms) CREATE TABLE "comments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "post_id" integer)
398
+  (1.0ms) CREATE INDEX "index_comments_on_post_id" ON "comments" ("post_id")
399
+  (1.1ms) CREATE TABLE "authors" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "comment_id" integer, "collab_posts_id" integer)
400
+  (1.0ms) CREATE INDEX "index_authors_on_comment_id" ON "authors" ("comment_id")
401
+  (0.9ms) CREATE INDEX "index_authors_on_collab_posts_id" ON "authors" ("collab_posts_id")
402
+  (0.9ms) CREATE TABLE "favorites" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "post_id" integer)
403
+  (0.9ms) CREATE INDEX "index_favorites_on_post_id" ON "favorites" ("post_id")
404
+  (0.9ms) CREATE TABLE "collab_posts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "authors_id" integer)
405
+  (0.8ms) CREATE INDEX "index_collab_posts_on_authors_id" ON "collab_posts" ("authors_id")
406
+  (1.0ms) CREATE TABLE "cards" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)
407
+  (0.9ms) CREATE TABLE "card_locations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "location_id" integer, "card_type" varchar, "card_id" integer)
408
+  (0.9ms) CREATE INDEX "index_card_locations_on_location_id" ON "card_locations" ("location_id")
409
+  (1.1ms) CREATE INDEX "index_card_locations_on_card" ON "card_locations" ("card_type", "card_id")
410
+  (0.9ms) CREATE TABLE "locations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)
411
+  (0.9ms) CREATE TABLE "community_tickets" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL)
412
+  (1.0ms) CREATE TABLE "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL)
413
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
414
+ TRANSACTION (0.0ms) begin transaction
415
+ ActiveRecord::InternalMetadata Create (0.4ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["key", "environment"], ["value", "test"], ["created_at", "2021-12-06 21:11:29.100377"], ["updated_at", "2021-12-06 21:11:29.100377"]]
416
+ TRANSACTION (0.8ms) commit transaction
417
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY)
418
+ ActiveRecord::InternalMetadata Load (0.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? LIMIT ? [["key", "environment"], ["LIMIT", 1]]
419
+  (0.1ms) SELECT sqlite_version(*)
420
+  (0.0ms) PRAGMA foreign_keys
421
+  (0.0ms) PRAGMA defer_foreign_keys
422
+  (0.1ms) PRAGMA defer_foreign_keys = ON
423
+  (0.0ms) PRAGMA foreign_keys = OFF
424
+  (0.8ms) DELETE FROM "posts";
425
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
426
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'posts';
427
+  (0.8ms) DELETE FROM "comments";
428
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
429
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'comments';
430
+  (1.7ms) DELETE FROM "authors";
431
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
432
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'authors';
433
+  (1.1ms) DELETE FROM "favorites";
434
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
435
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'favorites';
436
+  (0.8ms) DELETE FROM "collab_posts";
437
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
438
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'collab_posts';
439
+  (1.1ms) DELETE FROM "cards";
440
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
441
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'cards';
442
+  (0.9ms) DELETE FROM "card_locations";
443
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
444
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'card_locations';
445
+  (0.9ms) DELETE FROM "locations";
446
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
447
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'locations';
448
+  (1.0ms) DELETE FROM "community_tickets";
449
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
450
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'community_tickets';
451
+  (0.0ms) PRAGMA defer_foreign_keys = 0
452
+  (0.0ms) PRAGMA foreign_keys = 1
453
+ TRANSACTION (0.0ms) begin transaction
454
+ TRANSACTION (0.1ms) SAVEPOINT active_record_1
455
+ Post Create (0.4ms) INSERT INTO "posts" ("title") VALUES (?) [["title", "I'm a little teapot"]]
456
+ TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1
457
+ Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ? [["post_id", 1]]
458
+ TRANSACTION (0.2ms) rollback transaction
459
+ TRANSACTION (0.0ms) begin transaction
460
+ TRANSACTION (0.0ms) SAVEPOINT active_record_1
461
+ Post Create (0.5ms) INSERT INTO "posts" ("title") VALUES (?) [["title", "I'm a little teapot"]]
462
+ TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1
463
+ TRANSACTION (0.1ms) SAVEPOINT active_record_1
464
+ Comment Create (0.2ms) INSERT INTO "comments" ("post_id") VALUES (?) [["post_id", 1]]
465
+ TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1
466
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
467
+ Comment Load (0.0ms) SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ? [["post_id", 1]]
468
+ TRANSACTION (0.4ms) rollback transaction
469
+ TRANSACTION (0.0ms) begin transaction
470
+ Post Load (0.1ms) SELECT "posts".* FROM "posts"
471
+ TRANSACTION (0.0ms) SAVEPOINT active_record_1
472
+ Post Create (0.3ms) INSERT INTO "posts" ("title") VALUES (?) [["title", "foo"]]
473
+ TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1
474
+ Post Load (0.0ms) SELECT "posts".* FROM "posts"
475
+ TRANSACTION (0.2ms) rollback transaction
476
+ TRANSACTION (0.1ms) begin transaction
477
+ TRANSACTION (0.1ms) rollback transaction
478
+ TRANSACTION (0.0ms) begin transaction
479
+ TRANSACTION (0.0ms) rollback transaction
480
+ TRANSACTION (0.0ms) begin transaction
481
+ TRANSACTION (0.0ms) rollback transaction
482
+ TRANSACTION (0.0ms) begin transaction
483
+ TRANSACTION (0.0ms) SAVEPOINT active_record_1
484
+ Location Create (0.4ms) INSERT INTO "locations" DEFAULT VALUES
485
+ TRANSACTION (0.1ms) RELEASE SAVEPOINT active_record_1
486
+ TRANSACTION (0.1ms) SAVEPOINT active_record_1
487
+ CommunityTicket Create (0.2ms) INSERT INTO "community_tickets" DEFAULT VALUES
488
+ TRANSACTION (0.1ms) RELEASE SAVEPOINT active_record_1
489
+ TRANSACTION (0.1ms) SAVEPOINT active_record_1
490
+ CardLocation Create (0.3ms) INSERT INTO "card_locations" ("location_id", "card_type", "card_id") VALUES (?, ?, ?) [["location_id", 1], ["card_type", "CommunityTicket"], ["card_id", 1]]
491
+ TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1
492
+  (0.1ms) SELECT 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" [["card_type", "CommunityTicket"]]
493
+ Location Load (0.4ms) SELECT "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" [["card_type", "CommunityTicket"]]
494
+ TRANSACTION (0.4ms) rollback transaction
495
+ TRANSACTION (0.0ms) begin transaction
496
+ TRANSACTION (0.0ms) SAVEPOINT active_record_1
497
+ Post Create (0.4ms) INSERT INTO "posts" ("title") VALUES (?) [["title", "Foobar"]]
498
+ TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1
499
+ Post Load (0.0ms) SELECT "posts".* FROM "posts"
500
+ TRANSACTION (0.4ms) rollback transaction
501
+ TRANSACTION (0.1ms) begin transaction
502
+ TRANSACTION (0.1ms) SAVEPOINT active_record_1
503
+ Post Create (0.7ms) INSERT INTO "posts" ("title") VALUES (?) [["title", "Foobar"]]
504
+ TRANSACTION (0.1ms) RELEASE SAVEPOINT active_record_1
505
+ Post Load (0.1ms) SELECT "posts".* FROM "posts"
506
+ TRANSACTION (0.5ms) rollback transaction
507
+ TRANSACTION (0.1ms) begin transaction
508
+ TRANSACTION (0.1ms) SAVEPOINT active_record_1
509
+ Post Create (0.7ms) INSERT INTO "posts" ("title") VALUES (?) [["title", "Foobar"]]
510
+ TRANSACTION (0.0ms) RELEASE SAVEPOINT active_record_1
511
+ Post Load (0.0ms) SELECT "posts".* FROM "posts"
512
+ TRANSACTION (0.3ms) rollback transaction
513
+ TRANSACTION (0.0ms) begin transaction
514
+ Post Exists? (0.1ms) SELECT 1 AS one FROM "posts" LIMIT ? [["LIMIT", 1]]
515
+ TRANSACTION (0.0ms) rollback transaction
516
+ TRANSACTION (0.0ms) begin transaction
517
+  (0.1ms) SELECT COUNT(*) FROM "posts"
518
+ TRANSACTION (0.0ms) rollback transaction
519
+ TRANSACTION (0.1ms) begin transaction
520
+  (0.1ms) SELECT COUNT(*) FROM "posts"
521
+ TRANSACTION (0.1ms) rollback transaction
522
+ TRANSACTION (0.0ms) begin transaction
523
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT ? [["LIMIT", 1]]
524
+ TRANSACTION (0.0ms) rollback transaction
525
+ TRANSACTION (0.1ms) begin transaction
526
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT ? [["LIMIT", 1]]
527
+ TRANSACTION (0.1ms) rollback transaction
528
+ TRANSACTION (0.1ms) begin transaction
529
+  (0.1ms) SELECT "posts".* FROM "posts"
530
+ TRANSACTION (0.1ms) rollback transaction
@@ -53,6 +53,14 @@ describe ArelHelpers::QueryBuilder do
53
53
  expect(builder.map(&:title)).to eq ['Foobar']
54
54
  end
55
55
 
56
+ it 'forwards #empty?' do
57
+ expect(builder.empty?).to eq true
58
+ end
59
+
60
+ it 'forwards #size' do
61
+ expect(builder.size).to eq 0
62
+ end
63
+
56
64
  ArelHelpers::QueryBuilder::TERMINAL_METHODS.each do |method|
57
65
  it "does not enumerate records for #{method}" do
58
66
  allow(builder).to receive :each
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arel-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.1
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-26 00:00:00.000000000 Z
11
+ date: 2021-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord