mosql 0.4.1 → 0.4.2

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: 7ab1024ecdb478cb92b0c2041f7d5f52a67ec0d3
4
- data.tar.gz: 2b88ed3d4bb0723f67170d645d61e34b62d29dc6
3
+ metadata.gz: 6c0bef56bc688f403ccbc3ee8cb0e20a68a653b9
4
+ data.tar.gz: 7a1ee9bfb170e668aa201e84897a19d26cd3ea6b
5
5
  SHA512:
6
- metadata.gz: 5e8cc02a48b261391e0a161e0c35fb92113cc85f9e7436ed14bb9a4e0b54f4389f13093a02f9af6b516bd6d1d1db93202d5e8fd52c76d927564ead0733eb2d1d
7
- data.tar.gz: d6a2c35555a5e8d4c99596f8c0cd212dca2546932a023cc1d7686ea6581ef0387813179817ce368cf06dff50753b927cc1ecba8be3bc82b44ff52519c141e31c
6
+ metadata.gz: 476b45cde7f4be786096327408a5e07f2124d5cee2e9a53d5da04a4aa5307df2c5aa7e4aef8eff48f3a676249eb39c65f1dd0e8cf0d9a90fd6cb89fc22d74851
7
+ data.tar.gz: 866fb300b0608669bded7814e30d753749e1511af1008b56be79b032d1f108a3973bf39cf3ab825aa01ffe5155a4f2bdb15d4f7f8882e725118a3ad08a7797c2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mosql (0.4.1)
4
+ mosql (0.4.2)
5
5
  bson (~> 1.10)
6
6
  bson_ext
7
7
  json
data/README.md CHANGED
@@ -176,7 +176,8 @@ If it encounters a MongoDB object with fields not listed in the
176
176
  collection map, it will discard the extra fields, unless
177
177
  `:extra_props` is set in the `:meta` hash. If it is, it will collect
178
178
  any missing fields, JSON-encode them in a hash, and store the
179
- resulting text in `_extra_props` in SQL.
179
+ resulting text in `_extra_props` in SQL. You can set `:extra_props`
180
+ to use `JSON`, `JSONB`, or `TEXT`.
180
181
 
181
182
  As of PostgreSQL 9.3, you can declare columns as type "JSON" and use
182
183
  the [native JSON support][pg-json] to inspect inside of JSON-encoded
@@ -101,10 +101,13 @@ module MoSQL
101
101
  primary_key keys
102
102
  if meta[:extra_props]
103
103
  type =
104
- if meta[:extra_props] == "JSON"
105
- "JSON"
104
+ case meta[:extra_props]
105
+ when 'JSON'
106
+ 'JSON'
107
+ when 'JSONB'
108
+ 'JSONB'
106
109
  else
107
- "TEXT"
110
+ 'TEXT'
108
111
  end
109
112
  column '_extra_props', type
110
113
  end
@@ -185,14 +185,7 @@ module MoSQL
185
185
  @sql.upsert_ns(ns, obj)
186
186
  end
187
187
  else
188
- primary_sql_keys = @schema.primary_sql_key_for_ns(ns)
189
- schema = @schema.find_ns!(ns)
190
- query = {}
191
- primary_sql_keys.each do |key|
192
- source = schema[:columns].find {|c| c[:name] == key }[:source]
193
- query[key] = selector[source]
194
- end
195
- @sql.table_for_ns(ns).where(query).delete()
188
+ @sql.delete_ns(ns, selector)
196
189
  end
197
190
  end
198
191
 
@@ -1,3 +1,3 @@
1
1
  module MoSQL
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -139,6 +139,21 @@ EOF
139
139
  assert_equal(100, sequel[:sqltable].where(:_id => o['_id'].to_s).select.first[:var])
140
140
  end
141
141
 
142
+ it 'handle "u" ops with $set, BSON::ObjectID, and a deleted row' do
143
+ o = { '_id' => BSON::ObjectId.new, 'var' => 17 }
144
+ @adapter.upsert_ns('mosql_test.collection', o)
145
+
146
+ # Don't store the row in mongo, which will cause the 'u' op to
147
+ # delete it from SQL.
148
+
149
+ @streamer.handle_op({ 'ns' => 'mosql_test.collection',
150
+ 'op' => 'u',
151
+ 'o2' => { '_id' => o['_id'] },
152
+ 'o' => { '$set' => { 'var' => 100 } },
153
+ })
154
+ assert_equal(0, sequel[:sqltable].count(:_id => o['_id'].to_s))
155
+ end
156
+
142
157
  it 'handle "u" ops with $set and a renamed _id' do
143
158
  o = { '_id' => BSON::ObjectId.new, 'goats' => 96 }
144
159
  @adapter.upsert_ns('mosql_test.renameid', o)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mosql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nelson Elhage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel