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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3055b086d4ebfe48d6a8e0fc1f8b714dc156eea
4
- data.tar.gz: 33502d671dae3850251f913ba2eb2a1a1d8e5741
3
+ metadata.gz: eb355b42b818e47d6d615cb550779211635fe40c
4
+ data.tar.gz: c7ecc8ba5b4b1bde6c8ac9213d0733f64fa169be
5
5
  SHA512:
6
- metadata.gz: da8812d564ca9a540992684eb613ac6a46eeaf513cf38d04f76049afad332856f02529626b4f2fc4133b4b1aa353e5898f75abddd798b53bf5300bee2f7d0229
7
- data.tar.gz: 7671211165f8c2671ff42c653b166606db434cd49a5392ba600b3e42977d160fa0c3a588870955af333d5928aae8623b2619c59d21abf7574afa88789c832c9f
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.10'
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"
@@ -62,6 +62,9 @@ module Flounder
62
62
  def entities
63
63
  @plural.values
64
64
  end
65
+ def has_entity? name
66
+ @plural.has_key? name
67
+ end
65
68
 
66
69
  # Logs sql statements that are prepared for execution.
67
70
  #
@@ -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.kind_of?(Flounder::Entity)
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
@@ -31,7 +31,7 @@ module Flounder::Query
31
31
  attr_reader :projection_prefixes
32
32
 
33
33
  def _join join_node, entity
34
- entity = domain[entity] if entity.kind_of?(Symbol)
34
+ entity = convert_to_entity(entity)
35
35
 
36
36
  @last_join = entity
37
37
 
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
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.10
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaspar Schiess