activerecord-jdbcteradata-adapter 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/activerecord-jdbcteradata-adapter.gemspec +1 -1
- data/lib/arjdbc/teradata/adapter.rb +7 -3
- data/spec/associations_spec.rb +41 -1
- data/spec/models/purchase_orders.rb +21 -0
- metadata +1 -1
data/Gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "activerecord-jdbcteradata-adapter"
|
3
|
-
s.version = "0.3.
|
3
|
+
s.version = "0.3.9"
|
4
4
|
s.authors = ["Chris Parker"]
|
5
5
|
s.email = [ "mrcsparker@gmail.com"]
|
6
6
|
s.homepage = "https://github.com/mrcsparker/activerecord-jdbcteradata-adapter"
|
@@ -101,10 +101,14 @@ module ::ArJdbc
|
|
101
101
|
|
102
102
|
#- execute
|
103
103
|
def _execute(sql, name = nil)
|
104
|
-
|
105
|
-
|
104
|
+
if self.class.select?(sql)
|
105
|
+
@connection.execute_query(sql)
|
106
|
+
elsif self.class.insert?(sql)
|
107
|
+
(@connection.execute_insert(sql) or last_insert_id(sql)).to_i
|
108
|
+
else
|
109
|
+
@connection.execute_update(sql)
|
110
|
+
end
|
106
111
|
end
|
107
|
-
private :_execute
|
108
112
|
|
109
113
|
def _table_name_from_insert(sql)
|
110
114
|
sql.split(' ', 4)[2].gsub('"', '').gsub("'", '')
|
data/spec/associations_spec.rb
CHANGED
@@ -8,6 +8,7 @@ describe 'AssociationsSpec' do
|
|
8
8
|
CreateProducts.up
|
9
9
|
CreatePurchaseOrders.up
|
10
10
|
CreateOrderLineItems.up
|
11
|
+
CreateOrderFeelings.up
|
11
12
|
end
|
12
13
|
|
13
14
|
it 'should create all of the tables' do
|
@@ -28,7 +29,7 @@ describe 'AssociationsSpec' do
|
|
28
29
|
end
|
29
30
|
|
30
31
|
describe '#accepts_nested_attibutes_for' do
|
31
|
-
it '
|
32
|
+
it 'it has_many' do
|
32
33
|
vendor = Vendor.new(:name => 'Test vendor', :catch_phrase => 'Hello, world')
|
33
34
|
vendor.products.build(:name => 'Test product', :price => 100.00)
|
34
35
|
vendor.save
|
@@ -45,6 +46,44 @@ describe 'AssociationsSpec' do
|
|
45
46
|
purchase_order = PurchaseOrder.create(params[:purchase_order])
|
46
47
|
purchase_order.order_line_items.size.should == 1
|
47
48
|
end
|
49
|
+
|
50
|
+
it 'it has_one#create' do
|
51
|
+
vendor = Vendor.new(:name => 'Test vendor', :catch_phrase => 'Hello, world')
|
52
|
+
vendor.products.build(:name => 'Test product', :price => 100.00)
|
53
|
+
vendor.save
|
54
|
+
|
55
|
+
params = { :purchase_order => {
|
56
|
+
:product_id => vendor.products.first.id,
|
57
|
+
:code => 'Order 2',
|
58
|
+
:quantity => 1,
|
59
|
+
:order_feeling_attributes =>
|
60
|
+
{ :status => 'Wonderful' }
|
61
|
+
|
62
|
+
} }
|
63
|
+
|
64
|
+
purchase_order = PurchaseOrder.create(params[:purchase_order])
|
65
|
+
purchase_order.order_feeling.status.should eq('Wonderful')
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'it has_one#new' do
|
69
|
+
vendor = Vendor.new(:name => 'Test vendor', :catch_phrase => 'Hello, world')
|
70
|
+
vendor.products.build(:name => 'Test product', :price => 100.00)
|
71
|
+
vendor.save
|
72
|
+
|
73
|
+
params = { :purchase_order => {
|
74
|
+
:product_id => vendor.products.first.id,
|
75
|
+
:code => 'Order 3',
|
76
|
+
:quantity => 1,
|
77
|
+
:order_feeling_attributes =>
|
78
|
+
{ :status => 'Wonderful' }
|
79
|
+
|
80
|
+
} }
|
81
|
+
|
82
|
+
purchase_order = PurchaseOrder.new(params[:purchase_order])
|
83
|
+
purchase_order.save
|
84
|
+
purchase_order.order_feeling.status.should eq('Wonderful')
|
85
|
+
end
|
86
|
+
|
48
87
|
end
|
49
88
|
|
50
89
|
after(:all) do
|
@@ -52,5 +91,6 @@ describe 'AssociationsSpec' do
|
|
52
91
|
CreateProducts.down
|
53
92
|
CreatePurchaseOrders.down
|
54
93
|
CreateOrderLineItems.down
|
94
|
+
CreateOrderFeelings.down
|
55
95
|
end
|
56
96
|
end
|
@@ -44,6 +44,21 @@ class CreatePurchaseOrders < ActiveRecord::Migration
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
class CreateOrderFeelings < ActiveRecord::Migration
|
48
|
+
def self.up
|
49
|
+
create_table :order_feelings do |t|
|
50
|
+
t.integer :purchase_order_id, :null => false
|
51
|
+
t.string :status, :null => false
|
52
|
+
end
|
53
|
+
|
54
|
+
add_index :order_feelings, :purchase_order_id, :name => 'idx_order_feelings_po_id'
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.down
|
58
|
+
drop_table :order_feelings
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
47
62
|
class CreateOrderLineItems < ActiveRecord::Migration
|
48
63
|
def self.up
|
49
64
|
create_table :order_line_items do |t|
|
@@ -70,6 +85,10 @@ class Product < ActiveRecord::Base
|
|
70
85
|
has_many :purchase_orders
|
71
86
|
end
|
72
87
|
|
88
|
+
class OrderFeeling < ActiveRecord::Base
|
89
|
+
belongs_to :purchase_order
|
90
|
+
end
|
91
|
+
|
73
92
|
class OrderLineItem < ActiveRecord::Base
|
74
93
|
belongs_to :purchase_order
|
75
94
|
end
|
@@ -78,5 +97,7 @@ class PurchaseOrder < ActiveRecord::Base
|
|
78
97
|
belongs_to :product
|
79
98
|
has_many :order_line_items, :dependent => :destroy
|
80
99
|
accepts_nested_attributes_for :order_line_items, :allow_destroy => true
|
100
|
+
has_one :order_feeling, :dependent => :destroy
|
101
|
+
accepts_nested_attributes_for :order_feeling, :allow_destroy => true
|
81
102
|
end
|
82
103
|
|