ActiveRecord-JDBC 0.0.1 → 0.2.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.
@@ -0,0 +1 @@
1
+ require 'active_record/connection_adapters/jdbc_adapter'
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env jruby
2
+
3
+ if ARGV.length < 2
4
+ $stderr.puts "syntax: #{__FILE__} [filename] [configuration-name]"
5
+ $stderr.puts " where filename points to a YAML database configuration file"
6
+ $stderr.puts " and the configuration name is in this file"
7
+ exit
8
+ end
9
+
10
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
11
+
12
+ require 'yaml'
13
+ require 'rubygems'
14
+ RAILS_CONNECTION_ADAPTERS = ['mysql', 'jdbc']
15
+ require 'active_record'
16
+
17
+ cfg = (File.open(ARGV[0]) {|f| YAML.load(f) })[ARGV[1]]
18
+
19
+ ActiveRecord::Base.establish_connection(cfg)
20
+
21
+ ActiveRecord::Schema.define do
22
+ drop_table :authors rescue nil
23
+ drop_table :author rescue nil
24
+
25
+ create_table :author, :force => true do |t|
26
+ t.column :name, :string, :null => false
27
+ end
28
+
29
+ # Exercise all types, and add_column
30
+ add_column :author, :description, :text
31
+ add_column :author, :descr, :string, :limit => 50
32
+ add_column :author, :age, :integer, :null => false, :default => 17
33
+ add_column :author, :weight, :float
34
+ add_column :author, :born, :datetime
35
+ add_column :author, :died, :timestamp
36
+ add_column :author, :wakeup_time, :time
37
+ add_column :author, :birth_date, :date
38
+ add_column :author, :private_key, :binary
39
+ add_column :author, :female, :boolean, :default => true
40
+
41
+ change_column :author, :descr, :string, :limit => 100 if /db2|derby/ !~ ARGV[1]
42
+ change_column_default :author, :female, false if /db2|derby|mssql|firebird/ !~ ARGV[1]
43
+ remove_column :author, :died if /db2|derby/ !~ ARGV[1]
44
+ rename_column :author, :wakeup_time, :waking_time if /db2|derby/ !~ ARGV[1]
45
+
46
+ add_index :author, :name, :unique if /db2/ !~ ARGV[1]
47
+ add_index :author, [:age,:female], :name => :is_age_female if /db2/ !~ ARGV[1]
48
+
49
+ remove_index :author, :name if /db2/ !~ ARGV[1]
50
+ remove_index :author, :name => :is_age_female if /db2/ !~ ARGV[1]
51
+
52
+ rename_table :author, :authors if /db2|firebird/ !~ ARGV[1]
53
+
54
+
55
+ create_table :products, :force => true do |t|
56
+ t.column :title, :string
57
+ t.column :description, :text
58
+ t.column :image_url, :string
59
+ end
60
+ add_column :products, :price, :float, :default => 0.0
61
+ create_table :orders, :force => true do |t|
62
+ t.column :name, :string
63
+ t.column :address, :text
64
+ t.column :email, :string
65
+ t.column :pay_type, :string, :limit => 10
66
+ end
67
+ create_table :line_items, :force => true do |t|
68
+ t.column :product_id, :integer, :null => false
69
+ t.column :order_id, :integer, :null => false
70
+ t.column :quantity, :integer, :null => false
71
+ t.column :total_price, :float, :null => false
72
+ end
73
+ end
74
+
75
+ class Author < ActiveRecord::Base;
76
+ set_table_name "author" if /db2|firebird/ =~ ARGV[1]
77
+ end
78
+
79
+ class Order < ActiveRecord::Base
80
+ has_many :line_items
81
+ end
82
+
83
+ class Product < ActiveRecord::Base
84
+ has_many :orders, :through => :line_items
85
+ has_many :line_items
86
+
87
+ def self.find_products_for_sale
88
+ find(:all, :order => "title")
89
+ end
90
+ end
91
+
92
+ class LineItem < ActiveRecord::Base
93
+ belongs_to :order
94
+ belongs_to :product
95
+ end
96
+
97
+ Product.create(:title => 'Pragmatic Project Automation',
98
+ :description =>
99
+ %{<p>
100
+ <em>Pragmatic Project Automation</em> shows you how to improve the
101
+ consistency and repeatability of your project's procedures using
102
+ automation to reduce risk and errors.
103
+ </p>
104
+ <p>
105
+ Simply put, we're going to put this thing called a computer to work
106
+ for you doing the mundane (but important) project stuff. That means
107
+ you'll have more time and energy to do the really
108
+ exciting---and difficult---stuff, like writing quality code.
109
+ </p>},
110
+ :image_url => '/images/auto.jpg',
111
+ :price => 29.95)
112
+
113
+
114
+ Product.create(:title => 'Pragmatic Version Control',
115
+ :description =>
116
+ %{<p>
117
+ This book is a recipe-based approach to using Subversion that will
118
+ get you up and
119
+ running quickly---and correctly. All projects need version control:
120
+ it's a foundational piece of any project's infrastructure. Yet half
121
+ of all project teams in the U.S. don't use any version control at all.
122
+ Many others don't use it well, and end up experiencing time-consuming problems.
123
+ </p>},
124
+ :image_url => '/images/svn.jpg',
125
+ :price => 28.50)
126
+
127
+ # . . .
128
+
129
+
130
+ Product.create(:title => 'Pragmatic Unit Testing (C#)',
131
+ :description =>
132
+ %{<p>
133
+ Pragmatic programmers use feedback to drive their development and
134
+ personal processes. The most valuable feedback you can get while
135
+ coding comes from unit testing.
136
+ </p>
137
+ <p>
138
+ Without good tests in place, coding can become a frustrating game of
139
+ "whack-a-mole." That's the carnival game where the player strikes at a
140
+ mechanical mole; it retreats and another mole pops up on the opposite side
141
+ of the field. The moles pop up and down so fast that you end up flailing
142
+ your mallet helplessly as the moles continue to pop up where you least
143
+ expect them.
144
+ </p>},
145
+ :image_url => '/images/utc.jpg',
146
+ :price => 27.75)
147
+
148
+
149
+
150
+
151
+ 1.times do
152
+ $stderr.print '.'
153
+ Author.destroy_all
154
+ Author.create(:name => "Arne Svensson", :age => 30)
155
+ if /db2|derby/ !~ ARGV[1]
156
+ Author.create(:name => "Pelle Gogolsson", :age => 15, :waking_time => Time.now, :private_key => "afbafddsfgsdfg")
157
+ else
158
+ Author.create(:name => "Pelle Gogolsson", :age => 15, :wakeup_time => Time.now, :private_key => "afbafddsfgsdfg")
159
+ end
160
+ Author.find(:first)
161
+ Author.find(:all)
162
+ arne = Author.find(:first)
163
+ arne.destroy
164
+
165
+ pelle = Author.find(:first)
166
+ pelle.name = "Pelle Sweitchon"
167
+ pelle.description = "dfsssdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
168
+ pelle.descr = "adsfasdf"
169
+ pelle.age = 79
170
+ pelle.weight = 57.6
171
+ pelle.born = Time.gm(1982,8,13,10,15,3,0)
172
+ pelle.female = false
173
+ pelle.save
174
+
175
+
176
+
177
+
178
+
179
+ prods = Product.find_all
180
+ order = Order.new(:name => "Dalai Lama", :address => "Great Road 32", :email => "abc@dot.com", :pay_type => "cash")
181
+ order.line_items << LineItem.new(:product => prods[0], :quantity => 3, :total_price => (prods[0].price * 3))
182
+ order.line_items << LineItem.new(:product => prods[2], :quantity => 1, :total_price => (prods[2].price))
183
+ order.save
184
+
185
+ puts "order: #{order.line_items.inspect}, with id: #{order.id} and name: #{order.name}"
186
+ end
187
+
188
+ ActiveRecord::Schema.define do
189
+ drop_table :line_items
190
+ drop_table :orders
191
+ drop_table :products
192
+
193
+
194
+ drop_table((/db2|firebird/=~ARGV[1]? :author : :authors ))
195
+ end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ActiveRecord-JDBC
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2006-08-07 00:00:00 +02:00
6
+ version: 0.2.0
7
+ date: 2006-09-06 00:00:00 +02:00
8
8
  summary: JDBC support for ActiveRecord. Only usable within JRuby
9
9
  require_paths:
10
10
  - lib
@@ -25,25 +25,29 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - JRuby-extras
30
31
  files:
31
32
  - lib/active_record
33
+ - lib/jdbc_adapter.rb
32
34
  - lib/active_record/connection_adapters
35
+ - lib/active_record/connection_adapters/jdbc_adapter_spec.rb
33
36
  - lib/active_record/connection_adapters/jdbc_adapter.rb
34
37
  - test/activerecord
35
38
  - test/minirunit
36
39
  - test/minirunit.rb
40
+ - test/manualTestDatabase.rb
37
41
  - test/activerecord/connections
38
- - test/activerecord/jall.sh
39
42
  - test/activerecord/jtest.sh
43
+ - test/activerecord/jall.sh
40
44
  - test/activerecord/connections/native_jdbc_mysql
41
45
  - test/activerecord/connections/native_jdbc_mysql/connection.rb
42
- - test/minirunit/testConnect.rb
43
46
  - test/minirunit/testHsqldb.rb
44
- - test/minirunit/testLoadActiveRecord.rb
45
47
  - test/minirunit/testMysql.rb
48
+ - test/minirunit/testConnect.rb
46
49
  - test/minirunit/testRawSelect.rb
50
+ - test/minirunit/testLoadActiveRecord.rb
47
51
  - LICENSE
48
52
  - init.rb
49
53
  - install.rb