flounder 0.9.10 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/flounder.gemspec +1 -1
- data/lib/flounder/domain.rb +3 -0
- data/lib/flounder/query/base.rb +17 -2
- data/lib/flounder/query/select.rb +1 -1
- data/qed/index.md +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb355b42b818e47d6d615cb550779211635fe40c
|
4
|
+
data.tar.gz: c7ecc8ba5b4b1bde6c8ac9213d0733f64fa169be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d33b0970b670b8f53a6785c1b15ad060fe6756f93fc5d63cfbf55cf8e5c32005c3a37eef2a46d5cff82e787e61d0a1c8af825174791bc9f1382fff1f2873e0
|
7
|
+
data.tar.gz: 1e9786ec35fbe6f53300f6f010051a265888d45bf3ed263d9ccf8d9be118253338f4fb787314e880d80f4f1b25f90ca965a38c2795c20f778e525c07f26f205d
|
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.11'
|
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/domain.rb
CHANGED
data/lib/flounder/query/base.rb
CHANGED
@@ -37,8 +37,8 @@ module Flounder::Query
|
|
37
37
|
|
38
38
|
# is the first argument an entity? if yes, interpret field names relative
|
39
39
|
# to that entity.
|
40
|
-
if conditions.size > 1 && conditions.first
|
41
|
-
resolve_entity = conditions.shift
|
40
|
+
if conditions.size > 1 && entity_like?(conditions.first)
|
41
|
+
resolve_entity = convert_to_entity(conditions.shift)
|
42
42
|
end
|
43
43
|
|
44
44
|
# is this a hash? extract the first element
|
@@ -199,5 +199,20 @@ module Flounder::Query
|
|
199
199
|
fail "Could not transform condition part. (#{field.inspect}, #{value.inspect})"
|
200
200
|
end
|
201
201
|
end
|
202
|
+
|
203
|
+
def entity_like? something
|
204
|
+
something.kind_of?(Flounder::Entity) ||
|
205
|
+
something.kind_of?(Symbol) && domain.has_entity?(something)
|
206
|
+
end
|
207
|
+
def convert_to_entity something
|
208
|
+
case something
|
209
|
+
when Flounder::Entity, Flounder::EntityAlias
|
210
|
+
return something
|
211
|
+
when Symbol
|
212
|
+
return domain[something]
|
213
|
+
else
|
214
|
+
fail "Not entity-like - yet! (#{something.inspect})"
|
215
|
+
end
|
216
|
+
end
|
202
217
|
end
|
203
218
|
end
|
data/qed/index.md
CHANGED
@@ -68,6 +68,8 @@ By default, symbols are interpreted as field names in the entity that you start
|
|
68
68
|
~~~ruby
|
69
69
|
users.where(posts, :id => 1).
|
70
70
|
assert generates_sql("SELECT [fields] FROM \"users\" WHERE \"posts\".\"id\" = 1")
|
71
|
+
users.where(:posts, :id => 1).
|
72
|
+
assert generates_sql("SELECT [fields] FROM \"users\" WHERE \"posts\".\"id\" = 1")
|
71
73
|
~~~
|
72
74
|
|
73
75
|
# Some JOINs
|