postgres_tree 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/postgres_tree/concerns/model/active_record.rb +34 -11
- data/lib/postgres_tree/version.rb +1 -1
- data/test/dummy/log/test.log +484 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 483400384d001e4d4a7cb01a5d77f22ef18d70a7
|
4
|
+
data.tar.gz: bb55d1b2321d1a4a25c7a15ca8291ebe8e6492bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f53208c74944cdb1ea47507c853eaf373c8e9915bb69cd2dfd887ea2855f06655c94953bc385796b344521d931bf1644e9b0670a9e3f86190195c9af446bd16
|
7
|
+
data.tar.gz: 305257082f0bd368c7238a00989c3e17cd8b9020fe22fe876f5304ebace8e29e1d7d5a68402b19b58f8fa99dbf4ef6b1c69d3c48b106fc2f8cd2720fd51d20f4
|
@@ -8,33 +8,56 @@ module PostgresTree::ActiveRecordConcern
|
|
8
8
|
scope :tree_roots, -> { where(parent_id: nil) }
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
11
|
+
# Get all ancestors
|
12
|
+
#
|
13
|
+
# Example:
|
14
|
+
# > parent.ancestors
|
15
|
+
# => [#<Role id: 1, name: "Grandparent", parent_id: nil>]
|
16
|
+
|
12
17
|
def ancestors
|
13
18
|
self_and_ancestors - [self]
|
14
19
|
end
|
20
|
+
|
21
|
+
# Get all ancestors and include self in the returned result
|
22
|
+
#
|
23
|
+
# Example:
|
24
|
+
# > parent.self_and_ancestors
|
25
|
+
# => #<ActiveRecord::Relation [#<Role id: 1, name: "Grandparent", parent_id: nil>, #<Role id: 2, name: "Parent", parent_id: 1>]>
|
26
|
+
|
15
27
|
def self_and_ancestors
|
16
28
|
self_and_ancestors_for(self)
|
17
29
|
end
|
18
30
|
|
19
|
-
#
|
31
|
+
# Get all descendents
|
32
|
+
#
|
33
|
+
# Example:
|
34
|
+
# > parent.descendents
|
35
|
+
# => [#<Role id: 3, name: "Child", parent_id: 2>]
|
36
|
+
|
20
37
|
def descendents
|
21
38
|
self_and_descendents - [self]
|
22
39
|
end
|
40
|
+
|
41
|
+
# Get all descendents and include self in the returned result
|
42
|
+
#
|
43
|
+
# Example:
|
44
|
+
# > parent.self_and_descendents
|
45
|
+
# => #<ActiveRecord::Relation [#<Role id: 2, name: "Parent", parent_id: 1>, #<Role id: 3, name: "Child", parent_id: 2>]>
|
46
|
+
|
23
47
|
def self_and_descendents
|
24
48
|
self_and_descendents_for(self)
|
25
49
|
end
|
26
50
|
|
27
|
-
# Check if ancestors, self_and_ancestors, descendents or self_and_descendents includes? object
|
28
|
-
def method_missing(method, *args, &block)
|
29
|
-
if method.to_s =~ /\A(.+)_include\?\z/
|
30
|
-
self.send($1.to_sym).include? *args.first
|
31
|
-
else
|
32
|
-
super
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
51
|
private
|
37
52
|
|
53
|
+
def method_missing(method, *args, &block)
|
54
|
+
if method.to_s =~ /\A(.+)_include\?\z/
|
55
|
+
self.send($1.to_sym).include? *args.first
|
56
|
+
else
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
38
61
|
def respond_to_missing?(method, include_private_methods = false)
|
39
62
|
method.to_s =~ /\A(.+)_include\?\z/ || super
|
40
63
|
end
|
data/test/dummy/log/test.log
CHANGED
@@ -3231,3 +3231,487 @@ PersonTest: test_tree_roots_scope
|
|
3231
3231
|
PostgresTreeTest: test_truth
|
3232
3232
|
----------------------------
|
3233
3233
|
[1m[35m (0.1ms)[0m ROLLBACK
|
3234
|
+
[1m[36mActiveRecord::SchemaMigration Load (26.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
3235
|
+
[1m[35m (221.9ms)[0m drop schema public cascade;
|
3236
|
+
[1m[36m (49.0ms)[0m [1mcreate schema public;[0m
|
3237
|
+
[1m[35m (150.1ms)[0m CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL)
|
3238
|
+
[1m[36m (108.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
3239
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.7ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
3240
|
+
Migrating to CreatePeople (20140918023556)
|
3241
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3242
|
+
[1m[35m (128.8ms)[0m CREATE TABLE "people" ("id" serial primary key, "name" character varying(255), "parent_id" integer, "created_at" timestamp, "updated_at" timestamp)
|
3243
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ($1)[0m [["version", "20140918023556"]]
|
3244
|
+
[1m[35m (19.5ms)[0m COMMIT
|
3245
|
+
[1m[36m (37.8ms)[0m [1mALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "people" DISABLE TRIGGER ALL[0m
|
3246
|
+
[1m[35m (0.5ms)[0m BEGIN
|
3247
|
+
[1m[36mFixture Delete (0.8ms)[0m [1mDELETE FROM "people"[0m
|
3248
|
+
[1m[35mFixture Insert (0.6ms)[0m INSERT INTO "people" ("id", "name", "created_at", "updated_at") VALUES (1, 'Grandad', '2014-09-22 05:30:23', '2014-09-22 05:30:23')
|
3249
|
+
[1m[36mFixture Insert (0.3ms)[0m [1mINSERT INTO "people" ("id", "name", "parent_id", "created_at", "updated_at") VALUES (2, 'Dad', 1, '2014-09-22 05:30:23', '2014-09-22 05:30:23')[0m
|
3250
|
+
[1m[35mFixture Insert (0.2ms)[0m INSERT INTO "people" ("id", "name", "parent_id", "created_at", "updated_at") VALUES (3, 'Son', 2, '2014-09-22 05:30:23', '2014-09-22 05:30:23')
|
3251
|
+
[1m[36m (55.4ms)[0m [1mCOMMIT[0m
|
3252
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "people" ENABLE TRIGGER ALL
|
3253
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3254
|
+
------------------------------
|
3255
|
+
PersonTest: test_dad_ancestors
|
3256
|
+
------------------------------
|
3257
|
+
[1m[35mPerson Load (0.4ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1 [["id", 1]]
|
3258
|
+
[1m[36mPerson Load (0.5ms)[0m [1mSELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1[0m [["id", 2]]
|
3259
|
+
[1m[35mPerson Load (2.1ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3260
|
+
SELECT id, parent_id, ARRAY[id]
|
3261
|
+
FROM people
|
3262
|
+
WHERE id = 2
|
3263
|
+
UNION ALL
|
3264
|
+
SELECT people.id, people.parent_id, path || people.id
|
3265
|
+
FROM search_tree
|
3266
|
+
JOIN people ON people.id = search_tree.parent_id
|
3267
|
+
WHERE NOT people.id = ANY(path)
|
3268
|
+
)
|
3269
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3270
|
+
))
|
3271
|
+
[1m[36mPerson Load (0.8ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3272
|
+
SELECT id, parent_id, ARRAY[id]
|
3273
|
+
FROM people
|
3274
|
+
WHERE id = 2
|
3275
|
+
UNION ALL
|
3276
|
+
SELECT people.id, people.parent_id, path || people.id
|
3277
|
+
FROM search_tree
|
3278
|
+
JOIN people ON people.id = search_tree.parent_id
|
3279
|
+
WHERE NOT people.id = ANY(path)
|
3280
|
+
)
|
3281
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3282
|
+
))[0m
|
3283
|
+
[1m[35m (1.0ms)[0m SELECT COUNT(*) FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3284
|
+
SELECT id, parent_id, ARRAY[id]
|
3285
|
+
FROM people
|
3286
|
+
WHERE id = 2
|
3287
|
+
UNION ALL
|
3288
|
+
SELECT people.id, people.parent_id, path || people.id
|
3289
|
+
FROM search_tree
|
3290
|
+
JOIN people ON people.id = search_tree.parent_id
|
3291
|
+
WHERE NOT people.id = ANY(path)
|
3292
|
+
)
|
3293
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3294
|
+
))
|
3295
|
+
[1m[36mPerson Load (1.1ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3296
|
+
SELECT id, parent_id, ARRAY[id]
|
3297
|
+
FROM people
|
3298
|
+
WHERE id = 2
|
3299
|
+
UNION ALL
|
3300
|
+
SELECT people.id, people.parent_id, path || people.id
|
3301
|
+
FROM search_tree
|
3302
|
+
JOIN people ON people.id = search_tree.parent_id
|
3303
|
+
WHERE NOT people.id = ANY(path)
|
3304
|
+
)
|
3305
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3306
|
+
))[0m
|
3307
|
+
[1m[35mPerson Load (0.9ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3308
|
+
SELECT id, parent_id, ARRAY[id]
|
3309
|
+
FROM people
|
3310
|
+
WHERE id = 2
|
3311
|
+
UNION ALL
|
3312
|
+
SELECT people.id, people.parent_id, path || people.id
|
3313
|
+
FROM search_tree
|
3314
|
+
JOIN people ON people.id = search_tree.parent_id
|
3315
|
+
WHERE NOT people.id = ANY(path)
|
3316
|
+
)
|
3317
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3318
|
+
))
|
3319
|
+
[1m[36mPerson Load (1.6ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3320
|
+
SELECT id, parent_id, ARRAY[id]
|
3321
|
+
FROM people
|
3322
|
+
WHERE id = 2
|
3323
|
+
UNION ALL
|
3324
|
+
SELECT people.id, people.parent_id, path || people.id
|
3325
|
+
FROM search_tree
|
3326
|
+
JOIN people ON people.id = search_tree.parent_id
|
3327
|
+
WHERE NOT people.id = ANY(path)
|
3328
|
+
)
|
3329
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3330
|
+
))[0m
|
3331
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
3332
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3333
|
+
--------------------------------
|
3334
|
+
PersonTest: test_dad_descendents
|
3335
|
+
--------------------------------
|
3336
|
+
[1m[35mPerson Load (0.2ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1 [["id", 2]]
|
3337
|
+
[1m[36mPerson Load (0.3ms)[0m [1mSELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1[0m [["id", 3]]
|
3338
|
+
[1m[35mPerson Load (0.6ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3339
|
+
SELECT id, ARRAY[id]
|
3340
|
+
FROM people
|
3341
|
+
WHERE id = 2
|
3342
|
+
UNION ALL
|
3343
|
+
SELECT people.id, path || people.id
|
3344
|
+
FROM search_tree
|
3345
|
+
JOIN people ON people.parent_id = search_tree.id
|
3346
|
+
WHERE NOT people.id = ANY(path)
|
3347
|
+
)
|
3348
|
+
SELECT id FROM search_tree ORDER BY path
|
3349
|
+
))
|
3350
|
+
[1m[36mPerson Load (0.5ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3351
|
+
SELECT id, ARRAY[id]
|
3352
|
+
FROM people
|
3353
|
+
WHERE id = 2
|
3354
|
+
UNION ALL
|
3355
|
+
SELECT people.id, path || people.id
|
3356
|
+
FROM search_tree
|
3357
|
+
JOIN people ON people.parent_id = search_tree.id
|
3358
|
+
WHERE NOT people.id = ANY(path)
|
3359
|
+
)
|
3360
|
+
SELECT id FROM search_tree ORDER BY path
|
3361
|
+
))[0m
|
3362
|
+
[1m[35m (0.5ms)[0m SELECT COUNT(*) FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3363
|
+
SELECT id, ARRAY[id]
|
3364
|
+
FROM people
|
3365
|
+
WHERE id = 2
|
3366
|
+
UNION ALL
|
3367
|
+
SELECT people.id, path || people.id
|
3368
|
+
FROM search_tree
|
3369
|
+
JOIN people ON people.parent_id = search_tree.id
|
3370
|
+
WHERE NOT people.id = ANY(path)
|
3371
|
+
)
|
3372
|
+
SELECT id FROM search_tree ORDER BY path
|
3373
|
+
))
|
3374
|
+
[1m[36mPerson Load (0.5ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3375
|
+
SELECT id, ARRAY[id]
|
3376
|
+
FROM people
|
3377
|
+
WHERE id = 2
|
3378
|
+
UNION ALL
|
3379
|
+
SELECT people.id, path || people.id
|
3380
|
+
FROM search_tree
|
3381
|
+
JOIN people ON people.parent_id = search_tree.id
|
3382
|
+
WHERE NOT people.id = ANY(path)
|
3383
|
+
)
|
3384
|
+
SELECT id FROM search_tree ORDER BY path
|
3385
|
+
))[0m
|
3386
|
+
[1m[35mPerson Load (0.7ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3387
|
+
SELECT id, ARRAY[id]
|
3388
|
+
FROM people
|
3389
|
+
WHERE id = 2
|
3390
|
+
UNION ALL
|
3391
|
+
SELECT people.id, path || people.id
|
3392
|
+
FROM search_tree
|
3393
|
+
JOIN people ON people.parent_id = search_tree.id
|
3394
|
+
WHERE NOT people.id = ANY(path)
|
3395
|
+
)
|
3396
|
+
SELECT id FROM search_tree ORDER BY path
|
3397
|
+
))
|
3398
|
+
[1m[36mPerson Load (0.8ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3399
|
+
SELECT id, ARRAY[id]
|
3400
|
+
FROM people
|
3401
|
+
WHERE id = 2
|
3402
|
+
UNION ALL
|
3403
|
+
SELECT people.id, path || people.id
|
3404
|
+
FROM search_tree
|
3405
|
+
JOIN people ON people.parent_id = search_tree.id
|
3406
|
+
WHERE NOT people.id = ANY(path)
|
3407
|
+
)
|
3408
|
+
SELECT id FROM search_tree ORDER BY path
|
3409
|
+
))[0m
|
3410
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
3411
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3412
|
+
----------------------------------
|
3413
|
+
PersonTest: test_grandad_ancestors
|
3414
|
+
----------------------------------
|
3415
|
+
[1m[35mPerson Load (0.3ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1 [["id", 1]]
|
3416
|
+
[1m[36mPerson Load (0.8ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3417
|
+
SELECT id, parent_id, ARRAY[id]
|
3418
|
+
FROM people
|
3419
|
+
WHERE id = 1
|
3420
|
+
UNION ALL
|
3421
|
+
SELECT people.id, people.parent_id, path || people.id
|
3422
|
+
FROM search_tree
|
3423
|
+
JOIN people ON people.id = search_tree.parent_id
|
3424
|
+
WHERE NOT people.id = ANY(path)
|
3425
|
+
)
|
3426
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3427
|
+
))[0m
|
3428
|
+
[1m[35m (0.1ms)[0m ROLLBACK
|
3429
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3430
|
+
---------------------------------------
|
3431
|
+
PersonTest: test_person_fixtures_loaded
|
3432
|
+
---------------------------------------
|
3433
|
+
[1m[35mPerson Load (0.4ms)[0m SELECT "people".* FROM "people" ORDER BY "people"."id" ASC LIMIT 1
|
3434
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
3435
|
+
[1m[35m (0.1ms)[0m BEGIN
|
3436
|
+
---------------------------------------------
|
3437
|
+
PersonTest: test_respond_to_all_magic_methods
|
3438
|
+
---------------------------------------------
|
3439
|
+
[1m[36mPerson Load (0.4ms)[0m [1mSELECT "people".* FROM "people" ORDER BY "people"."id" ASC LIMIT 1[0m
|
3440
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
3441
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3442
|
+
----------------------------------------
|
3443
|
+
PersonTest: test_responds_to_all_methods
|
3444
|
+
----------------------------------------
|
3445
|
+
[1m[35mPerson Load (0.2ms)[0m SELECT "people".* FROM "people" ORDER BY "people"."id" ASC LIMIT 1
|
3446
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
3447
|
+
[1m[35m (0.1ms)[0m BEGIN
|
3448
|
+
--------------------------------
|
3449
|
+
PersonTest: test_son_descendents
|
3450
|
+
--------------------------------
|
3451
|
+
[1m[36mPerson Load (0.4ms)[0m [1mSELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1[0m [["id", 3]]
|
3452
|
+
[1m[35mPerson Load (0.7ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3453
|
+
SELECT id, ARRAY[id]
|
3454
|
+
FROM people
|
3455
|
+
WHERE id = 3
|
3456
|
+
UNION ALL
|
3457
|
+
SELECT people.id, path || people.id
|
3458
|
+
FROM search_tree
|
3459
|
+
JOIN people ON people.parent_id = search_tree.id
|
3460
|
+
WHERE NOT people.id = ANY(path)
|
3461
|
+
)
|
3462
|
+
SELECT id FROM search_tree ORDER BY path
|
3463
|
+
))
|
3464
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
3465
|
+
[1m[35m (0.1ms)[0m BEGIN
|
3466
|
+
---------------------------------
|
3467
|
+
PersonTest: test_tree_roots_scope
|
3468
|
+
---------------------------------
|
3469
|
+
[1m[36m (0.4ms)[0m [1mSELECT COUNT(*) FROM "people" WHERE "people"."parent_id" IS NULL[0m
|
3470
|
+
[1m[35m (0.1ms)[0m ROLLBACK
|
3471
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3472
|
+
----------------------------
|
3473
|
+
PostgresTreeTest: test_truth
|
3474
|
+
----------------------------
|
3475
|
+
[1m[35m (0.1ms)[0m ROLLBACK
|
3476
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.4ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
3477
|
+
[1m[35m (46.4ms)[0m drop schema public cascade;
|
3478
|
+
[1m[36m (7.1ms)[0m [1mcreate schema public;[0m
|
3479
|
+
[1m[35m (8.1ms)[0m CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL)
|
3480
|
+
[1m[36m (64.0ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
3481
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.5ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
3482
|
+
Migrating to CreatePeople (20140918023556)
|
3483
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
3484
|
+
[1m[35m (60.8ms)[0m CREATE TABLE "people" ("id" serial primary key, "name" character varying(255), "parent_id" integer, "created_at" timestamp, "updated_at" timestamp)
|
3485
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ($1)[0m [["version", "20140918023556"]]
|
3486
|
+
[1m[35m (19.4ms)[0m COMMIT
|
3487
|
+
[1m[36m (0.5ms)[0m [1mALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "people" DISABLE TRIGGER ALL[0m
|
3488
|
+
[1m[35m (0.7ms)[0m BEGIN
|
3489
|
+
[1m[36mFixture Delete (0.3ms)[0m [1mDELETE FROM "people"[0m
|
3490
|
+
[1m[35mFixture Insert (0.4ms)[0m INSERT INTO "people" ("id", "name", "created_at", "updated_at") VALUES (1, 'Grandad', '2014-09-22 05:40:02', '2014-09-22 05:40:02')
|
3491
|
+
[1m[36mFixture Insert (0.2ms)[0m [1mINSERT INTO "people" ("id", "name", "parent_id", "created_at", "updated_at") VALUES (2, 'Dad', 1, '2014-09-22 05:40:02', '2014-09-22 05:40:02')[0m
|
3492
|
+
[1m[35mFixture Insert (0.2ms)[0m INSERT INTO "people" ("id", "name", "parent_id", "created_at", "updated_at") VALUES (3, 'Son', 2, '2014-09-22 05:40:02', '2014-09-22 05:40:02')
|
3493
|
+
[1m[36m (10.4ms)[0m [1mCOMMIT[0m
|
3494
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "people" ENABLE TRIGGER ALL
|
3495
|
+
[1m[36m (0.2ms)[0m [1mBEGIN[0m
|
3496
|
+
----------------------------
|
3497
|
+
PostgresTreeTest: test_truth
|
3498
|
+
----------------------------
|
3499
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
3500
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3501
|
+
------------------------------
|
3502
|
+
PersonTest: test_dad_ancestors
|
3503
|
+
------------------------------
|
3504
|
+
[1m[35mPerson Load (0.4ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1 [["id", 1]]
|
3505
|
+
[1m[36mPerson Load (0.3ms)[0m [1mSELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1[0m [["id", 2]]
|
3506
|
+
[1m[35mPerson Load (1.0ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3507
|
+
SELECT id, parent_id, ARRAY[id]
|
3508
|
+
FROM people
|
3509
|
+
WHERE id = 2
|
3510
|
+
UNION ALL
|
3511
|
+
SELECT people.id, people.parent_id, path || people.id
|
3512
|
+
FROM search_tree
|
3513
|
+
JOIN people ON people.id = search_tree.parent_id
|
3514
|
+
WHERE NOT people.id = ANY(path)
|
3515
|
+
)
|
3516
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3517
|
+
))
|
3518
|
+
[1m[36mPerson Load (0.5ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3519
|
+
SELECT id, parent_id, ARRAY[id]
|
3520
|
+
FROM people
|
3521
|
+
WHERE id = 2
|
3522
|
+
UNION ALL
|
3523
|
+
SELECT people.id, people.parent_id, path || people.id
|
3524
|
+
FROM search_tree
|
3525
|
+
JOIN people ON people.id = search_tree.parent_id
|
3526
|
+
WHERE NOT people.id = ANY(path)
|
3527
|
+
)
|
3528
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3529
|
+
))[0m
|
3530
|
+
[1m[35m (0.8ms)[0m SELECT COUNT(*) FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3531
|
+
SELECT id, parent_id, ARRAY[id]
|
3532
|
+
FROM people
|
3533
|
+
WHERE id = 2
|
3534
|
+
UNION ALL
|
3535
|
+
SELECT people.id, people.parent_id, path || people.id
|
3536
|
+
FROM search_tree
|
3537
|
+
JOIN people ON people.id = search_tree.parent_id
|
3538
|
+
WHERE NOT people.id = ANY(path)
|
3539
|
+
)
|
3540
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3541
|
+
))
|
3542
|
+
[1m[36mPerson Load (0.7ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3543
|
+
SELECT id, parent_id, ARRAY[id]
|
3544
|
+
FROM people
|
3545
|
+
WHERE id = 2
|
3546
|
+
UNION ALL
|
3547
|
+
SELECT people.id, people.parent_id, path || people.id
|
3548
|
+
FROM search_tree
|
3549
|
+
JOIN people ON people.id = search_tree.parent_id
|
3550
|
+
WHERE NOT people.id = ANY(path)
|
3551
|
+
)
|
3552
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3553
|
+
))[0m
|
3554
|
+
[1m[35mPerson Load (1.3ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3555
|
+
SELECT id, parent_id, ARRAY[id]
|
3556
|
+
FROM people
|
3557
|
+
WHERE id = 2
|
3558
|
+
UNION ALL
|
3559
|
+
SELECT people.id, people.parent_id, path || people.id
|
3560
|
+
FROM search_tree
|
3561
|
+
JOIN people ON people.id = search_tree.parent_id
|
3562
|
+
WHERE NOT people.id = ANY(path)
|
3563
|
+
)
|
3564
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3565
|
+
))
|
3566
|
+
[1m[36mPerson Load (1.1ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3567
|
+
SELECT id, parent_id, ARRAY[id]
|
3568
|
+
FROM people
|
3569
|
+
WHERE id = 2
|
3570
|
+
UNION ALL
|
3571
|
+
SELECT people.id, people.parent_id, path || people.id
|
3572
|
+
FROM search_tree
|
3573
|
+
JOIN people ON people.id = search_tree.parent_id
|
3574
|
+
WHERE NOT people.id = ANY(path)
|
3575
|
+
)
|
3576
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3577
|
+
))[0m
|
3578
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
3579
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3580
|
+
--------------------------------
|
3581
|
+
PersonTest: test_dad_descendents
|
3582
|
+
--------------------------------
|
3583
|
+
[1m[35mPerson Load (0.3ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1 [["id", 2]]
|
3584
|
+
[1m[36mPerson Load (0.3ms)[0m [1mSELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1[0m [["id", 3]]
|
3585
|
+
[1m[35mPerson Load (0.9ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3586
|
+
SELECT id, ARRAY[id]
|
3587
|
+
FROM people
|
3588
|
+
WHERE id = 2
|
3589
|
+
UNION ALL
|
3590
|
+
SELECT people.id, path || people.id
|
3591
|
+
FROM search_tree
|
3592
|
+
JOIN people ON people.parent_id = search_tree.id
|
3593
|
+
WHERE NOT people.id = ANY(path)
|
3594
|
+
)
|
3595
|
+
SELECT id FROM search_tree ORDER BY path
|
3596
|
+
))
|
3597
|
+
[1m[36mPerson Load (0.6ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3598
|
+
SELECT id, ARRAY[id]
|
3599
|
+
FROM people
|
3600
|
+
WHERE id = 2
|
3601
|
+
UNION ALL
|
3602
|
+
SELECT people.id, path || people.id
|
3603
|
+
FROM search_tree
|
3604
|
+
JOIN people ON people.parent_id = search_tree.id
|
3605
|
+
WHERE NOT people.id = ANY(path)
|
3606
|
+
)
|
3607
|
+
SELECT id FROM search_tree ORDER BY path
|
3608
|
+
))[0m
|
3609
|
+
[1m[35m (0.7ms)[0m SELECT COUNT(*) FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3610
|
+
SELECT id, ARRAY[id]
|
3611
|
+
FROM people
|
3612
|
+
WHERE id = 2
|
3613
|
+
UNION ALL
|
3614
|
+
SELECT people.id, path || people.id
|
3615
|
+
FROM search_tree
|
3616
|
+
JOIN people ON people.parent_id = search_tree.id
|
3617
|
+
WHERE NOT people.id = ANY(path)
|
3618
|
+
)
|
3619
|
+
SELECT id FROM search_tree ORDER BY path
|
3620
|
+
))
|
3621
|
+
[1m[36mPerson Load (0.7ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3622
|
+
SELECT id, ARRAY[id]
|
3623
|
+
FROM people
|
3624
|
+
WHERE id = 2
|
3625
|
+
UNION ALL
|
3626
|
+
SELECT people.id, path || people.id
|
3627
|
+
FROM search_tree
|
3628
|
+
JOIN people ON people.parent_id = search_tree.id
|
3629
|
+
WHERE NOT people.id = ANY(path)
|
3630
|
+
)
|
3631
|
+
SELECT id FROM search_tree ORDER BY path
|
3632
|
+
))[0m
|
3633
|
+
[1m[35mPerson Load (0.7ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3634
|
+
SELECT id, ARRAY[id]
|
3635
|
+
FROM people
|
3636
|
+
WHERE id = 2
|
3637
|
+
UNION ALL
|
3638
|
+
SELECT people.id, path || people.id
|
3639
|
+
FROM search_tree
|
3640
|
+
JOIN people ON people.parent_id = search_tree.id
|
3641
|
+
WHERE NOT people.id = ANY(path)
|
3642
|
+
)
|
3643
|
+
SELECT id FROM search_tree ORDER BY path
|
3644
|
+
))
|
3645
|
+
[1m[36mPerson Load (0.9ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3646
|
+
SELECT id, ARRAY[id]
|
3647
|
+
FROM people
|
3648
|
+
WHERE id = 2
|
3649
|
+
UNION ALL
|
3650
|
+
SELECT people.id, path || people.id
|
3651
|
+
FROM search_tree
|
3652
|
+
JOIN people ON people.parent_id = search_tree.id
|
3653
|
+
WHERE NOT people.id = ANY(path)
|
3654
|
+
)
|
3655
|
+
SELECT id FROM search_tree ORDER BY path
|
3656
|
+
))[0m
|
3657
|
+
[1m[35m (0.1ms)[0m ROLLBACK
|
3658
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3659
|
+
----------------------------------
|
3660
|
+
PersonTest: test_grandad_ancestors
|
3661
|
+
----------------------------------
|
3662
|
+
[1m[35mPerson Load (0.4ms)[0m SELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1 [["id", 1]]
|
3663
|
+
[1m[36mPerson Load (1.0ms)[0m [1mSELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, parent_id, path) AS (
|
3664
|
+
SELECT id, parent_id, ARRAY[id]
|
3665
|
+
FROM people
|
3666
|
+
WHERE id = 1
|
3667
|
+
UNION ALL
|
3668
|
+
SELECT people.id, people.parent_id, path || people.id
|
3669
|
+
FROM search_tree
|
3670
|
+
JOIN people ON people.id = search_tree.parent_id
|
3671
|
+
WHERE NOT people.id = ANY(path)
|
3672
|
+
)
|
3673
|
+
SELECT id FROM search_tree ORDER BY path DESC
|
3674
|
+
))[0m
|
3675
|
+
[1m[35m (0.2ms)[0m ROLLBACK
|
3676
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3677
|
+
---------------------------------------
|
3678
|
+
PersonTest: test_person_fixtures_loaded
|
3679
|
+
---------------------------------------
|
3680
|
+
[1m[35mPerson Load (0.5ms)[0m SELECT "people".* FROM "people" ORDER BY "people"."id" ASC LIMIT 1
|
3681
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
3682
|
+
[1m[35m (0.1ms)[0m BEGIN
|
3683
|
+
---------------------------------------------
|
3684
|
+
PersonTest: test_respond_to_all_magic_methods
|
3685
|
+
---------------------------------------------
|
3686
|
+
[1m[36mPerson Load (0.3ms)[0m [1mSELECT "people".* FROM "people" ORDER BY "people"."id" ASC LIMIT 1[0m
|
3687
|
+
[1m[35m (0.1ms)[0m ROLLBACK
|
3688
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
3689
|
+
----------------------------------------
|
3690
|
+
PersonTest: test_responds_to_all_methods
|
3691
|
+
----------------------------------------
|
3692
|
+
[1m[35mPerson Load (0.2ms)[0m SELECT "people".* FROM "people" ORDER BY "people"."id" ASC LIMIT 1
|
3693
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
3694
|
+
[1m[35m (0.1ms)[0m BEGIN
|
3695
|
+
--------------------------------
|
3696
|
+
PersonTest: test_son_descendents
|
3697
|
+
--------------------------------
|
3698
|
+
[1m[36mPerson Load (0.2ms)[0m [1mSELECT "people".* FROM "people" WHERE "people"."id" = $1 LIMIT 1[0m [["id", 3]]
|
3699
|
+
[1m[35mPerson Load (0.6ms)[0m SELECT "people".* FROM "people" WHERE (people.id IN ( WITH RECURSIVE search_tree(id, path) AS (
|
3700
|
+
SELECT id, ARRAY[id]
|
3701
|
+
FROM people
|
3702
|
+
WHERE id = 3
|
3703
|
+
UNION ALL
|
3704
|
+
SELECT people.id, path || people.id
|
3705
|
+
FROM search_tree
|
3706
|
+
JOIN people ON people.parent_id = search_tree.id
|
3707
|
+
WHERE NOT people.id = ANY(path)
|
3708
|
+
)
|
3709
|
+
SELECT id FROM search_tree ORDER BY path
|
3710
|
+
))
|
3711
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
3712
|
+
[1m[35m (0.1ms)[0m BEGIN
|
3713
|
+
---------------------------------
|
3714
|
+
PersonTest: test_tree_roots_scope
|
3715
|
+
---------------------------------
|
3716
|
+
[1m[36m (0.4ms)[0m [1mSELECT COUNT(*) FROM "people" WHERE "people"."parent_id" IS NULL[0m
|
3717
|
+
[1m[35m (0.1ms)[0m ROLLBACK
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postgres_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dyson Simmons
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -52,8 +52,8 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
56
|
-
|
55
|
+
description: Access to Rails 4 ActiveRecord models ancestors and descendents in one
|
56
|
+
query.
|
57
57
|
email:
|
58
58
|
- dysonsimmons@gmail.com
|
59
59
|
executables: []
|
@@ -134,7 +134,7 @@ rubyforge_project:
|
|
134
134
|
rubygems_version: 2.2.2
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
|
-
summary: ActiveRecord tree structures using PostgreSQL
|
137
|
+
summary: Rails 4 ActiveRecord tree structures using PostgreSQL
|
138
138
|
test_files:
|
139
139
|
- test/integration/navigation_test.rb
|
140
140
|
- test/test_helper.rb
|