flounder 0.6.1 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c24fd44d83971c04ab5af008256caa682550c92a
4
- data.tar.gz: d75714297696317a7156d0f6f6ca74c6b5541ef8
3
+ metadata.gz: a3cf7329905c8c1b1379adeb8474f9ec7f594b77
4
+ data.tar.gz: 9806546b6fbb16077607e0b60930a051fbab9d1f
5
5
  SHA512:
6
- metadata.gz: 2b45f93c33f514e6bdf2bc6fe1725cac663041814b6ed25fd3b82a749936fd9ec7ad737d41f2a0f26111fda23b0a9fb243ca1ebc8a81e8ac587dd95924d261e8
7
- data.tar.gz: 5986acd3c19b5f836f02ac790e48a6ab1ee805b69a567a5c686f08a67b85b9cd89cec6afce452f005a797cf8165bc92c2f71a58ecc69e1261481161aacd6286f
6
+ metadata.gz: c74c0f97d0a716d094d0af54a3292ba5060c051e913a2b46046942ec92291005474abad4dbe3c692f1391bc3d323d7cd16d514fe92be18d2488f4b4491050156
7
+ data.tar.gz: b026b324cc4589a2da8c3ae677dbcbd65ad334637ce97b4ad8af5233180e67265bf396199771f625cad198114ad9c2f7c6974a4cfe98029a38045cd4718ab645
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.6.1'
5
+ s.version = '0.7.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/laboratory_flounder"
@@ -66,7 +66,7 @@ module Flounder
66
66
  def insdate fields, hash, &inserted
67
67
  found = where(hash.select { |k, _| fields.include?(k) }).first
68
68
  if found
69
- update(hash).where(:id => hash.delete(:id))
69
+ update(hash).where(:id => found.id)
70
70
  else
71
71
  insert(hash, &inserted)
72
72
  end
@@ -99,7 +99,7 @@ module Flounder
99
99
  end
100
100
 
101
101
  # Kickers
102
- [:first, :all, :size].each do |name|
102
+ [:first, :all, :size, :delete].each do |name|
103
103
  define_method name do |*args|
104
104
  q = query
105
105
  q.send(name, *args)
@@ -140,6 +140,18 @@ module Flounder
140
140
 
141
141
  all.first.count
142
142
  end
143
+ def delete
144
+ # things.where(...).delete.all
145
+ #
146
+ # Code that I actually want:
147
+ #
148
+ # @manager = manager.compile_delete
149
+ # self
150
+ #
151
+ # But for now it's a kicker:
152
+ #
153
+ engine.exec(manager.compile_delete.to_sql)
154
+ end
143
155
 
144
156
  # Returns all rows of the query result as an array. Individual rows are
145
157
  # mapped to objects using the row mapper.
data/qed/insdate.md CHANGED
@@ -1,23 +1,25 @@
1
1
  Flounder offers Insdate.
2
2
 
3
3
  ~~~ruby
4
- user = users.first
4
+ post = posts.first
5
5
 
6
- # Update if found.
7
- #
8
- results = users.insdate([:id], :id => user.id, :name => 'Mr. Insdate Update') do |u|
9
- assert false # Not called.
10
- end.returning
11
- results.first.name.assert == 'Mr. Insdate Update'
12
-
13
6
  # Insert if not found.
14
7
  #
15
- results = users.insdate([:name], :name => 'Mr. Insdate Insert') do |u|
8
+ post = posts.insdate([:title], :title => 'Insdate Insert', :text => '', :user_id => users.first.id) do |u|
16
9
  u.assert # Is called.
17
- end.returning
18
- results.first.name.assert == 'Mr. Insdate Insert'
10
+ end.returning.first
11
+ post.title.assert == 'Insdate Insert'
12
+ post.text.assert == ''
13
+
14
+ # Update if found with the fields.
15
+ #
16
+ post = posts.insdate([:title], :title => 'Insdate Insert', :text => 'Insdate Update Text') do |u|
17
+ assert false # Not called.
18
+ end.returning.first
19
+ post.title.assert == 'Insdate Insert'
20
+ post.text.assert == 'Insdate Update Text'
19
21
 
20
- # Reset QED.
22
+ # Reset this particular QED.
21
23
  #
22
- users.update(:name => 'John Snow').where(:id => user.id).returning('*')
24
+ posts.where(:id => post.id).delete.first
23
25
  ~~~
data/qed/selects.md CHANGED
@@ -27,7 +27,7 @@ If we want to see all records, we use the `all` kicker, which has some synonyms.
27
27
 
28
28
  ~~~ruby
29
29
  users = domain[:users].all
30
- users.size.assert == 7
30
+ users.size.assert == 6
31
31
  users.assert.kind_of? Array
32
32
 
33
33
  domain[:users].map(&:id).assert == users.map(&:id)
data/qed/updates.md CHANGED
@@ -64,5 +64,5 @@ Updating multiple rows is possible.
64
64
  ~~~ruby
65
65
  updated = users.update(:name => 'Update Multiple Rows').where(:name.not_eq => nil).returning
66
66
 
67
- updated.map(&:name).assert == ['Update Multiple Rows']*7
67
+ updated.map(&:name).assert == ['Update Multiple Rows']*6
68
68
  ~~~
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.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaspar Schiess