pod4 0.7.2 → 0.8.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 +4 -4
- data/.hgignore +1 -0
- data/.hgtags +1 -0
- data/Gemfile +3 -1
- data/Rakefile +17 -5
- data/lib/pod4/pg_interface.rb +81 -57
- data/lib/pod4/sequel_interface.rb +61 -6
- data/lib/pod4/sql_helper.rb +229 -0
- data/lib/pod4/tds_interface.rb +65 -50
- data/lib/pod4/version.rb +1 -1
- data/md/roadmap.md +81 -25
- data/spec/common/basic_model_spec.rb +5 -0
- data/spec/common/model_spec.rb +49 -7
- data/spec/common/nebulous_interface_spec.rb +2 -0
- data/spec/common/sequel_interface_pg_spec.rb +511 -0
- data/spec/common/sql_helper_spec.rb +299 -0
- data/spec/jruby/sequel_interface_jdbc_ms_spec.rb +525 -0
- data/spec/jruby/sequel_interface_jdbc_pg_spec.rb +520 -0
- data/spec/mri/pg_interface_spec.rb +140 -16
- data/spec/mri/sequel_interface_spec.rb +146 -13
- data/spec/mri/tds_interface_spec.rb +82 -12
- metadata +11 -4
- data/spec/jruby/pg_interface_spec.rb +0 -469
@@ -30,6 +30,12 @@ class BadTdsInterface2 < TdsInterface
|
|
30
30
|
set_id_fld :id
|
31
31
|
end
|
32
32
|
|
33
|
+
class ProdTdsInterface < TdsInterface
|
34
|
+
set_db :pod4_test
|
35
|
+
set_table :product
|
36
|
+
set_id_fld :code
|
37
|
+
end
|
38
|
+
|
33
39
|
|
34
40
|
describe TestTdsInterface do
|
35
41
|
|
@@ -42,10 +48,14 @@ describe TestTdsInterface do
|
|
42
48
|
client.execute(%Q|
|
43
49
|
if exists (select * from INFORMATION_SCHEMA.TABLES
|
44
50
|
where TABLE_NAME = 'customer'
|
45
|
-
|
46
|
-
drop table dbo.customer
|
51
|
+
and TABLE_SCHEMA = 'dbo' )
|
52
|
+
drop table dbo.customer;
|
53
|
+
|
54
|
+
if exists (select * from INFORMATION_SCHEMA.TABLES
|
55
|
+
where TABLE_NAME = 'product'
|
56
|
+
and TABLE_SCHEMA = 'dbo' )
|
57
|
+
drop table dbo.product;
|
47
58
|
|
48
|
-
client.execute(%Q|
|
49
59
|
create table dbo.customer (
|
50
60
|
id int identity(1,1) not null,
|
51
61
|
name nvarchar(max),
|
@@ -53,7 +63,11 @@ describe TestTdsInterface do
|
|
53
63
|
day date null,
|
54
64
|
timestamp datetime null,
|
55
65
|
price money null,
|
56
|
-
qty numeric(5,2) null )
|
66
|
+
qty numeric(5,2) null );
|
67
|
+
|
68
|
+
create table dbo.product (
|
69
|
+
code nvarchar(20),
|
70
|
+
name nvarchar(max) );| ).do
|
57
71
|
|
58
72
|
ensure
|
59
73
|
client.close if client
|
@@ -64,6 +78,10 @@ describe TestTdsInterface do
|
|
64
78
|
@data.each{|r| ifce.create(r) }
|
65
79
|
end
|
66
80
|
|
81
|
+
def fill_product_data(ifce)
|
82
|
+
ifce.create( {code: "foo", name: "bar"} )
|
83
|
+
end
|
84
|
+
|
67
85
|
|
68
86
|
before(:all) do
|
69
87
|
@connect_hash = DB[:tds]
|
@@ -104,6 +122,10 @@ describe TestTdsInterface do
|
|
104
122
|
TestTdsInterface.new(@connect_hash)
|
105
123
|
end
|
106
124
|
|
125
|
+
let(:prod_interface) do
|
126
|
+
ProdTdsInterface.new(@connect_hash)
|
127
|
+
end
|
128
|
+
|
107
129
|
#####
|
108
130
|
|
109
131
|
|
@@ -113,6 +135,7 @@ describe TestTdsInterface do
|
|
113
135
|
TestTdsInterface.new(@connect_hash)
|
114
136
|
end
|
115
137
|
|
138
|
+
|
116
139
|
let(:record) { {name: 'Barney'} }
|
117
140
|
|
118
141
|
end
|
@@ -252,20 +275,29 @@ describe TestTdsInterface do
|
|
252
275
|
expect( interface.read(id).to_h ).to include ot.to_h
|
253
276
|
end
|
254
277
|
|
255
|
-
it '
|
278
|
+
it 'shouldn\'t have a problem with record values of nil' do
|
256
279
|
hash2 = {name: 'Ranger', price: nil}
|
257
280
|
expect{ interface.create(hash2) }.not_to raise_exception
|
258
281
|
id = interface.create(hash2)
|
259
282
|
expect( interface.read(id).to_h ).to include(hash2)
|
260
283
|
end
|
261
284
|
|
262
|
-
it '
|
285
|
+
it 'shouldn\'t have a problem with strings containing special characters' do
|
263
286
|
hash2 = {name: "T'Challa[]", price: nil}
|
264
287
|
expect{ interface.create(hash2) }.not_to raise_exception
|
265
288
|
id = interface.create(hash2)
|
266
289
|
expect( interface.read(id).to_h ).to include(hash2)
|
267
290
|
end
|
268
291
|
|
292
|
+
it 'shouldn\'t have a problem with non-integer keys' do
|
293
|
+
hash = {code: "foo", name: "bar"}
|
294
|
+
id = prod_interface.create( Octothorpe.new(hash) )
|
295
|
+
|
296
|
+
expect( id ).to eq "foo"
|
297
|
+
expect{ prod_interface.read("foo") }.not_to raise_exception
|
298
|
+
expect( prod_interface.read("foo").to_h ).to include hash
|
299
|
+
end
|
300
|
+
|
269
301
|
end
|
270
302
|
##
|
271
303
|
|
@@ -325,6 +357,14 @@ describe TestTdsInterface do
|
|
325
357
|
expect( price ).to eq @data.first[:price]
|
326
358
|
end
|
327
359
|
|
360
|
+
it 'shouldn\'t have a problem with non-integer keys' do
|
361
|
+
# this is a 100% overlap with the create test above...
|
362
|
+
fill_product_data(prod_interface)
|
363
|
+
|
364
|
+
expect{ prod_interface.read("foo") }.not_to raise_exception
|
365
|
+
expect( prod_interface.read("foo").to_h ).to include(code: "foo", name: "bar")
|
366
|
+
end
|
367
|
+
|
328
368
|
end
|
329
369
|
##
|
330
370
|
|
@@ -395,26 +435,32 @@ describe TestTdsInterface do
|
|
395
435
|
|
396
436
|
end
|
397
437
|
|
398
|
-
it '
|
438
|
+
it 'shouldn\'t have a problem with record values of nil' do
|
399
439
|
record = {name: 'Ranger', price: nil}
|
400
440
|
expect{ interface.update(id, record) }.not_to raise_exception
|
401
441
|
expect( interface.read(id).to_h ).to include(record)
|
402
442
|
end
|
403
443
|
|
404
|
-
it '
|
444
|
+
it 'shouldn\'t have a problem with strings containing special characters' do
|
405
445
|
record = {name: "T'Challa[]", price: nil}
|
406
446
|
expect{ interface.update(id, record) }.not_to raise_exception
|
407
447
|
expect( interface.read(id).to_h ).to include(record)
|
408
448
|
end
|
409
449
|
|
450
|
+
it 'shouldn\'t have a problem with non-integer keys' do
|
451
|
+
fill_product_data(prod_interface)
|
452
|
+
expect{ prod_interface.update("foo", name: "baz") }.not_to raise_error
|
453
|
+
expect( prod_interface.read("foo").to_h[:name] ).to eq "baz"
|
454
|
+
end
|
455
|
+
|
410
456
|
end
|
411
457
|
##
|
412
458
|
|
413
459
|
|
414
460
|
describe '#delete' do
|
415
461
|
|
416
|
-
def list_contains(id)
|
417
|
-
|
462
|
+
def list_contains(ifce, id)
|
463
|
+
ifce.list.find {|x| x[ifce.id_fld] == id }
|
418
464
|
end
|
419
465
|
|
420
466
|
let(:id) { interface.list.first[:id] }
|
@@ -427,9 +473,16 @@ describe TestTdsInterface do
|
|
427
473
|
end
|
428
474
|
|
429
475
|
it 'makes the record at ID go away' do
|
430
|
-
expect( list_contains(id) ).to be_truthy
|
476
|
+
expect( list_contains(interface, id) ).to be_truthy
|
431
477
|
interface.delete(id)
|
432
|
-
expect( list_contains(id) ).to be_falsy
|
478
|
+
expect( list_contains(interface, id) ).to be_falsy
|
479
|
+
end
|
480
|
+
|
481
|
+
it 'shouldn\'t have a problem with non-integer keys' do
|
482
|
+
fill_product_data(prod_interface)
|
483
|
+
expect( list_contains(prod_interface, "foo") ).to be_truthy
|
484
|
+
prod_interface.delete("foo")
|
485
|
+
expect( list_contains(prod_interface, "foo") ).to be_falsy
|
433
486
|
end
|
434
487
|
|
435
488
|
end
|
@@ -504,5 +557,22 @@ describe TestTdsInterface do
|
|
504
557
|
##
|
505
558
|
|
506
559
|
|
560
|
+
describe "#escape" do
|
561
|
+
# This just wraps the TinyTDS escape method, and we don't really know what that does.
|
562
|
+
# But at the very least it should deal with ' inside a string.
|
563
|
+
# Frankly? I suspect that that's all it does.
|
564
|
+
|
565
|
+
it "returns a simple String unchanged" do
|
566
|
+
expect( interface.escape "foo" ).to eq %Q|foo|
|
567
|
+
end
|
568
|
+
|
569
|
+
it "turns a single quote into a doubled single quote" do
|
570
|
+
expect( interface.escape "G'Kar" ).to eq %Q|G''Kar|
|
571
|
+
end
|
572
|
+
|
573
|
+
end
|
574
|
+
##
|
575
|
+
|
576
|
+
|
507
577
|
end
|
508
578
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pod4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devnull
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/pod4/param.rb
|
71
71
|
- lib/pod4/pg_interface.rb
|
72
72
|
- lib/pod4/sequel_interface.rb
|
73
|
+
- lib/pod4/sql_helper.rb
|
73
74
|
- lib/pod4/tds_interface.rb
|
74
75
|
- lib/pod4/typecasting.rb
|
75
76
|
- lib/pod4/version.rb
|
@@ -85,11 +86,14 @@ files:
|
|
85
86
|
- spec/common/null_interface_spec.rb
|
86
87
|
- spec/common/param_spec.rb
|
87
88
|
- spec/common/pod4_spec.rb
|
89
|
+
- spec/common/sequel_interface_pg_spec.rb
|
88
90
|
- spec/common/shared_examples_for_interface.rb
|
89
91
|
- spec/common/spec_helper.rb
|
92
|
+
- spec/common/sql_helper_spec.rb
|
90
93
|
- spec/doc_no_pending.rb
|
91
94
|
- spec/fixtures/database.rb
|
92
|
-
- spec/jruby/
|
95
|
+
- spec/jruby/sequel_interface_jdbc_ms_spec.rb
|
96
|
+
- spec/jruby/sequel_interface_jdbc_pg_spec.rb
|
93
97
|
- spec/mri/pg_interface_spec.rb
|
94
98
|
- spec/mri/sequel_interface_spec.rb
|
95
99
|
- spec/mri/tds_interface_spec.rb
|
@@ -129,11 +133,14 @@ test_files:
|
|
129
133
|
- spec/common/null_interface_spec.rb
|
130
134
|
- spec/common/param_spec.rb
|
131
135
|
- spec/common/pod4_spec.rb
|
136
|
+
- spec/common/sequel_interface_pg_spec.rb
|
132
137
|
- spec/common/shared_examples_for_interface.rb
|
133
138
|
- spec/common/spec_helper.rb
|
139
|
+
- spec/common/sql_helper_spec.rb
|
134
140
|
- spec/doc_no_pending.rb
|
135
141
|
- spec/fixtures/database.rb
|
136
|
-
- spec/jruby/
|
142
|
+
- spec/jruby/sequel_interface_jdbc_ms_spec.rb
|
143
|
+
- spec/jruby/sequel_interface_jdbc_pg_spec.rb
|
137
144
|
- spec/mri/pg_interface_spec.rb
|
138
145
|
- spec/mri/sequel_interface_spec.rb
|
139
146
|
- spec/mri/tds_interface_spec.rb
|