squeel 1.2.1 → 1.2.2
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 +4 -4
- data/CHANGELOG.md +14 -1
- data/Gemfile +6 -0
- data/README.md +37 -20
- data/lib/squeel/adapters/active_record/3.0/relation_extensions.rb +4 -0
- data/lib/squeel/adapters/active_record/3.1/relation_extensions.rb +4 -0
- data/lib/squeel/adapters/active_record/4.0/relation_extensions.rb +5 -3
- data/lib/squeel/adapters/active_record/4.1/preloader_extensions.rb +1 -1
- data/lib/squeel/adapters/active_record/4.1/relation_extensions.rb +1 -1
- data/lib/squeel/adapters/active_record/relation_extensions.rb +7 -3
- data/lib/squeel/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/squeel/adapters/active_record/relation_extensions_spec.rb +114 -7
- data/spec/support/models.rb +20 -1
- data/spec/support/schema.rb +5 -0
- data/squeel.gemspec +4 -2
- metadata +68 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bd3775d68a256e08489cd4c9e80f050c9048e46
|
4
|
+
data.tar.gz: d0c2141316dff16b8a0235f6ab1c8dae5224b139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca682a51846f17fb4f74dd5f23a10e022841b6ac91d62f744f6378a64c59fce21519b0cabf55f9dccb0a58f0b25a74592a74073d8ac67a59eb14aad7ea30cd0a
|
7
|
+
data.tar.gz: 26ef0beb4f3b04d40b852cd20ed085279186aadb83718e6ebcda1e0a1b62ea5dfd63bd4f3af7f9f1365e5505893db717757409419f0fa0323bb714512c8f16a5
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,17 @@
|
|
1
|
-
## 1.2.
|
1
|
+
## 1.2.3 (Unreleased)
|
2
|
+
|
3
|
+
## 1.2.2 (2014-11-25)
|
4
|
+
|
5
|
+
* Size method can return the result correctly when grouping by the column of a
|
6
|
+
joined table. Fixes #286
|
7
|
+
* Properly add 'AND' to generated SQL when joining through a polymorphic model
|
8
|
+
with the source type configuration and default scopes above Rails 4. Fixes #270.
|
9
|
+
* Fix NoMethodError when calling unscope method above Rails 4. By @estum
|
10
|
+
* Fix error when including HABTM or HMT associations without eager loading.
|
11
|
+
Fixes #326.
|
12
|
+
* Ordering sequence is now correct when chaining multiple order methods. Fixes #276.
|
13
|
+
|
14
|
+
## 1.2.1 (2014-07-18)
|
2
15
|
|
3
16
|
* Run all specs against sqlite, mysql and postgresql!
|
4
17
|
* Genereta table names correctly when joining through an association. Fixes#302.
|
data/Gemfile
CHANGED
@@ -6,6 +6,10 @@ gem 'rake'
|
|
6
6
|
rails = ENV['RAILS'] || 'master'
|
7
7
|
arel = ENV['AREL'] || 'master'
|
8
8
|
|
9
|
+
if rails == 'master'
|
10
|
+
gem 'i18n', github: 'svenfuchs/i18n', branch: 'master'
|
11
|
+
end
|
12
|
+
|
9
13
|
arel_opts = case arel
|
10
14
|
when /\// # A path
|
11
15
|
{:path => arel}
|
@@ -35,3 +39,5 @@ else
|
|
35
39
|
gem 'activerecord'
|
36
40
|
end
|
37
41
|
end
|
42
|
+
|
43
|
+
|
data/README.md
CHANGED
@@ -23,8 +23,6 @@ just a simple example -- Squeel's capable of a whole lot more. Keep reading.
|
|
23
23
|
In your Gemfile:
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
# Make sure you are using the latest version of polyamorous
|
27
|
-
gem "polyamorous", :git => "git://github.com/activerecord-hackery/polyamorous.git"
|
28
26
|
gem "squeel" # Last officially released gem
|
29
27
|
# gem "squeel", :git => "git://github.com/activerecord-hackery/squeel.git" # Track git repo
|
30
28
|
```
|
@@ -88,24 +86,6 @@ A Squeel keypath is essentially a more concise and readable alternative to a
|
|
88
86
|
deeply nested hash. For instance, in standard Active Record, you might join several
|
89
87
|
associations like this to perform a query:
|
90
88
|
|
91
|
-
#### Rails 4+
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
Person.joins(:articles => {:comments => :person}).references(:all)
|
95
|
-
# => SELECT "people".* FROM "people"
|
96
|
-
# LEFT OUTER JOIN "articles" ON "articles"."person_id" = "people"."id"
|
97
|
-
# LEFT OUTER JOIN "comments" ON "comments"."article_id" = "articles"."id"
|
98
|
-
# LEFT OUTER JOIN "people" "people_comments" ON "people_comments"."id" = "comments"."person_id"
|
99
|
-
```
|
100
|
-
|
101
|
-
With a keypath, this would look like:
|
102
|
-
|
103
|
-
```ruby
|
104
|
-
Person.joins{articles.comments.person}.references(:all)
|
105
|
-
```
|
106
|
-
|
107
|
-
#### Rails 3.x
|
108
|
-
|
109
89
|
```ruby
|
110
90
|
Person.joins(:articles => {:comments => :person})
|
111
91
|
# => SELECT "people".* FROM "people"
|
@@ -454,6 +434,43 @@ Seat.joins { [payment.outer, subquery.as('seat_order_items').on { id == seat_ord
|
|
454
434
|
# ) seat_order_items ON "seats"."id" = "seat_order_items"."orderable_id"
|
455
435
|
```
|
456
436
|
|
437
|
+
### Includes
|
438
|
+
|
439
|
+
Includes works similarly with joins, it uses outer join defaultly. In Rails 4,
|
440
|
+
you need to use `references` with `includes` together.
|
441
|
+
|
442
|
+
#### Rails 4+
|
443
|
+
|
444
|
+
```ruby
|
445
|
+
Person.includes(:articles => {:comments => :person}).references(:all)
|
446
|
+
# => SELECT "people".* FROM "people"
|
447
|
+
# LEFT OUTER JOIN "articles" ON "articles"."person_id" = "people"."id"
|
448
|
+
# LEFT OUTER JOIN "comments" ON "comments"."article_id" = "articles"."id"
|
449
|
+
# LEFT OUTER JOIN "people" "people_comments" ON "people_comments"."id" = "comments"."person_id"
|
450
|
+
```
|
451
|
+
|
452
|
+
With a keypath, this would look like:
|
453
|
+
|
454
|
+
```ruby
|
455
|
+
Person.includes{articles.comments.person}.references(:all)
|
456
|
+
```
|
457
|
+
|
458
|
+
#### Rails 3.x
|
459
|
+
|
460
|
+
```ruby
|
461
|
+
Person.includes(:articles => {:comments => :person})
|
462
|
+
# => SELECT "people".* FROM "people"
|
463
|
+
# LEFT OUTER JOIN "articles" ON "articles"."person_id" = "people"."id"
|
464
|
+
# LEFT OUTER JOIN "comments" ON "comments"."article_id" = "articles"."id"
|
465
|
+
# LEFT OUTER JOIN "people" "people_comments" ON "people_comments"."id" = "comments"."person_id"
|
466
|
+
```
|
467
|
+
|
468
|
+
With a keypath, this would look like:
|
469
|
+
|
470
|
+
```ruby
|
471
|
+
Person.includes{articles.comments.person}
|
472
|
+
```
|
473
|
+
|
457
474
|
### Functions
|
458
475
|
|
459
476
|
You can call SQL functions just like you would call a method in Ruby...
|
@@ -41,7 +41,7 @@ module Squeel
|
|
41
41
|
when Hash
|
42
42
|
rel.stringify_keys.has_key?(target_value)
|
43
43
|
when Squeel::Nodes::Predicate
|
44
|
-
rel.expr.symbol.to_s == target_value
|
44
|
+
rel.expr.symbol.to_s == target_value if rel.expr.respond_to?(:symbol)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -160,10 +160,12 @@ module Squeel
|
|
160
160
|
|
161
161
|
# if a symbol is given we prepend the quoted table name
|
162
162
|
args = args.map { |arg|
|
163
|
-
arg.is_a?(Symbol) ?
|
163
|
+
arg.is_a?(Symbol) ?
|
164
|
+
Arel::Nodes::Ascending.new(klass.arel_table[arg]) :
|
165
|
+
arg
|
164
166
|
}
|
165
167
|
|
166
|
-
self.order_values
|
168
|
+
self.order_values += args
|
167
169
|
self
|
168
170
|
end
|
169
171
|
|
@@ -17,7 +17,7 @@ module Squeel
|
|
17
17
|
if records.empty?
|
18
18
|
[]
|
19
19
|
else
|
20
|
-
Visitors::PreloadVisitor.new.accept(associations).
|
20
|
+
Visitors::PreloadVisitor.new.accept(associations).flat_map do |association|
|
21
21
|
preloaders_on(association, records, preload_scope)
|
22
22
|
end
|
23
23
|
end
|
@@ -272,9 +272,7 @@ module Squeel
|
|
272
272
|
|
273
273
|
groups = binaries.group_by {|b| [b.class, b.left]}
|
274
274
|
|
275
|
-
groups.
|
276
|
-
arel.where(Arel::Nodes::And.new(bins))
|
277
|
-
end
|
275
|
+
arel.where(Arel::Nodes::And.new(groups.map{|_, bins| bins}.flatten)) if groups.any?
|
278
276
|
|
279
277
|
(wheres - binaries).each do |where|
|
280
278
|
where = Arel.sql(where) if String === where
|
@@ -436,6 +434,12 @@ module Squeel
|
|
436
434
|
end
|
437
435
|
end
|
438
436
|
|
437
|
+
def execute_grouped_calculation(operation, column_name, distinct)
|
438
|
+
arel = Arel::SelectManager.new(table.engine, table)
|
439
|
+
build_join_dependency(arel, joins_values.flatten) unless joins_values.empty?
|
440
|
+
self.group_values = group_visit(group_values.uniq.reject{|g| g.blank?}) unless group_values.empty?
|
441
|
+
super
|
442
|
+
end
|
439
443
|
end
|
440
444
|
end
|
441
445
|
end
|
data/lib/squeel/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -339,6 +339,10 @@ module Squeel
|
|
339
339
|
relation.debug_sql.should match /SELECT #{Q}notes#{Q}.* FROM #{Q}notes#{Q} LEFT OUTER JOIN #{Q}articles#{Q} ON #{Q}articles#{Q}.#{Q}id#{Q} = #{Q}notes#{Q}.#{Q}notable_id#{Q} AND #{Q}notes#{Q}.#{Q}notable_type#{Q} = 'Article' LEFT OUTER JOIN #{Q}people#{Q} ON #{Q}people#{Q}.#{Q}id#{Q} = #{Q}articles#{Q}.#{Q}person_id#{Q} LEFT OUTER JOIN #{Q}people#{Q} #{Q}children_people#{Q} ON #{Q}children_people#{Q}.#{Q}parent_id#{Q} = #{Q}people#{Q}.#{Q}id#{Q} WHERE #{Q}children_people#{Q}.#{Q}name#{Q} = 'Ernie'/
|
340
340
|
end
|
341
341
|
|
342
|
+
it 'eager loads has_and_belongs_to_many' do
|
343
|
+
expect { Article.includes{tags}.to_a }.should_not raise_error
|
344
|
+
expect { Person.includes{authored_article_comments}.to_a }.should_not raise_error
|
345
|
+
end
|
342
346
|
end
|
343
347
|
|
344
348
|
describe '#preload' do
|
@@ -523,6 +527,27 @@ module Squeel
|
|
523
527
|
block.to_sql.should eq standard.to_sql
|
524
528
|
end
|
525
529
|
|
530
|
+
it 'returns size correctly using group' do
|
531
|
+
if activerecord_version_at_least('3.2.0')
|
532
|
+
relation = Article.joins{person}.group{person.id}
|
533
|
+
relation.size.should have(10).items
|
534
|
+
relation.size[Person.first.id].should == 3
|
535
|
+
end
|
536
|
+
|
537
|
+
relation = Article.joins{person}.group{"people.id"}
|
538
|
+
relation.size.should have(10).items
|
539
|
+
relation.size[Person.first.id].should == 3
|
540
|
+
|
541
|
+
relation = Article.joins{person}.group("people.id")
|
542
|
+
relation.size.should have(10).items
|
543
|
+
relation.size[Person.first.id].should == 3
|
544
|
+
|
545
|
+
relation = Article.group{person_id}
|
546
|
+
relation.size.should have(11).items
|
547
|
+
relation.size[Person.first.id].should == 3
|
548
|
+
|
549
|
+
end
|
550
|
+
|
526
551
|
end
|
527
552
|
|
528
553
|
describe '#where' do
|
@@ -661,12 +686,44 @@ module Squeel
|
|
661
686
|
|
662
687
|
it 'uses Squeel and Arel at the same time' do
|
663
688
|
relation = User.where{id.in([1,2,3]) & User.arel_table[:id].not_eq(nil) }
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
689
|
+
|
690
|
+
if activerecord_version_at_least '4.2.0'
|
691
|
+
relation.to_sql.should eq "
|
692
|
+
SELECT #{Q}users#{Q}.* FROM #{Q}users#{Q}
|
693
|
+
WHERE (#{Q}users#{Q}.#{Q}id#{Q} IN (1, 2, 3)
|
694
|
+
AND #{Q}users#{Q}.#{Q}id#{Q} IS NOT NULL)
|
695
|
+
".squish
|
696
|
+
else
|
697
|
+
relation.to_sql.should match /SELECT #{Q}users#{Q}.\* FROM #{Q}users#{Q}\s+WHERE \(\(#{Q}users#{Q}.#{Q}id#{Q} IN \(1, 2, 3\) AND #{Q}users#{Q}.#{Q}id#{Q} IS NOT NULL\)\)/
|
698
|
+
end
|
699
|
+
|
700
|
+
relation = User.where {
|
701
|
+
(id.in([1,2,3]) | User.arel_table[:id].eq(1)) &
|
702
|
+
((id == 1) | User.arel_table[:id].not_eq(nil)) }
|
703
|
+
|
704
|
+
if activerecord_version_at_least '4.2.0'
|
705
|
+
relation.to_sql.should eq "
|
706
|
+
SELECT #{Q}users#{Q}.*
|
707
|
+
FROM #{Q}users#{Q}
|
708
|
+
WHERE ((#{Q}users#{Q}.#{Q}id#{Q} IN (1, 2, 3) OR #{Q}users#{Q}.#{Q}id#{Q} = 1)
|
709
|
+
AND (#{Q}users#{Q}.#{Q}id#{Q} = 1 OR #{Q}users#{Q}.#{Q}id#{Q} IS NOT NULL))
|
710
|
+
".squish
|
711
|
+
else
|
712
|
+
relation.to_sql.should match /SELECT #{Q}users#{Q}.\* FROM #{Q}users#{Q}\s+WHERE \(\(\(#{Q}users#{Q}.#{Q}id#{Q} IN \(1, 2, 3\) OR #{Q}users#{Q}.#{Q}id#{Q} = 1\) AND \(#{Q}users#{Q}.#{Q}id#{Q} = 1 OR #{Q}users#{Q}.#{Q}id#{Q} IS NOT NULL\)\)\)/
|
713
|
+
end
|
668
714
|
end
|
669
715
|
|
716
|
+
it "large than & less than" do
|
717
|
+
if activerecord_version_at_least '4.1.0'
|
718
|
+
relation = User.where { created_at <= 1.hours.ago }
|
719
|
+
expect { relation.to_sql }.not_to raise_error
|
720
|
+
|
721
|
+
relation = User.where { created_at < 1.hours.ago }
|
722
|
+
expect { relation.to_sql }.not_to raise_error
|
723
|
+
else
|
724
|
+
pending 'Unsupported under Rails 4.1'
|
725
|
+
end
|
726
|
+
end
|
670
727
|
end
|
671
728
|
|
672
729
|
describe '#joins' do
|
@@ -718,7 +775,19 @@ module Squeel
|
|
718
775
|
end
|
719
776
|
|
720
777
|
it 'validates polymorphic relationship with source type' do
|
721
|
-
if activerecord_version_at_least
|
778
|
+
if activerecord_version_at_least('4.0.0')
|
779
|
+
relation = Group.joins{users}
|
780
|
+
|
781
|
+
if MYSQL_ENV
|
782
|
+
relation.to_sql.should match /#{Q}memberships#{Q}.#{Q}active#{Q} = 1/
|
783
|
+
else
|
784
|
+
relation.to_sql.should match /#{Q}memberships#{Q}.#{Q}active#{Q} = 't'/
|
785
|
+
end
|
786
|
+
|
787
|
+
relation.to_sql.should match /#{Q}memberships#{Q}.#{Q}member_type#{Q} = 'User'/
|
788
|
+
relation.to_sql.should match /INNER JOIN #{Q}users#{Q} ON #{Q}users#{Q}.#{Q}id#{Q} = #{Q}memberships#{Q}.#{Q}member_id#{Q}/
|
789
|
+
relation.to_sql.should match /INNER JOIN #{Q}memberships#{Q} ON #{Q}memberships#{Q}.#{Q}group_id#{Q} = #{Q}groups#{Q}.#{Q}id#{Q}/
|
790
|
+
elsif activerecord_version_at_least('3.2.7')
|
722
791
|
Group.first.users.to_sql.should match /#{Q}memberships#{Q}.#{Q}member_type#{Q} = 'User'/
|
723
792
|
else
|
724
793
|
Group.first.users.size.should eq 1
|
@@ -746,14 +815,29 @@ module Squeel
|
|
746
815
|
if MYSQL_ENV
|
747
816
|
User.first.groups.to_sql.should match /#{Q}memberships#{Q}.#{Q}active#{Q} = 1/
|
748
817
|
else
|
749
|
-
puts User.first.groups.to_sql
|
750
818
|
User.first.groups.to_sql.should match /#{Q}memberships#{Q}.#{Q}active#{Q} = 't'/
|
751
819
|
end
|
752
|
-
|
753
820
|
else
|
754
821
|
pending "Rails 3.0.x doesn't support to_sql in an association."
|
755
822
|
end
|
756
823
|
end
|
824
|
+
|
825
|
+
it 'default scopes with multiple wheres' do
|
826
|
+
if activerecord_version_at_least('4.0.0')
|
827
|
+
relation = Dept.joins { people_named_bill_with_low_salary }
|
828
|
+
|
829
|
+
relation.to_sql.should eq "
|
830
|
+
SELECT #{Q}depts#{Q}.*
|
831
|
+
FROM #{Q}depts#{Q}
|
832
|
+
INNER JOIN #{Q}people#{Q} ON
|
833
|
+
#{Q}people#{Q}.#{Q}dept_id#{Q} = #{Q}depts#{Q}.#{Q}id#{Q} AND
|
834
|
+
#{Q}people#{Q}.#{Q}name#{Q} = 'Bill' AND
|
835
|
+
#{Q}people#{Q}.#{Q}salary#{Q} < 20000
|
836
|
+
".squish
|
837
|
+
else
|
838
|
+
pending "Rails 3.x doesn't support default scope in joins"
|
839
|
+
end
|
840
|
+
end
|
757
841
|
end
|
758
842
|
|
759
843
|
describe '#having' do
|
@@ -806,6 +890,11 @@ module Squeel
|
|
806
890
|
relation.to_sql.should match /ORDER BY #{Q}people#{Q}.#{Q}id#{Q} ASC/
|
807
891
|
end
|
808
892
|
|
893
|
+
it 'orders chain in correct sequence' do
|
894
|
+
relation = Article.order {id.asc}.order {title.desc}
|
895
|
+
relation.to_sql.should match /#{Q}articles#{Q}.#{Q}id#{Q} ASC, #{Q}articles#{Q}.#{Q}title#{Q} DESC/
|
896
|
+
end
|
897
|
+
|
809
898
|
end
|
810
899
|
|
811
900
|
describe '#reorder' do
|
@@ -966,6 +1055,24 @@ module Squeel
|
|
966
1055
|
|
967
1056
|
end
|
968
1057
|
|
1058
|
+
describe '#where_unscoping' do
|
1059
|
+
|
1060
|
+
it "doesn't ruin everything when predicate expression in where_values doesn't respond to :symbol method" do
|
1061
|
+
unless activerecord_version_at_least '4.2.0'
|
1062
|
+
if activerecord_version_at_least '4.0.0'
|
1063
|
+
order_items = OrderItem.where{quantity == 0}.where{unit_price / 2 == 5}
|
1064
|
+
expect { order_items.unscope(where: :quantity) }.should_not raise_error
|
1065
|
+
order_items.to_sql.should_not match /#{Q}order_items#{Q}.#{Q}quantity#{Q} = 0/
|
1066
|
+
else
|
1067
|
+
pending 'Unsupported on AR versions < 4.0.0'
|
1068
|
+
end
|
1069
|
+
else
|
1070
|
+
pending 'Not required in AR versions > 4.2.0'
|
1071
|
+
end
|
1072
|
+
end
|
1073
|
+
|
1074
|
+
end
|
1075
|
+
|
969
1076
|
describe '#as' do
|
970
1077
|
|
971
1078
|
it 'aliases the relation in an As node' do
|
data/spec/support/models.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
class Person < ActiveRecord::Base
|
2
|
+
belongs_to :dept
|
2
3
|
belongs_to :parent, :class_name => 'Person', :foreign_key => :parent_id
|
3
4
|
has_many :children, :class_name => 'Person', :foreign_key => :parent_id
|
4
5
|
has_many :articles
|
@@ -58,6 +59,19 @@ class PersonNamedBill < ActiveRecord::Base
|
|
58
59
|
scope :with_salary_equal_to, lambda { |value| where{abs(salary) == value} }
|
59
60
|
end
|
60
61
|
|
62
|
+
class Dept < ActiveRecord::Base
|
63
|
+
has_many :people_named_bill_with_low_salary,
|
64
|
+
class_name: 'PersonNamedBillAndLowSalary', foreign_key: 'dept_id'
|
65
|
+
end
|
66
|
+
|
67
|
+
class PersonNamedBillAndLowSalary < Person
|
68
|
+
if ActiveRecord::VERSION::MAJOR > 3 || ActiveRecord::VERSION::MINOR > 0
|
69
|
+
default_scope { where { name == 'Bill' }.where { salary < 20000 } }
|
70
|
+
else # 3.0 doesn't support callables for default_scope
|
71
|
+
default_scope where { name == 'Bill' }.where { salary < 20000 }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
61
75
|
class Message < ActiveRecord::Base
|
62
76
|
belongs_to :author, :class_name => 'Person'
|
63
77
|
belongs_to :recipient, :class_name => 'Person'
|
@@ -145,9 +159,14 @@ end
|
|
145
159
|
|
146
160
|
class Models
|
147
161
|
def self.make
|
162
|
+
dept = Dept.create(name: Faker::Lorem.name)
|
163
|
+
|
148
164
|
10.times do |i|
|
149
165
|
# 10 people total, salary gt 30000
|
150
|
-
person = Person.create(name: Faker::Name.name,
|
166
|
+
person = Person.create(name: Faker::Name.name,
|
167
|
+
salary: 30000 + (i + 1) * 1000,
|
168
|
+
dept: dept)
|
169
|
+
|
151
170
|
2.times do
|
152
171
|
# 20 unidentified object total, 2 per person
|
153
172
|
person.unidentified_objects.create(name: Faker::Lorem.words(1).first)
|
data/spec/support/schema.rb
CHANGED
@@ -79,10 +79,15 @@ silence_stream(STDOUT) do
|
|
79
79
|
ActiveRecord::Migration.verbose = false
|
80
80
|
|
81
81
|
ActiveRecord::Schema.define do
|
82
|
+
create_table :depts, :force => true do |t|
|
83
|
+
t.string :name
|
84
|
+
end
|
85
|
+
|
82
86
|
create_table :people, :force => true do |t|
|
83
87
|
t.integer :parent_id
|
84
88
|
t.string :name
|
85
89
|
t.integer :salary
|
90
|
+
t.integer :dept_id
|
86
91
|
end
|
87
92
|
|
88
93
|
create_table :messages, :force => true do |t|
|
data/squeel.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "squeel"
|
7
7
|
s.version = Squeel::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["Ernie Miller"]
|
10
|
-
s.email = ["ernie@erniemiller.org"]
|
9
|
+
s.authors = ["Ernie Miller", "Xiang Li"]
|
10
|
+
s.email = ["ernie@erniemiller.org", "bigxiang@gmail.com"]
|
11
11
|
s.homepage = "https://github.com/ernie/squeel"
|
12
12
|
s.summary = %q{Active Record, improved.}
|
13
13
|
s.description = %q{
|
@@ -27,6 +27,8 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_development_dependency 'mysql', '~> 2.9.1'
|
28
28
|
s.add_development_dependency 'mysql2', '~> 0.3.16'
|
29
29
|
s.add_development_dependency 'pg', '~> 0.17.1'
|
30
|
+
s.add_development_dependency 'git_pretty_accept', '~> 0.4.0'
|
31
|
+
s.add_development_dependency 'pry'
|
30
32
|
|
31
33
|
s.files = `git ls-files`.split("\n")
|
32
34
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squeel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernie Miller
|
8
|
+
- Xiang Li
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activerecord
|
@@ -136,12 +137,41 @@ dependencies:
|
|
136
137
|
- - "~>"
|
137
138
|
- !ruby/object:Gem::Version
|
138
139
|
version: 0.17.1
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: git_pretty_accept
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 0.4.0
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 0.4.0
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: pry
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
139
168
|
description: "\n Squeel unlocks the power of Arel in your Rails application with\n
|
140
169
|
\ a handy block-based syntax. You can write subqueries, access named\n functions
|
141
170
|
provided by your RDBMS, and more, all without writing\n SQL strings. Supporting
|
142
171
|
Rails 3 and 4.\n "
|
143
172
|
email:
|
144
173
|
- ernie@erniemiller.org
|
174
|
+
- bigxiang@gmail.com
|
145
175
|
executables: []
|
146
176
|
extensions: []
|
147
177
|
extra_rdoc_files: []
|
@@ -292,8 +322,42 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
292
322
|
version: '0'
|
293
323
|
requirements: []
|
294
324
|
rubyforge_project: squeel
|
295
|
-
rubygems_version: 2.
|
325
|
+
rubygems_version: 2.4.3
|
296
326
|
signing_key:
|
297
327
|
specification_version: 4
|
298
328
|
summary: Active Record, improved.
|
299
|
-
test_files:
|
329
|
+
test_files:
|
330
|
+
- spec/config.travis.yml
|
331
|
+
- spec/config.yml
|
332
|
+
- spec/console.rb
|
333
|
+
- spec/core_ext/symbol_spec.rb
|
334
|
+
- spec/helpers/squeel_helper.rb
|
335
|
+
- spec/spec_helper.rb
|
336
|
+
- spec/squeel/adapters/active_record/base_extensions_spec.rb
|
337
|
+
- spec/squeel/adapters/active_record/context_spec.rb
|
338
|
+
- spec/squeel/adapters/active_record/join_dependency_extensions_spec.rb
|
339
|
+
- spec/squeel/adapters/active_record/relation_extensions_spec.rb
|
340
|
+
- spec/squeel/core_ext/symbol_spec.rb
|
341
|
+
- spec/squeel/dsl_spec.rb
|
342
|
+
- spec/squeel/nodes/as_spec.rb
|
343
|
+
- spec/squeel/nodes/function_spec.rb
|
344
|
+
- spec/squeel/nodes/grouping_spec.rb
|
345
|
+
- spec/squeel/nodes/join_spec.rb
|
346
|
+
- spec/squeel/nodes/key_path_spec.rb
|
347
|
+
- spec/squeel/nodes/literal_spec.rb
|
348
|
+
- spec/squeel/nodes/operation_spec.rb
|
349
|
+
- spec/squeel/nodes/operators_spec.rb
|
350
|
+
- spec/squeel/nodes/order_spec.rb
|
351
|
+
- spec/squeel/nodes/predicate_operators_spec.rb
|
352
|
+
- spec/squeel/nodes/predicate_spec.rb
|
353
|
+
- spec/squeel/nodes/sifter_spec.rb
|
354
|
+
- spec/squeel/nodes/stub_spec.rb
|
355
|
+
- spec/squeel/nodes/subquery_join_spec.rb
|
356
|
+
- spec/squeel/visitors/from_visitor_spec.rb
|
357
|
+
- spec/squeel/visitors/order_visitor_spec.rb
|
358
|
+
- spec/squeel/visitors/predicate_visitor_spec.rb
|
359
|
+
- spec/squeel/visitors/preload_visitor_spec.rb
|
360
|
+
- spec/squeel/visitors/select_visitor_spec.rb
|
361
|
+
- spec/squeel/visitors/visitor_spec.rb
|
362
|
+
- spec/support/models.rb
|
363
|
+
- spec/support/schema.rb
|