flounder 0.9.0 → 0.9.1
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 +4 -4
- data/HISTORY +4 -1
- data/flounder.gemspec +1 -1
- data/lib/flounder/connection.rb +8 -2
- data/lib/flounder.rb +2 -2
- data/qed/database_technicalities.md +41 -0
- data/qed/index.md +0 -28
- metadata +3 -2
- data/flounder-0.3.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7f0215b9a32d26575d6a27982baf1e3557df937
|
4
|
+
data.tar.gz: b0b7cb0356ea83e8af672a0f91b025f567891d03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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"
|
data/lib/flounder/connection.rb
CHANGED
@@ -4,9 +4,15 @@ module Flounder
|
|
4
4
|
attr_reader :pg
|
5
5
|
attr_reader :visitor
|
6
6
|
|
7
|
-
def initialize
|
8
|
-
|
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
@@ -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.
|
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
|