flounder 0.9.12 → 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/HISTORY +2 -1
- data/flounder.gemspec +1 -1
- data/lib/flounder/entity.rb +1 -1
- data/lib/flounder/query/select.rb +30 -0
- data/qed/selects.md +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9298bfc2f968429143600db83b178317276c90ee
|
4
|
+
data.tar.gz: 7f8a6080dc2be42627cbf3b15a2b9af46a93e8b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3446da6ec7625773c5ee45064646ab0d309a430bec819817e37bf9c9776dffcb31095b50e2f358f5af4bb62adb643f828ec7edb9dcc71c7360eb8564df009aa
|
7
|
+
data.tar.gz: 98ca2a21ffd6e01a5b76a0d1d7f9d93562dee7ef8eab859410b4baf95a8ae9925f2073d1ea20c17e4c2595bb937b23f8a24aa180cd1755e3e516c01e46d21db7
|
data/Gemfile.lock
CHANGED
data/HISTORY
CHANGED
@@ -14,4 +14,5 @@
|
|
14
14
|
+ db.where(entity, hash) form, where all symbols are looked up in entity.
|
15
15
|
+ db.entity.join(:other_entity) is now allowed
|
16
16
|
+ :symbol.in => ... is now working.
|
17
|
-
+ JOIN ... AND is now working.
|
17
|
+
+ JOIN ... AND is now working.
|
18
|
+
+ GROUP BY - HAVING should work as expected.
|
data/flounder.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "flounder"
|
5
|
-
s.version = '0.9.
|
5
|
+
s.version = '0.9.13'
|
6
6
|
s.summary = "Flounder is a way to write SQL simply in Ruby. It deals with everything BUT object relational mapping. "
|
7
7
|
s.email = "kaspar.schiess@technologyastronauts.ch"
|
8
8
|
s.homepage = "https://bitbucket.org/technologyastronauts/oss_flounder"
|
data/lib/flounder/entity.rb
CHANGED
@@ -108,7 +108,7 @@ module Flounder
|
|
108
108
|
end
|
109
109
|
|
110
110
|
# Query initiators
|
111
|
-
[:where, :join, :outer_join, :project, :order_by].each do |name|
|
111
|
+
[:where, :join, :outer_join, :project, :order_by, :group_by].each do |name|
|
112
112
|
define_method name do |*args|
|
113
113
|
select { |q| q.send(name, *args) }
|
114
114
|
end
|
@@ -91,6 +91,36 @@ module Flounder::Query
|
|
91
91
|
manager.group *map_to_arel(field_list)
|
92
92
|
self
|
93
93
|
end
|
94
|
+
def having *conditions
|
95
|
+
# TODO mostly duplicates #where!!!
|
96
|
+
conditions = conditions.dup
|
97
|
+
|
98
|
+
resolve_entity = entity
|
99
|
+
|
100
|
+
# is the first argument an entity? if yes, interpret field names relative
|
101
|
+
# to that entity.
|
102
|
+
if conditions.size > 1 && entity_like?(conditions.first)
|
103
|
+
resolve_entity = convert_to_entity(conditions.shift)
|
104
|
+
end
|
105
|
+
|
106
|
+
# is this a hash? extract the first element
|
107
|
+
if conditions.size == 1 && conditions.first.kind_of?(Hash)
|
108
|
+
conditions = conditions.first
|
109
|
+
|
110
|
+
conditions.each do |k, v|
|
111
|
+
manager.having(transform_tuple(resolve_entity, k, v))
|
112
|
+
end
|
113
|
+
return self
|
114
|
+
end
|
115
|
+
|
116
|
+
# maybe conditions is of the second form?
|
117
|
+
conditions.each do |cond_str, *values|
|
118
|
+
manager.where(
|
119
|
+
Arel::Nodes::SqlLiteral.new(
|
120
|
+
rewrite_bind_variables(cond_str, bind_values.size, values.size)))
|
121
|
+
bind_values.concat values
|
122
|
+
end
|
123
|
+
end
|
94
124
|
|
95
125
|
# Orders by a list of field references.
|
96
126
|
#
|
data/qed/selects.md
CHANGED
@@ -64,3 +64,9 @@ Sometimes you have to say it with a subquery. For example, you might want to loo
|
|
64
64
|
row.post.id.assert == 1
|
65
65
|
~~~
|
66
66
|
|
67
|
+
# GROUP BY and HAVING
|
68
|
+
|
69
|
+
~~~ruby
|
70
|
+
posts.group_by(:id).having(id: 0, user_id: 2).
|
71
|
+
assert generates_sql("SELECT [fields] FROM \"posts\" GROUP BY \"posts\".\"id\" HAVING \"posts\".\"id\" = 0 AND \"posts\".\"user_id\" = 2")
|
72
|
+
~~~
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flounder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaspar Schiess
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-08-
|
12
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: arel
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.2.
|
152
|
+
rubygems_version: 2.2.2
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Flounder is a way to write SQL simply in Ruby. It deals with everything BUT
|