pod4 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hgtags +1 -0
- data/Gemfile +1 -0
- data/README.md +3 -2
- data/Rakefile +2 -2
- data/lib/pod4/nebulous_interface.rb +0 -2
- data/lib/pod4/pg_interface.rb +0 -1
- data/lib/pod4/sequel_interface.rb +0 -1
- data/lib/pod4/tds_interface.rb +0 -1
- data/lib/pod4/version.rb +1 -1
- data/{spec_common → spec/common}/sequel_interface_spec.rb +1 -0
- data/{spec_mri → spec/jruby}/pg_interface_spec.rb +3 -2
- data/spec/mri/pg_interface_spec.rb +453 -0
- data/{spec_mri → spec/mri}/tds_interface_spec.rb +3 -2
- metadata +38 -41
- data/spec_jruby/alert_spec.rb +0 -1
- data/spec_jruby/basic_model_spec.rb +0 -1
- data/spec_jruby/doc_no_pending.rb +0 -1
- data/spec_jruby/fixtures +0 -1
- data/spec_jruby/model_spec.rb +0 -1
- data/spec_jruby/nebulous_interface_spec.rb +0 -1
- data/spec_jruby/null_interface_spec.rb +0 -1
- data/spec_jruby/param_spec.rb +0 -1
- data/spec_jruby/pod4_spec.rb +0 -1
- data/spec_jruby/shared_examples_for_interface.rb +0 -1
- data/spec_jruby/spec_helper.rb +0 -24
- data/spec_mri/alert_spec.rb +0 -1
- data/spec_mri/basic_model_spec.rb +0 -1
- data/spec_mri/doc_no_pending.rb +0 -1
- data/spec_mri/fixtures +0 -1
- data/spec_mri/model_spec.rb +0 -1
- data/spec_mri/nebulous_interface_spec.rb +0 -1
- data/spec_mri/null_interface_spec.rb +0 -1
- data/spec_mri/param_spec.rb +0 -1
- data/spec_mri/pod4_spec.rb +0 -1
- data/spec_mri/sequel_interface_spec.rb +0 -1
- data/spec_mri/shared_examples_for_interface.rb +0 -1
- /data/{spec_common → spec}/README.md +0 -0
- /data/{spec_common → spec/common}/alert_spec.rb +0 -0
- /data/{spec_common → spec/common}/basic_model_spec.rb +0 -0
- /data/{spec_mri → spec/common}/model_plus_typecasting_spec.rb +0 -0
- /data/{spec_common → spec/common}/model_spec.rb +0 -0
- /data/{spec_common → spec/common}/nebulous_interface_spec.rb +0 -0
- /data/{spec_common → spec/common}/null_interface_spec.rb +0 -0
- /data/{spec_common → spec/common}/param_spec.rb +0 -0
- /data/{spec_common → spec/common}/pod4_spec.rb +0 -0
- /data/{spec_common → spec/common}/shared_examples_for_interface.rb +0 -0
- /data/{spec_common → spec/common}/spec_helper.rb +0 -0
- /data/{spec_common → spec}/doc_no_pending.rb +0 -0
- /data/{spec_common → spec}/fixtures/database.rb +0 -0
- /data/{spec_mri → spec}/spec_helper.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3413f940c1247aeff8c31bc7498b3a5d03f0a63a
|
4
|
+
data.tar.gz: ca5ba62daf452817d7b95131af0b581b940e06e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f40df06b6b359502f201d9eae2e7a2970d96ace5166bd6932b2ea4b2b7d8e0109aa407b0e95007d2aa0e11730bfa5de420abd236443f6dbc20d2caf278776f03
|
7
|
+
data.tar.gz: d70085fb97f4911dd052a099f7744925eb3f292860819739fbdacc47fc2f196aac8ccb9e34944d9e405b04a8a1480b08fce7c6215546f23be682e0ab67806ce3
|
data/.hgtags
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -167,6 +167,7 @@ Here is the model and interface definition that goes with the above example:
|
|
167
167
|
|
168
168
|
require 'pod4'
|
169
169
|
require 'pod4/pg_interface'
|
170
|
+
require 'pg'
|
170
171
|
|
171
172
|
class ExampleModel < Pod4::Model
|
172
173
|
|
@@ -184,8 +185,8 @@ table 'example'. The table has a primary key field 'id' and columns which
|
|
184
185
|
correspond to our three attributes one, two and three. There is no validation
|
185
186
|
or error control.
|
186
187
|
|
187
|
-
Note that we have to require pg_interface seperately. I won't bother to
|
188
|
-
this in any more model examples.
|
188
|
+
Note that we have to require pg_interface and pg seperately. I won't bother to
|
189
|
+
show this in any more model examples.
|
189
190
|
|
190
191
|
### Interface ###
|
191
192
|
|
data/Rakefile
CHANGED
@@ -17,12 +17,12 @@ namespace :rspec do
|
|
17
17
|
|
18
18
|
desc "run tests (mri)"
|
19
19
|
task :mri do
|
20
|
-
sh "rspec
|
20
|
+
sh "rspec spec/common spec/mri"
|
21
21
|
end
|
22
22
|
|
23
23
|
desc "run tests (jRuby)"
|
24
24
|
task :jruby do
|
25
|
-
sh "rspec
|
25
|
+
sh "rspec spec/common spec/jruby"
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
data/lib/pod4/pg_interface.rb
CHANGED
data/lib/pod4/tds_interface.rb
CHANGED
data/lib/pod4/version.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'pod4/pg_interface'
|
2
|
+
require 'pg'
|
2
3
|
|
3
|
-
require_relative 'shared_examples_for_interface'
|
4
|
-
require_relative 'fixtures/database'
|
4
|
+
require_relative '../common/shared_examples_for_interface'
|
5
|
+
require_relative '../fixtures/database'
|
5
6
|
|
6
7
|
|
7
8
|
class TestPgInterface < PgInterface
|
@@ -0,0 +1,453 @@
|
|
1
|
+
require 'pod4/pg_interface'
|
2
|
+
require 'pg'
|
3
|
+
|
4
|
+
require_relative '../common/shared_examples_for_interface'
|
5
|
+
require_relative '../fixtures/database'
|
6
|
+
|
7
|
+
|
8
|
+
class TestPgInterface < PgInterface
|
9
|
+
set_table :customer
|
10
|
+
set_id_fld :id
|
11
|
+
end
|
12
|
+
|
13
|
+
class SchemaPgInterface < PgInterface
|
14
|
+
set_schema :public
|
15
|
+
set_table :customer
|
16
|
+
set_id_fld :id
|
17
|
+
end
|
18
|
+
|
19
|
+
class BadPgInterface1 < PgInterface
|
20
|
+
set_table :customer
|
21
|
+
end
|
22
|
+
|
23
|
+
class BadPgInterface2 < PgInterface
|
24
|
+
set_id_fld :id
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
describe TestPgInterface do
|
29
|
+
|
30
|
+
def db_setup(connect)
|
31
|
+
client = PG.connect(connect)
|
32
|
+
|
33
|
+
client.exec(%Q|drop table if exists customer;|)
|
34
|
+
|
35
|
+
client.exec(%Q|
|
36
|
+
create table customer (
|
37
|
+
id serial,
|
38
|
+
name text,
|
39
|
+
level real null,
|
40
|
+
day date null,
|
41
|
+
timestamp timestamp null,
|
42
|
+
price money null,
|
43
|
+
qty numeric null );| )
|
44
|
+
|
45
|
+
ensure
|
46
|
+
client.finish if client
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def fill_data(ifce)
|
51
|
+
@data.each{|r| ifce.create(r) }
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
before(:all) do
|
56
|
+
@connect_hash = DB[:pg]
|
57
|
+
db_setup(@connect_hash)
|
58
|
+
|
59
|
+
@data = []
|
60
|
+
@data << { name: 'Barney',
|
61
|
+
level: 1.23,
|
62
|
+
day: Date.parse("2016-01-01"),
|
63
|
+
timestamp: Time.parse('2015-01-01 12:11'),
|
64
|
+
price: BigDecimal.new("1.24"),
|
65
|
+
qty: BigDecimal.new("1.25") }
|
66
|
+
|
67
|
+
@data << { name: 'Fred',
|
68
|
+
level: 2.34,
|
69
|
+
day: Date.parse("2016-02-02"),
|
70
|
+
timestamp: Time.parse('2015-01-02 12:22'),
|
71
|
+
price: BigDecimal.new("2.35"),
|
72
|
+
qty: BigDecimal.new("2.36") }
|
73
|
+
|
74
|
+
@data << { name: 'Betty',
|
75
|
+
level: 3.45,
|
76
|
+
day: Date.parse("2016-03-03"),
|
77
|
+
timestamp: Time.parse('2015-01-03 12:33'),
|
78
|
+
price: BigDecimal.new("3.46"),
|
79
|
+
qty: BigDecimal.new("3.47") }
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
before do
|
85
|
+
# TRUNCATE TABLE also resets the identity counter
|
86
|
+
interface.execute(%Q|truncate table customer restart identity;|)
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
let(:interface) do
|
91
|
+
TestPgInterface.new(@connect_hash)
|
92
|
+
end
|
93
|
+
|
94
|
+
#####
|
95
|
+
|
96
|
+
|
97
|
+
it_behaves_like 'an interface' do
|
98
|
+
|
99
|
+
let(:interface) do
|
100
|
+
TestPgInterface.new(@connect_hash)
|
101
|
+
end
|
102
|
+
|
103
|
+
let(:record) { {name: 'Barney'} }
|
104
|
+
|
105
|
+
end
|
106
|
+
##
|
107
|
+
|
108
|
+
|
109
|
+
describe 'PgInterface.set_schema' do
|
110
|
+
it 'takes one argument' do
|
111
|
+
expect( PgInterface ).to respond_to(:set_schema).with(1).argument
|
112
|
+
end
|
113
|
+
end
|
114
|
+
##
|
115
|
+
|
116
|
+
|
117
|
+
describe 'PgInterface.schema' do
|
118
|
+
it 'returns the schema' do
|
119
|
+
expect( SchemaPgInterface.schema ).to eq :public
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'is optional' do
|
123
|
+
expect{ TestPgInterface.schema }.not_to raise_exception
|
124
|
+
expect( TestPgInterface.schema ).to eq nil
|
125
|
+
end
|
126
|
+
end
|
127
|
+
##
|
128
|
+
|
129
|
+
|
130
|
+
describe 'PgInterface.set_table' do
|
131
|
+
it 'takes one argument' do
|
132
|
+
expect( PgInterface ).to respond_to(:set_table).with(1).argument
|
133
|
+
end
|
134
|
+
end
|
135
|
+
##
|
136
|
+
|
137
|
+
|
138
|
+
describe 'PgInterface.table' do
|
139
|
+
it 'returns the table' do
|
140
|
+
expect( TestPgInterface.table ).to eq :customer
|
141
|
+
end
|
142
|
+
end
|
143
|
+
##
|
144
|
+
|
145
|
+
|
146
|
+
describe 'PgInterface.set_id_fld' do
|
147
|
+
it 'takes one argument' do
|
148
|
+
expect( PgInterface ).to respond_to(:set_id_fld).with(1).argument
|
149
|
+
end
|
150
|
+
end
|
151
|
+
##
|
152
|
+
|
153
|
+
|
154
|
+
describe 'PgInterface.id_fld' do
|
155
|
+
it 'returns the ID field name' do
|
156
|
+
expect( TestPgInterface.id_fld ).to eq :id
|
157
|
+
end
|
158
|
+
end
|
159
|
+
##
|
160
|
+
|
161
|
+
|
162
|
+
describe '#new' do
|
163
|
+
|
164
|
+
it 'requires a TinyTds connection string' do
|
165
|
+
expect{ TestPgInterface.new }.to raise_exception ArgumentError
|
166
|
+
expect{ TestPgInterface.new(nil) }.to raise_exception ArgumentError
|
167
|
+
expect{ TestPgInterface.new('foo') }.to raise_exception ArgumentError
|
168
|
+
|
169
|
+
expect{ TestPgInterface.new(@connect_hash) }.not_to raise_exception
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
##
|
174
|
+
|
175
|
+
|
176
|
+
describe '#quoted_table' do
|
177
|
+
|
178
|
+
it 'returns just the table when the schema is not set' do
|
179
|
+
expect( interface.quoted_table ).to eq( %Q|"customer"| )
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'returns the schema plus table when the schema is set' do
|
183
|
+
ifce = SchemaPgInterface.new(@connect_hash)
|
184
|
+
expect( ifce.quoted_table ).to eq( %|"public"."customer"| )
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
##
|
189
|
+
|
190
|
+
|
191
|
+
describe '#create' do
|
192
|
+
|
193
|
+
let(:hash) { {name: 'Bam-Bam', price: 4.44} }
|
194
|
+
let(:ot) { Octothorpe.new(name: 'Wilma', price: 5.55) }
|
195
|
+
|
196
|
+
it 'raises a Pod4::DatabaseError if anything goes wrong' do
|
197
|
+
expect{ interface.create(one: 'two') }.to raise_exception DatabaseError
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'creates the record when given a hash' do
|
201
|
+
# kinda impossible to seperate these two tests
|
202
|
+
id = interface.create(hash)
|
203
|
+
|
204
|
+
expect{ interface.read(id) }.not_to raise_exception
|
205
|
+
expect( interface.read(id).to_h ).to include hash
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'creates the record when given an Octothorpe' do
|
209
|
+
id = interface.create(ot)
|
210
|
+
|
211
|
+
expect{ interface.read(id) }.not_to raise_exception
|
212
|
+
expect( interface.read(id).to_h ).to include ot.to_h
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'shouldnt have a problem with record values of nil' do
|
216
|
+
record = {name: 'Ranger', price: nil}
|
217
|
+
expect{ interface.create(record) }.not_to raise_exception
|
218
|
+
id = interface.create(record)
|
219
|
+
expect( interface.read(id).to_h ).to include(record)
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
223
|
+
##
|
224
|
+
|
225
|
+
|
226
|
+
describe '#read' do
|
227
|
+
before { fill_data(interface) }
|
228
|
+
|
229
|
+
it 'returns the record for the id as an Octothorpe' do
|
230
|
+
rec = interface.read(2)
|
231
|
+
expect( rec ).to be_a_kind_of Octothorpe
|
232
|
+
expect( rec.>>.name ).to eq 'Fred'
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'raises a Pod4::CantContinue if the ID is bad' do
|
236
|
+
expect{ interface.read(:foo) }.to raise_exception CantContinue
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'returns an empty Octothorpe if no record matches the ID' do
|
240
|
+
expect{ interface.read(99) }.not_to raise_exception
|
241
|
+
expect( interface.read(99) ).to be_a_kind_of Octothorpe
|
242
|
+
expect( interface.read(99) ).to be_empty
|
243
|
+
end
|
244
|
+
|
245
|
+
it 'returns real fields as Float' do
|
246
|
+
level = interface.read(1).>>.level
|
247
|
+
|
248
|
+
expect( level ).to be_a_kind_of Float
|
249
|
+
expect( level ).to be_within(0.001).of( @data.first[:level] )
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'returns date fields as Date' do
|
253
|
+
date = interface.read(1).>>.day
|
254
|
+
|
255
|
+
expect( date ).to be_a_kind_of Date
|
256
|
+
expect( date ).to eq @data.first[:day]
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'returns datetime fields as Time' do
|
260
|
+
timestamp = interface.read(1).>>.timestamp
|
261
|
+
|
262
|
+
expect( timestamp ).to be_a_kind_of Time
|
263
|
+
expect( timestamp ).to eq @data.first[:timestamp]
|
264
|
+
end
|
265
|
+
|
266
|
+
it 'returns numeric fields as BigDecimal' do
|
267
|
+
qty = interface.read(1).>>.qty
|
268
|
+
|
269
|
+
expect( qty ).to be_a_kind_of BigDecimal
|
270
|
+
expect( qty ).to eq @data.first[:qty]
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'returns money fields as BigDecimal' do
|
274
|
+
price = interface.read(1).>>.price
|
275
|
+
|
276
|
+
expect( price ).to be_a_kind_of BigDecimal
|
277
|
+
expect( price ).to eq @data.first[:price]
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
##
|
282
|
+
|
283
|
+
|
284
|
+
describe '#list' do
|
285
|
+
before { fill_data(interface) }
|
286
|
+
|
287
|
+
it 'has an optional selection parameter, a hash' do
|
288
|
+
# Actually it does not have to be a hash, but FTTB we only support that.
|
289
|
+
expect{ interface.list(name: 'Barney') }.not_to raise_exception
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'returns an array of Octothorpes that match the records' do
|
293
|
+
# convert each OT to a hash and remove the ID key
|
294
|
+
arr = interface.list.map {|ot| x = ot.to_h; x.delete(:id); x }
|
295
|
+
|
296
|
+
expect( arr ).to match_array @data
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'returns a subset of records based on the selection parameter' do
|
300
|
+
expect( interface.list(name: 'Fred').size ).to eq 1
|
301
|
+
|
302
|
+
expect( interface.list(name: 'Betty').first.to_h ).
|
303
|
+
to include(name: 'Betty')
|
304
|
+
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'returns an empty Array if nothing matches' do
|
308
|
+
expect( interface.list(name: 'Yogi') ).to eq([])
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'raises ArgumentError if the selection criteria is nonsensical' do
|
312
|
+
expect{ interface.list('foo') }.to raise_exception ArgumentError
|
313
|
+
end
|
314
|
+
|
315
|
+
end
|
316
|
+
##
|
317
|
+
|
318
|
+
|
319
|
+
describe '#update' do
|
320
|
+
before { fill_data(interface) }
|
321
|
+
|
322
|
+
let(:id) { interface.list.first[:id] }
|
323
|
+
|
324
|
+
def float_price(row)
|
325
|
+
row[:price] = row[:price].to_f
|
326
|
+
row
|
327
|
+
end
|
328
|
+
|
329
|
+
it 'updates the record at ID with record parameter' do
|
330
|
+
record = {name: 'Booboo', price: 99.99}
|
331
|
+
interface.update(id, record)
|
332
|
+
|
333
|
+
# It so happens that TinyTds returns money as BigDecimal --
|
334
|
+
# this is a really good thing, even though it screws with our test.
|
335
|
+
expect( float_price( interface.read(id).to_h ) ).to include(record)
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'raises a CantContinue if anything weird happens with the ID' do
|
339
|
+
expect{ interface.update(99, name: 'Booboo') }.
|
340
|
+
to raise_exception CantContinue
|
341
|
+
|
342
|
+
end
|
343
|
+
|
344
|
+
it 'raises a DatabaseError if anything weird happens with the record' do
|
345
|
+
expect{ interface.update(id, smarts: 'more') }.
|
346
|
+
to raise_exception DatabaseError
|
347
|
+
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'shouldnt have a problem with record values of nil' do
|
351
|
+
record = {name: 'Ranger', price: nil}
|
352
|
+
expect{ interface.update(id, record) }.not_to raise_exception
|
353
|
+
expect( interface.read(id).to_h ).to include(record)
|
354
|
+
end
|
355
|
+
|
356
|
+
end
|
357
|
+
##
|
358
|
+
|
359
|
+
|
360
|
+
describe '#delete' do
|
361
|
+
|
362
|
+
def list_contains(id)
|
363
|
+
interface.list.find {|x| x[interface.id_fld] == id }
|
364
|
+
end
|
365
|
+
|
366
|
+
let(:id) { interface.list.first[:id] }
|
367
|
+
|
368
|
+
before { fill_data(interface) }
|
369
|
+
|
370
|
+
it 'raises CantContinue if anything hinky happens with the id' do
|
371
|
+
expect{ interface.delete(:foo) }.to raise_exception CantContinue
|
372
|
+
expect{ interface.delete(99) }.to raise_exception CantContinue
|
373
|
+
end
|
374
|
+
|
375
|
+
it 'makes the record at ID go away' do
|
376
|
+
expect( list_contains(id) ).to be_truthy
|
377
|
+
interface.delete(id)
|
378
|
+
expect( list_contains(id) ).to be_falsy
|
379
|
+
end
|
380
|
+
|
381
|
+
end
|
382
|
+
##
|
383
|
+
|
384
|
+
|
385
|
+
describe '#execute' do
|
386
|
+
|
387
|
+
let(:sql) { 'delete from customer where cast(price as numeric) < 2.0;' }
|
388
|
+
|
389
|
+
before { fill_data(interface) }
|
390
|
+
|
391
|
+
it 'requires an SQL string' do
|
392
|
+
expect{ interface.execute }.to raise_exception ArgumentError
|
393
|
+
expect{ interface.execute(nil) }.to raise_exception ArgumentError
|
394
|
+
expect{ interface.execute(14) }.to raise_exception ArgumentError
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'raises some sort of Pod4 error if it runs into problems' do
|
398
|
+
expect{ interface.execute('delete from not_a_table') }.
|
399
|
+
to raise_exception Pod4Error
|
400
|
+
|
401
|
+
end
|
402
|
+
|
403
|
+
it 'executes the string' do
|
404
|
+
expect{ interface.execute(sql) }.not_to raise_exception
|
405
|
+
expect( interface.list.size ).to eq(@data.size - 1)
|
406
|
+
expect( interface.list.map{|r| r[:name] } ).not_to include 'Barney'
|
407
|
+
end
|
408
|
+
|
409
|
+
end
|
410
|
+
##
|
411
|
+
|
412
|
+
|
413
|
+
describe '#select' do
|
414
|
+
|
415
|
+
before { fill_data(interface) }
|
416
|
+
|
417
|
+
it 'requires an SQL string' do
|
418
|
+
expect{ interface.select }.to raise_exception ArgumentError
|
419
|
+
expect{ interface.select(nil) }.to raise_exception ArgumentError
|
420
|
+
expect{ interface.select(14) }.to raise_exception ArgumentError
|
421
|
+
end
|
422
|
+
|
423
|
+
it 'raises some sort of Pod4 error if it runs into problems' do
|
424
|
+
expect{ interface.select('select * from not_a_table') }.
|
425
|
+
to raise_exception Pod4Error
|
426
|
+
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'returns the result of the sql' do
|
430
|
+
sql1 = 'select name from customer where cast(price as numeric) < 2.0;'
|
431
|
+
sql2 = 'select name from customer where cast(price as numeric) < 0.0;'
|
432
|
+
|
433
|
+
expect{ interface.select(sql1) }.not_to raise_exception
|
434
|
+
expect( interface.select(sql1) ).to eq( [{name: 'Barney'}] )
|
435
|
+
expect( interface.select(sql2) ).to eq( [] )
|
436
|
+
end
|
437
|
+
|
438
|
+
it 'works if you pass a non-select' do
|
439
|
+
# By which I mean: still executes the SQL; returns []
|
440
|
+
sql = 'delete from customer where cast(price as numeric) < 2.0;'
|
441
|
+
ret = interface.select(sql)
|
442
|
+
|
443
|
+
expect( interface.list.size ).to eq(@data.size - 1)
|
444
|
+
expect( interface.list.map{|r| r[:name] } ).not_to include 'Barney'
|
445
|
+
expect( ret ).to eq( [] )
|
446
|
+
end
|
447
|
+
|
448
|
+
end
|
449
|
+
##
|
450
|
+
|
451
|
+
|
452
|
+
end
|
453
|
+
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'pod4/tds_interface'
|
2
2
|
|
3
|
+
require 'tiny_tds'
|
3
4
|
require 'date'
|
4
5
|
|
5
|
-
require_relative 'shared_examples_for_interface'
|
6
|
-
require_relative 'fixtures/database'
|
6
|
+
require_relative '../common/shared_examples_for_interface'
|
7
|
+
require_relative '../fixtures/database'
|
7
8
|
|
8
9
|
|
9
10
|
class TestTdsInterface < TdsInterface
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pod4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jones
|
@@ -76,45 +76,24 @@ files:
|
|
76
76
|
- md/fixme.md
|
77
77
|
- md/roadmap.md
|
78
78
|
- pod4.gemspec
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
- spec_jruby/nebulous_interface_spec.rb
|
98
|
-
- spec_jruby/null_interface_spec.rb
|
99
|
-
- spec_jruby/param_spec.rb
|
100
|
-
- spec_jruby/pod4_spec.rb
|
101
|
-
- spec_jruby/shared_examples_for_interface.rb
|
102
|
-
- spec_jruby/spec_helper.rb
|
103
|
-
- spec_mri/alert_spec.rb
|
104
|
-
- spec_mri/basic_model_spec.rb
|
105
|
-
- spec_mri/doc_no_pending.rb
|
106
|
-
- spec_mri/fixtures
|
107
|
-
- spec_mri/model_plus_typecasting_spec.rb
|
108
|
-
- spec_mri/model_spec.rb
|
109
|
-
- spec_mri/nebulous_interface_spec.rb
|
110
|
-
- spec_mri/null_interface_spec.rb
|
111
|
-
- spec_mri/param_spec.rb
|
112
|
-
- spec_mri/pg_interface_spec.rb
|
113
|
-
- spec_mri/pod4_spec.rb
|
114
|
-
- spec_mri/sequel_interface_spec.rb
|
115
|
-
- spec_mri/shared_examples_for_interface.rb
|
116
|
-
- spec_mri/spec_helper.rb
|
117
|
-
- spec_mri/tds_interface_spec.rb
|
79
|
+
- spec/README.md
|
80
|
+
- spec/common/alert_spec.rb
|
81
|
+
- spec/common/basic_model_spec.rb
|
82
|
+
- spec/common/model_plus_typecasting_spec.rb
|
83
|
+
- spec/common/model_spec.rb
|
84
|
+
- spec/common/nebulous_interface_spec.rb
|
85
|
+
- spec/common/null_interface_spec.rb
|
86
|
+
- spec/common/param_spec.rb
|
87
|
+
- spec/common/pod4_spec.rb
|
88
|
+
- spec/common/sequel_interface_spec.rb
|
89
|
+
- spec/common/shared_examples_for_interface.rb
|
90
|
+
- spec/common/spec_helper.rb
|
91
|
+
- spec/doc_no_pending.rb
|
92
|
+
- spec/fixtures/database.rb
|
93
|
+
- spec/jruby/pg_interface_spec.rb
|
94
|
+
- spec/mri/pg_interface_spec.rb
|
95
|
+
- spec/mri/tds_interface_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
118
97
|
- tags
|
119
98
|
homepage: https://bitbucket.org/andy-twosticks/pod4
|
120
99
|
licenses:
|
@@ -140,5 +119,23 @@ rubygems_version: 2.5.1
|
|
140
119
|
signing_key:
|
141
120
|
specification_version: 4
|
142
121
|
summary: Totally not an ORM
|
143
|
-
test_files:
|
122
|
+
test_files:
|
123
|
+
- spec/README.md
|
124
|
+
- spec/common/alert_spec.rb
|
125
|
+
- spec/common/basic_model_spec.rb
|
126
|
+
- spec/common/model_plus_typecasting_spec.rb
|
127
|
+
- spec/common/model_spec.rb
|
128
|
+
- spec/common/nebulous_interface_spec.rb
|
129
|
+
- spec/common/null_interface_spec.rb
|
130
|
+
- spec/common/param_spec.rb
|
131
|
+
- spec/common/pod4_spec.rb
|
132
|
+
- spec/common/sequel_interface_spec.rb
|
133
|
+
- spec/common/shared_examples_for_interface.rb
|
134
|
+
- spec/common/spec_helper.rb
|
135
|
+
- spec/doc_no_pending.rb
|
136
|
+
- spec/fixtures/database.rb
|
137
|
+
- spec/jruby/pg_interface_spec.rb
|
138
|
+
- spec/mri/pg_interface_spec.rb
|
139
|
+
- spec/mri/tds_interface_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
144
141
|
has_rdoc:
|
data/spec_jruby/alert_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/alert_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/basic_model_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/doc_no_pending.rb
|
data/spec_jruby/fixtures
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/fixtures
|
data/spec_jruby/model_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/model_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/nebulous_interface_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/null_interface_spec.rb
|
data/spec_jruby/param_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/param_spec.rb
|
data/spec_jruby/pod4_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/pod4_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/shared_examples_for_interface.rb
|
data/spec_jruby/spec_helper.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'pod4'
|
2
|
-
|
3
|
-
|
4
|
-
include Pod4
|
5
|
-
|
6
|
-
|
7
|
-
RSpec.configure do |config|
|
8
|
-
config.expect_with :rspec do |expectations|
|
9
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
10
|
-
end
|
11
|
-
|
12
|
-
config.mock_with :rspec do |mocks|
|
13
|
-
mocks.verify_partial_doubles = true
|
14
|
-
end
|
15
|
-
|
16
|
-
config.filter_run :focus
|
17
|
-
config.run_all_when_everything_filtered = true
|
18
|
-
|
19
|
-
if config.files_to_run.one?
|
20
|
-
config.default_formatter = 'doc'
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
data/spec_mri/alert_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/alert_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/basic_model_spec.rb
|
data/spec_mri/doc_no_pending.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/doc_no_pending.rb
|
data/spec_mri/fixtures
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/fixtures
|
data/spec_mri/model_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/model_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/nebulous_interface_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/null_interface_spec.rb
|
data/spec_mri/param_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/param_spec.rb
|
data/spec_mri/pod4_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/pod4_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/sequel_interface_spec.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
../spec_common/shared_examples_for_interface.rb
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|