flounder 0.9.0 → 0.9.1

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: 97e8380edd41a2232f500fc61ceb3f49e2dd3211
4
- data.tar.gz: e0330758a5aac5eba5d509cdffa778f0dca41735
3
+ metadata.gz: b7f0215b9a32d26575d6a27982baf1e3557df937
4
+ data.tar.gz: b0b7cb0356ea83e8af672a0f91b025f567891d03
5
5
  SHA512:
6
- metadata.gz: c17571110ffbe588b794f026e5eddfc244bd479c37d1a09e4f01639caa4e6031bbb82a1ff5512a616fc4c0069cab4c0165eeddcd5a39535275376c8e8dcf5509
7
- data.tar.gz: 76e6e016a4ac6bcaa9f2c8679909a63cd1564efeed5b5ce970d6a41e845cdc77d43c09cc188e0fbd3e367bff6725c382fae2fa223b07b15ce25c15947766417e
6
+ metadata.gz: ff873c40c360913978fd6d9138b704e8362c26e577a15f042c062f2be74731e63ab0d06ec49931892b1a98f729eab67823b8e23da8cf2fd41f09841ccaa9fa01
7
+ data.tar.gz: 4ab1e4048e43d99ce94ea224e026e4e6bd9b36ca591d600df5777f9bcf4666ddcc47eaa93afcb44fc5a74751e98790ec1be3f68e440dc3c43ba0747926efdbe8
data/HISTORY CHANGED
@@ -4,4 +4,7 @@
4
4
  + Allows expressions of the form `where('id=$1', 1)`.
5
5
  + You now need to call `#kick` when performing an insert or an update
6
6
  to get it to really happen. Please see our documentation in qed/*.
7
- + `domain.transaction do |conn| ... end`
7
+ + `domain.transaction do |conn| ... end`
8
+
9
+ 0.9.1
10
+ + `search_path` argument for `Flounder.connect`.
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.0'
5
+ s.version = '0.9.1'
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"
@@ -4,9 +4,15 @@ module Flounder
4
4
  attr_reader :pg
5
5
  attr_reader :visitor
6
6
 
7
- def initialize pg_conn_args
8
- @pg = PG.connect(*pg_conn_args)
7
+ def initialize pg_conn_opts
8
+ search_path = pg_conn_opts.delete(:search_path)
9
+
10
+ @pg = PG.connect(pg_conn_opts)
9
11
  @visitor = Arel::Visitors::PostgreSQL.new(self)
12
+
13
+ if search_path
14
+ exec('set search_path=' + search_path)
15
+ end
10
16
  end
11
17
 
12
18
  attr_reader :visitor
data/lib/flounder.rb CHANGED
@@ -22,8 +22,8 @@ require 'flounder/exceptions'
22
22
 
23
23
  module Flounder
24
24
  module_function
25
- def connect *args
26
- ConnectionPool.new(args)
25
+ def connect opts={}
26
+ ConnectionPool.new(opts)
27
27
  end
28
28
 
29
29
  def domain connection, &block
@@ -0,0 +1,41 @@
1
+ # Transactions
2
+
3
+ Transactions are supported on the domain and on entities. Since you need to make sure that your transaction uses only one connection, you will need to handle connections explicitly.
4
+
5
+ ~~~ruby
6
+ expect RuntimeError do
7
+ domain.with_connection do |conn|
8
+ conn.transaction do
9
+ posts.update(title: 'A single title for everyone').kick(conn)
10
+ fail 'rollback'
11
+ end
12
+ end
13
+ end
14
+
15
+ posts.first.title.assert != 'A single title for everyone'
16
+ ~~~
17
+
18
+ The same works on any entity from the domain. Please note that there is a shortcut for getting at a transaction.
19
+
20
+ ~~~ruby
21
+ domain.transaction do |conn|
22
+ posts.all(conn)
23
+ end
24
+
25
+ posts.transaction do |conn|
26
+ posts.all(conn)
27
+ end
28
+ ~~~
29
+
30
+ # Schemas & Search-Path
31
+
32
+ When connecting to a database, you can use the `search_path` argument to install a search path for all your accesses.
33
+
34
+ ~~~ruby
35
+ pool = Flounder.connect(dbname: 'flounder', search_path: 'public,test')
36
+ pool.with_connection do |connection|
37
+ result = connection.exec 'show search_path'
38
+ path = result.to_a.first.first.last
39
+ path.assert == 'public, test'
40
+ end
41
+ ~~~
data/qed/index.md CHANGED
@@ -112,31 +112,3 @@ The call to `#anchor` anchors all further joins at that point.
112
112
  to_sql.assert == %Q(SELECT "users"."id" FROM "users" WHERE "users"."id" = 2013)
113
113
  ~~~
114
114
 
115
- # Transactions
116
-
117
- Transactions are supported on the domain and on entities. Since you need to make sure that your transaction uses only one connection, you will need to handle connections explicitly.
118
-
119
- ~~~ruby
120
- expect RuntimeError do
121
- domain.with_connection do |conn|
122
- conn.transaction do
123
- posts.update(title: 'A single title for everyone').kick(conn)
124
- fail 'rollback'
125
- end
126
- end
127
- end
128
-
129
- posts.first.title.assert != 'A single title for everyone'
130
- ~~~
131
-
132
- The same works on any entity from the domain. Please note that there is a shortcut for getting at a transaction.
133
-
134
- ~~~ruby
135
- domain.transaction do |conn|
136
- posts.all(conn)
137
- end
138
-
139
- posts.transaction do |conn|
140
- posts.all(conn)
141
- end
142
- ~~~
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.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaspar Schiess
@@ -90,7 +90,6 @@ files:
90
90
  - HISTORY
91
91
  - LICENSE
92
92
  - README
93
- - flounder-0.3.0.gem
94
93
  - flounder.gemspec
95
94
  - lib/flounder.rb
96
95
  - lib/flounder/connection.rb
@@ -114,6 +113,7 @@ files:
114
113
  - qed/applique/setup_domain.rb
115
114
  - qed/atomic_insert_update.md
116
115
  - qed/conditions.md
116
+ - qed/database_technicalities.md
117
117
  - qed/exceptions.md
118
118
  - qed/flounder.sql
119
119
  - qed/index.md
@@ -153,6 +153,7 @@ test_files:
153
153
  - qed/applique/setup_domain.rb
154
154
  - qed/atomic_insert_update.md
155
155
  - qed/conditions.md
156
+ - qed/database_technicalities.md
156
157
  - qed/exceptions.md
157
158
  - qed/flounder.sql
158
159
  - qed/index.md
data/flounder-0.3.0.gem DELETED
Binary file