flounder 0.13.0 → 0.14.0

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: 04d1106f4e95ce3826634ec72900b5ccd131a216
4
- data.tar.gz: 2fab08b9cfbe86039810223e9756eb121a7d7e92
3
+ metadata.gz: 5cc0f113f0d254c49373affa1869e3f8fc03a3fb
4
+ data.tar.gz: 8ff7ed39500492b2f965ff7e1d7c1acc2a7f2473
5
5
  SHA512:
6
- metadata.gz: b172e8b4b323d12ae34950b98fb596c8b624b53aa0e4f9c9799f2b4d6a2aceca1e277f04c064e21e33aecc944e57d0239b7a2dff8b3d1ebab15a331666675c46
7
- data.tar.gz: 03f98c7833cee422c3fe81a2d4dc2b6fa3f59033b99a7cff3387342a24258ce90ee4f85e3574de030f2fb6775f37bc596e1c593abd428eea8532483b9282ea56
6
+ metadata.gz: a0e855f62812d513ae1ca5bfb0d04d0a313c5f9d0f7c42d076de31625a60b344dd32a05e8f9cfb674346e6db7c964ea157c0f2c50f91f5dce333226612191a23
7
+ data.tar.gz: bc99c6125d8e890eb89f1db3ab1ad326e50f0a2d13950a4efed4089f4c209773e3d79dc2513862c33a82788d130c9484c60cc7b7a09832efd55a10a91c55b829
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "flounder"
5
- s.version = '0.13.0'
5
+ s.version = '0.14.0'
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"
@@ -215,7 +215,12 @@ module Flounder::Query
215
215
  value = PgHstore.dump(value, true)
216
216
  end
217
217
 
218
- placeholder = add_binding(value)
218
+ # If this is update by subselect, don't create a binding.
219
+ placeholder = if value.kind_of?(Flounder::Query::Base)
220
+ Flounder.literal("(#{value.manager.to_sql})")
221
+ else
222
+ add_binding(value)
223
+ end
219
224
 
220
225
  case field
221
226
  when Symbol, String
@@ -65,3 +65,11 @@ Updating multiple rows is possible.
65
65
 
66
66
  updated.map(&:name).assert == ['Update Multiple Rows']*7
67
67
  ~~~
68
+
69
+ Also, updating by using a subquery is possible.
70
+
71
+ ~~~ruby
72
+ first_author = users.project(:id).limit(1)
73
+ users.update(approver_id: first_author).where(:approver_id => nil).
74
+ assert generates_sql("UPDATE \"users\" SET \"approver_id\" = (SELECT \"users\".\"id\" FROM \"users\" LIMIT 1) WHERE \"users\".\"approver_id\" IS NULL RETURNING *")
75
+ ~~~
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.13.0
4
+ version: 0.14.0
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-09-26 00:00:00.000000000 Z
12
+ date: 2014-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arel