activerecord-jdbc-adapter 1.3.0.beta2 → 1.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -8
- data/.travis.yml +40 -31
- data/.yardopts +4 -0
- data/Appraisals +2 -5
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +21 -4
- data/Gemfile.lock +42 -17
- data/{History.txt → History.md} +142 -75
- data/README.md +102 -104
- data/RUNNING_TESTS.md +76 -0
- data/Rakefile.jdbc +20 -0
- data/activerecord-jdbc-adapter.gemspec +35 -18
- data/gemfiles/rails23.gemfile +4 -3
- data/gemfiles/rails23.gemfile.lock +9 -6
- data/gemfiles/rails30.gemfile +4 -3
- data/gemfiles/rails30.gemfile.lock +9 -6
- data/gemfiles/rails31.gemfile +4 -3
- data/gemfiles/rails31.gemfile.lock +9 -6
- data/gemfiles/rails32.gemfile +4 -3
- data/gemfiles/rails32.gemfile.lock +17 -14
- data/gemfiles/rails40.gemfile +5 -5
- data/gemfiles/rails40.gemfile.lock +17 -69
- data/lib/active_record/connection_adapters/firebird_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
- data/lib/arel/visitors/compat.rb +22 -3
- data/lib/arel/visitors/db2.rb +8 -4
- data/lib/arel/visitors/derby.rb +14 -13
- data/lib/arel/visitors/firebird.rb +5 -4
- data/lib/arel/visitors/hsqldb.rb +11 -9
- data/lib/arel/visitors/sql_server.rb +89 -61
- data/lib/arjdbc.rb +1 -1
- data/lib/arjdbc/db2/adapter.rb +181 -212
- data/lib/arjdbc/db2/as400.rb +31 -18
- data/lib/arjdbc/db2/column.rb +167 -0
- data/lib/arjdbc/db2/connection_methods.rb +2 -0
- data/lib/arjdbc/derby/adapter.rb +206 -107
- data/lib/arjdbc/derby/connection_methods.rb +4 -9
- data/lib/arjdbc/firebird.rb +1 -0
- data/lib/arjdbc/firebird/adapter.rb +202 -64
- data/lib/arjdbc/firebird/connection_methods.rb +20 -0
- data/lib/arjdbc/h2/adapter.rb +56 -36
- data/lib/arjdbc/hsqldb/adapter.rb +99 -68
- data/lib/arjdbc/jdbc/adapter.rb +474 -265
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/adapter_require.rb +8 -7
- data/lib/arjdbc/jdbc/arel_support.rb +132 -0
- data/lib/arjdbc/jdbc/base_ext.rb +8 -7
- data/lib/arjdbc/jdbc/callbacks.rb +16 -10
- data/lib/arjdbc/jdbc/column.rb +25 -3
- data/lib/arjdbc/jdbc/connection.rb +28 -55
- data/lib/arjdbc/jdbc/extension.rb +14 -14
- data/lib/arjdbc/jdbc/java.rb +6 -3
- data/lib/arjdbc/jdbc/jdbc.rake +1 -1
- data/lib/arjdbc/jdbc/quoted_primary_key.rb +2 -2
- data/lib/arjdbc/jdbc/rake_tasks.rb +1 -1
- data/lib/arjdbc/jdbc/type_converter.rb +5 -2
- data/lib/arjdbc/mssql/adapter.rb +160 -280
- data/lib/arjdbc/mssql/column.rb +182 -0
- data/lib/arjdbc/mssql/connection_methods.rb +37 -4
- data/lib/arjdbc/mssql/explain_support.rb +13 -21
- data/lib/arjdbc/mssql/limit_helpers.rb +79 -42
- data/lib/arjdbc/mssql/lock_methods.rb +77 -0
- data/lib/arjdbc/mssql/utils.rb +11 -11
- data/lib/arjdbc/mysql/adapter.rb +165 -247
- data/lib/arjdbc/mysql/column.rb +123 -0
- data/lib/arjdbc/mysql/connection_methods.rb +3 -6
- data/lib/arjdbc/oracle/adapter.rb +282 -288
- data/lib/arjdbc/oracle/column.rb +122 -0
- data/lib/arjdbc/oracle/connection_methods.rb +3 -0
- data/lib/arjdbc/postgresql/adapter.rb +336 -574
- data/lib/arjdbc/postgresql/column.rb +458 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +1 -2
- data/lib/arjdbc/postgresql/schema_creation.rb +38 -0
- data/lib/arjdbc/sqlite3/adapter.rb +189 -145
- data/lib/arjdbc/sqlite3/explain_support.rb +1 -1
- data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +8 -8
- data/lib/arjdbc/util/quoted_cache.rb +60 -0
- data/lib/arjdbc/util/table_copier.rb +110 -0
- data/lib/arjdbc/version.rb +6 -7
- data/pom.xml +56 -2
- data/rakelib/02-test.rake +72 -83
- data/rakelib/db.rake +29 -17
- data/src/java/arjdbc/ArJdbcModule.java +21 -18
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +84 -12
- data/src/java/arjdbc/derby/DerbyModule.java +140 -143
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +58 -7
- data/src/java/arjdbc/h2/H2Module.java +43 -0
- data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +7 -6
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1223 -648
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +24 -23
- data/src/java/arjdbc/mysql/MySQLModule.java +33 -32
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +147 -30
- data/src/java/arjdbc/oracle/OracleModule.java +13 -13
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +114 -6
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +166 -36
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +101 -19
- data/src/java/arjdbc/util/QuotingUtils.java +19 -19
- metadata +240 -394
- data/bench/bench_attributes.rb +0 -13
- data/bench/bench_attributes_new.rb +0 -14
- data/bench/bench_create.rb +0 -12
- data/bench/bench_find_all.rb +0 -12
- data/bench/bench_find_all_mt.rb +0 -25
- data/bench/bench_model.rb +0 -85
- data/bench/bench_new.rb +0 -12
- data/bench/bench_new_valid.rb +0 -12
- data/bench/bench_valid.rb +0 -13
- data/lib/arel/engines/sql/compilers/db2_compiler.rb +0 -9
- data/lib/arel/engines/sql/compilers/derby_compiler.rb +0 -6
- data/lib/arel/engines/sql/compilers/h2_compiler.rb +0 -6
- data/lib/arel/engines/sql/compilers/hsqldb_compiler.rb +0 -15
- data/lib/arel/engines/sql/compilers/jdbc_compiler.rb +0 -6
- data/lib/arel/engines/sql/compilers/mssql_compiler.rb +0 -46
- data/lib/arjdbc/jdbc/missing_functionality_helper.rb +0 -98
- data/lib/arjdbc/mssql/lock_helpers.rb +0 -76
- data/lib/arjdbc/mssql/tsql_methods.rb +0 -58
- data/lib/arjdbc/postgresql/column_cast.rb +0 -134
- data/test/activerecord/connections/native_jdbc_mysql/connection.rb +0 -25
- data/test/activerecord/jall.sh +0 -7
- data/test/activerecord/jtest.sh +0 -3
- data/test/assets/flowers.jpg +0 -0
- data/test/binary.rb +0 -67
- data/test/db/db2.rb +0 -43
- data/test/db/db2/binary_test.rb +0 -6
- data/test/db/db2/has_many_through_test.rb +0 -6
- data/test/db/db2/rake_test.rb +0 -82
- data/test/db/db2/rake_test_data.sql +0 -35
- data/test/db/db2/reset_column_information_test.rb +0 -5
- data/test/db/db2/serialize_test.rb +0 -6
- data/test/db/db2/simple_test.rb +0 -81
- data/test/db/db2/test_helper.rb +0 -6
- data/test/db/db2/unit_test.rb +0 -73
- data/test/db/derby.rb +0 -12
- data/test/db/derby/binary_test.rb +0 -6
- data/test/db/derby/migration_test.rb +0 -74
- data/test/db/derby/rake_test.rb +0 -96
- data/test/db/derby/reset_column_information_test.rb +0 -6
- data/test/db/derby/row_locking_test.rb +0 -20
- data/test/db/derby/schema_dump_test.rb +0 -5
- data/test/db/derby/serialize_test.rb +0 -6
- data/test/db/derby/simple_test.rb +0 -173
- data/test/db/derby/test_helper.rb +0 -6
- data/test/db/derby/unit_test.rb +0 -32
- data/test/db/derby/xml_column_test.rb +0 -17
- data/test/db/h2.rb +0 -11
- data/test/db/h2/binary_test.rb +0 -6
- data/test/db/h2/change_column_test.rb +0 -68
- data/test/db/h2/identity_column_test.rb +0 -35
- data/test/db/h2/offset_test.rb +0 -49
- data/test/db/h2/rake_test.rb +0 -98
- data/test/db/h2/schema_dump_test.rb +0 -29
- data/test/db/h2/serialize_test.rb +0 -6
- data/test/db/h2/simple_test.rb +0 -56
- data/test/db/hsqldb.rb +0 -11
- data/test/db/hsqldb/binary_test.rb +0 -6
- data/test/db/hsqldb/rake_test.rb +0 -101
- data/test/db/hsqldb/schema_dump_test.rb +0 -19
- data/test/db/hsqldb/serialize_test.rb +0 -6
- data/test/db/hsqldb/simple_test.rb +0 -17
- data/test/db/informix.rb +0 -13
- data/test/db/jdbc.rb +0 -16
- data/test/db/jdbc_derby.rb +0 -14
- data/test/db/jdbc_h2.rb +0 -17
- data/test/db/jdbc_mysql.rb +0 -13
- data/test/db/jdbc_postgres.rb +0 -23
- data/test/db/jndi_config.rb +0 -32
- data/test/db/jndi_pooled_config.rb +0 -32
- data/test/db/mssql.rb +0 -11
- data/test/db/mssql/binary_test.rb +0 -6
- data/test/db/mssql/exec_proc_test.rb +0 -46
- data/test/db/mssql/identity_insert_test.rb +0 -18
- data/test/db/mssql/ignore_system_views_test.rb +0 -40
- data/test/db/mssql/limit_offset_test.rb +0 -190
- data/test/db/mssql/multibyte_test.rb +0 -16
- data/test/db/mssql/multiple_connections_test.rb +0 -71
- data/test/db/mssql/rake_test.rb +0 -143
- data/test/db/mssql/reset_column_information_test.rb +0 -6
- data/test/db/mssql/row_locking_test.rb +0 -7
- data/test/db/mssql/serialize_test.rb +0 -6
- data/test/db/mssql/simple_test.rb +0 -140
- data/test/db/mssql/transaction_test.rb +0 -6
- data/test/db/mssql/types_test.rb +0 -205
- data/test/db/mssql/unit_test.rb +0 -249
- data/test/db/mysql.rb +0 -4
- data/test/db/mysql/_rails_test_mysql.32.out +0 -6585
- data/test/db/mysql/binary_test.rb +0 -6
- data/test/db/mysql/connection_test.rb +0 -51
- data/test/db/mysql/index_length_test.rb +0 -58
- data/test/db/mysql/multibyte_test.rb +0 -10
- data/test/db/mysql/nonstandard_primary_key_test.rb +0 -39
- data/test/db/mysql/rake_test.rb +0 -97
- data/test/db/mysql/reset_column_information_test.rb +0 -6
- data/test/db/mysql/schema_dump_test.rb +0 -228
- data/test/db/mysql/serialize_test.rb +0 -6
- data/test/db/mysql/simple_test.rb +0 -187
- data/test/db/mysql/statement_escaping_test.rb +0 -46
- data/test/db/mysql/transaction_test.rb +0 -6
- data/test/db/mysql/types_test.rb +0 -30
- data/test/db/mysql/unit_test.rb +0 -93
- data/test/db/mysql_config.rb +0 -7
- data/test/db/oracle.rb +0 -27
- data/test/db/oracle/binary_test.rb +0 -6
- data/test/db/oracle/limit_test.rb +0 -24
- data/test/db/oracle/multibyte_test.rb +0 -22
- data/test/db/oracle/rake_test.rb +0 -100
- data/test/db/oracle/reset_column_information_test.rb +0 -6
- data/test/db/oracle/serialize_test.rb +0 -6
- data/test/db/oracle/simple_test.rb +0 -140
- data/test/db/oracle/specific_test.rb +0 -180
- data/test/db/oracle/transaction_test.rb +0 -31
- data/test/db/oracle/unit_test.rb +0 -31
- data/test/db/postgres.rb +0 -11
- data/test/db/postgres/_rails_test_postgres.32.out +0 -6405
- data/test/db/postgres/a_custom_primary_key_test.rb +0 -50
- data/test/db/postgres/active_schema_unit_test.rb +0 -68
- data/test/db/postgres/array_type_test.rb +0 -101
- data/test/db/postgres/binary_test.rb +0 -6
- data/test/db/postgres/connection_test.rb +0 -63
- data/test/db/postgres/data_types_test.rb +0 -703
- data/test/db/postgres/hstore_test.rb +0 -200
- data/test/db/postgres/information_schema_leak_test.rb +0 -30
- data/test/db/postgres/json_test.rb +0 -86
- data/test/db/postgres/ltree_test.rb +0 -51
- data/test/db/postgres/mixed_case_test.rb +0 -29
- data/test/db/postgres/native_types_test.rb +0 -124
- data/test/db/postgres/rake_test.rb +0 -117
- data/test/db/postgres/reserved_test.rb +0 -22
- data/test/db/postgres/reset_column_information_test.rb +0 -6
- data/test/db/postgres/row_locking_test.rb +0 -21
- data/test/db/postgres/schema_dump_test.rb +0 -95
- data/test/db/postgres/schema_test.rb +0 -115
- data/test/db/postgres/simple_test.rb +0 -260
- data/test/db/postgres/table_alias_length_test.rb +0 -16
- data/test/db/postgres/transaction_test.rb +0 -6
- data/test/db/postgres/unit_test.rb +0 -31
- data/test/db/postgres_config.rb +0 -10
- data/test/db/sqlite3.rb +0 -6
- data/test/db/sqlite3/_rails_test_sqlite3.32.out +0 -6274
- data/test/db/sqlite3/has_many_though_test.rb +0 -6
- data/test/db/sqlite3/rake_test.rb +0 -71
- data/test/db/sqlite3/reset_column_information_test.rb +0 -6
- data/test/db/sqlite3/schema_dump_test.rb +0 -6
- data/test/db/sqlite3/serialize_test.rb +0 -6
- data/test/db/sqlite3/simple_test.rb +0 -268
- data/test/db/sqlite3/transaction_test.rb +0 -32
- data/test/db/sqlite3/type_conversion_test.rb +0 -104
- data/test/has_many_through.rb +0 -61
- data/test/informix_simple_test.rb +0 -48
- data/test/jdbc/db2.rb +0 -36
- data/test/jdbc/oracle.rb +0 -34
- data/test/jdbc_column_test.rb +0 -23
- data/test/jdbc_common.rb +0 -16
- data/test/jdbc_connection_test.rb +0 -196
- data/test/jndi_callbacks_test.rb +0 -33
- data/test/jndi_test.rb +0 -55
- data/test/manualTestDatabase.rb +0 -191
- data/test/models/add_not_null_column_to_table.rb +0 -9
- data/test/models/auto_id.rb +0 -15
- data/test/models/binary.rb +0 -18
- data/test/models/custom_pk_name.rb +0 -15
- data/test/models/data_types.rb +0 -40
- data/test/models/entry.rb +0 -41
- data/test/models/mixed_case.rb +0 -22
- data/test/models/reserved_word.rb +0 -15
- data/test/models/rights_and_roles.rb +0 -57
- data/test/models/string_id.rb +0 -17
- data/test/models/thing.rb +0 -17
- data/test/models/topic.rb +0 -32
- data/test/models/validates_uniqueness_of_string.rb +0 -19
- data/test/rails/mysql.rb +0 -13
- data/test/rails/sqlite3/version.rb +0 -6
- data/test/rails_stub.rb +0 -31
- data/test/rake_test_support.rb +0 -298
- data/test/row_locking.rb +0 -102
- data/test/schema_dump.rb +0 -182
- data/test/serialize.rb +0 -275
- data/test/shared_helper.rb +0 -35
- data/test/simple.rb +0 -1317
- data/test/sybase_jtds_simple_test.rb +0 -28
- data/test/sybase_reset_column_information_test.rb +0 -6
- data/test/test_helper.rb +0 -304
- data/test/transaction.rb +0 -109
data/test/jndi_test.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'db/jndi_config'
|
2
|
-
require 'simple'
|
3
|
-
|
4
|
-
class DerbyJndiTest < Test::Unit::TestCase
|
5
|
-
include SimpleTestMethods
|
6
|
-
|
7
|
-
# Derby specifics :
|
8
|
-
DbTypeMigration.big_decimal_precision = 31
|
9
|
-
ALIVE_SQL = 'SELECT 1 FROM SYS.SYSSCHEMAS'
|
10
|
-
|
11
|
-
def setup
|
12
|
-
config = { :connection_alive_sql => ALIVE_SQL }.merge(JNDI_CONFIG)
|
13
|
-
ActiveRecord::Base.establish_connection config
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
test "(raw) connection is a jndi connection" do
|
18
|
-
connection = ActiveRecord::Base.connection.raw_connection
|
19
|
-
assert_true connection.jndi?
|
20
|
-
assert_true connection.jndi_connection?
|
21
|
-
end
|
22
|
-
|
23
|
-
test "fills username from data source meta-data if missing" do
|
24
|
-
connection = ActiveRecord::Base.connection.raw_connection
|
25
|
-
|
26
|
-
config = { :jndi => JNDI_CONFIG[:jndi] }
|
27
|
-
ArJdbc::Derby.adapter_matcher('Derby', config)
|
28
|
-
assert_equal 'sa', config[:username]
|
29
|
-
|
30
|
-
# but only for Derby of course :
|
31
|
-
config = { :jndi => JNDI_CONFIG[:jndi] }
|
32
|
-
ArJdbc::Derby.adapter_matcher('DB42', config)
|
33
|
-
assert_nil config[:username]
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
require 'db/jndi_pooled_config'
|
39
|
-
|
40
|
-
class DerbyJndiPooledTest < Test::Unit::TestCase
|
41
|
-
include SimpleTestMethods
|
42
|
-
|
43
|
-
def self.startup
|
44
|
-
ActiveRecord::Base.establish_connection( {
|
45
|
-
:connection_alive_sql => DerbyJndiTest::ALIVE_SQL
|
46
|
-
}.merge(JNDI_POOLED_CONFIG) )
|
47
|
-
end
|
48
|
-
|
49
|
-
test "(raw) connection is a jndi connection" do
|
50
|
-
connection = ActiveRecord::Base.connection.raw_connection
|
51
|
-
assert_true connection.jndi?
|
52
|
-
assert_true connection.jndi_connection?
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
data/test/manualTestDatabase.rb
DELETED
@@ -1,191 +0,0 @@
|
|
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|mimer/ !~ 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|mimer/ !~ 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
|
-
self.table_name = "author" if /db2|firebird|mimer/ =~ 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|mimer/ !~ 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
|
-
prods = Product.find :all
|
176
|
-
order = Order.new(:name => "Dalai Lama", :address => "Great Road 32", :email => "abc@dot.com", :pay_type => "cash")
|
177
|
-
order.line_items << LineItem.new(:product => prods[0], :quantity => 3, :total_price => (prods[0].price * 3))
|
178
|
-
order.line_items << LineItem.new(:product => prods[2], :quantity => 1, :total_price => (prods[2].price))
|
179
|
-
order.save
|
180
|
-
|
181
|
-
puts "order: #{order.line_items.inspect}, with id: #{order.id} and name: #{order.name}"
|
182
|
-
end
|
183
|
-
|
184
|
-
ActiveRecord::Schema.define do
|
185
|
-
drop_table :line_items
|
186
|
-
drop_table :orders
|
187
|
-
drop_table :products
|
188
|
-
|
189
|
-
|
190
|
-
drop_table((/db2|firebird|mimer/=~ARGV[1]? :author : :authors ))
|
191
|
-
end
|
data/test/models/auto_id.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
class CreateAutoIds < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table "auto_ids", :force => true do |t|
|
4
|
-
t.column :value, :integer
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.down
|
9
|
-
drop_table "auto_ids"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class AutoId < ActiveRecord::Base
|
14
|
-
def self.table_name() "auto_ids" end
|
15
|
-
end
|
data/test/models/binary.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
class Binary < ActiveRecord::Base
|
2
|
-
end
|
3
|
-
|
4
|
-
class BinaryMigration < ActiveRecord::Migration
|
5
|
-
|
6
|
-
def self.up
|
7
|
-
create_table :binaries, :force => true do |t|
|
8
|
-
t.string :name
|
9
|
-
t.binary :data
|
10
|
-
t.binary :short_data, :limit => 2048
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.down
|
15
|
-
drop_table :binaries
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class CreateCustomPkName < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :custom_pk_names, :force => true, :id => false do |t|
|
4
|
-
t.primary_key :custom_id
|
5
|
-
t.string :name
|
6
|
-
end
|
7
|
-
end
|
8
|
-
def self.down
|
9
|
-
drop_table :custom_pk_names
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class CustomPkName < ActiveRecord::Base
|
14
|
-
self.primary_key = "custom_id"
|
15
|
-
end
|
data/test/models/data_types.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
class DbTypeMigration < ActiveRecord::Migration
|
2
|
-
|
3
|
-
# Oracle/SQLServer supports precision up to 38
|
4
|
-
@@big_decimal_precision = 38
|
5
|
-
|
6
|
-
def self.big_decimal_precision; @@big_decimal_precision; end
|
7
|
-
def self.big_decimal_precision=(precision); @@big_decimal_precision = precision; end
|
8
|
-
|
9
|
-
def self.up
|
10
|
-
create_table "db_types", :force => true do |t|
|
11
|
-
t.column :sample_timestamp, :timestamp
|
12
|
-
t.column :sample_datetime, :datetime
|
13
|
-
t.column :sample_date, :date
|
14
|
-
t.column :sample_time, :time
|
15
|
-
# NOTE: on purpose setup so that it's OK to use a 32-bit integer column :
|
16
|
-
t.column :sample_decimal, :decimal, :precision => 9, :scale => 0
|
17
|
-
t.column :sample_small_decimal, :decimal, :precision => 3, :scale => 2, :default => 3.14
|
18
|
-
t.column :sample_default_decimal, :decimal
|
19
|
-
t.column :sample_float, :float
|
20
|
-
t.column :sample_binary, :binary
|
21
|
-
t.column :sample_boolean, :boolean
|
22
|
-
t.column :sample_string, :string, :default => ''
|
23
|
-
t.column :sample_integer, :integer, :limit => 5
|
24
|
-
t.column :sample_integer_with_limit_2, :integer, :limit => 2
|
25
|
-
t.column :sample_integer_with_limit_8, :integer, :limit => 8
|
26
|
-
t.column :sample_integer_no_limit, :integer, :default => 42
|
27
|
-
t.column :sample_integer_neg_default, :integer, :default => -1
|
28
|
-
t.column :sample_text, :text
|
29
|
-
t.decimal :decimal_with_scale, :precision => 15, :scale => 3
|
30
|
-
t.decimal :big_decimal, :precision => big_decimal_precision, :scale => 0
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.down
|
35
|
-
drop_table "db_types"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class DbType < ActiveRecord::Base
|
40
|
-
end
|
data/test/models/entry.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
class CreateEntries < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table "entries", :force => true do |t|
|
4
|
-
t.column :title, :string, :limit => 100
|
5
|
-
t.column :content, :text
|
6
|
-
t.column :rating, :decimal, :precision => 10, :scale => 2
|
7
|
-
t.column :user_id, :integer
|
8
|
-
t.column :updated_on, :datetime # treated as date "_on" convention
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.down
|
13
|
-
drop_table "entries"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class Entry < ActiveRecord::Base
|
18
|
-
belongs_to :user
|
19
|
-
|
20
|
-
def to_param
|
21
|
-
"#{id}-#{title.gsub(/[^a-zA-Z0-9]/, '-')}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class CreateUsers < ActiveRecord::Migration
|
26
|
-
def self.up
|
27
|
-
create_table "users", :force => true do |t|
|
28
|
-
t.column :login, :string, :limit => 100, :null => false
|
29
|
-
t.timestamps # created_at / updated_at
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.down
|
34
|
-
drop_table "users"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class User < ActiveRecord::Base
|
39
|
-
has_many :entries
|
40
|
-
end
|
41
|
-
|
data/test/models/mixed_case.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Migration
|
2
|
-
class MixedCase < ActiveRecord::Migration
|
3
|
-
|
4
|
-
def self.up
|
5
|
-
create_table "mixed_cases" do |t|
|
6
|
-
t.column :SOME_value, :string
|
7
|
-
end
|
8
|
-
create_table "tblUsers" do |t|
|
9
|
-
t.column :firstName, :string
|
10
|
-
t.column :lastName, :string
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.down
|
15
|
-
drop_table "mixed_cases"
|
16
|
-
drop_table "tblUsers"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class MixedCase < ActiveRecord::Base
|
22
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class CreateReservedWords < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table "reserved_words", :force => true do |t|
|
4
|
-
t.column :position, :integer
|
5
|
-
t.column :select, :integer
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.down
|
10
|
-
drop_table "reserved_words"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class ReservedWord < ActiveRecord::Base
|
15
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
class CreateRightsAndRoles < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :role_assignments do |t|
|
4
|
-
t.column :role_id, :integer
|
5
|
-
t.column :user_id, :integer
|
6
|
-
end
|
7
|
-
|
8
|
-
create_table :roles do |t|
|
9
|
-
t.column :name, :string
|
10
|
-
t.column :description, :string
|
11
|
-
end
|
12
|
-
|
13
|
-
create_table :permission_groups do |t|
|
14
|
-
t.column :right_id, :integer, :null => false
|
15
|
-
t.column :role_id, :integer, :null => false
|
16
|
-
end
|
17
|
-
|
18
|
-
create_table :rights do |t|
|
19
|
-
t.column :name, :string
|
20
|
-
t.column :controller_name, :string
|
21
|
-
t.column :actions, :string
|
22
|
-
t.column :hours, :float, :null => false
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.down
|
27
|
-
drop_table :role_assignments
|
28
|
-
drop_table :roles
|
29
|
-
drop_table :permission_groups
|
30
|
-
drop_table :rights
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class Right < ActiveRecord::Base
|
35
|
-
has_many :permission_groups, :dependent => :destroy
|
36
|
-
has_many :roles, :through => :permission_groups
|
37
|
-
end
|
38
|
-
|
39
|
-
class Role < ActiveRecord::Base
|
40
|
-
has_many :permission_groups, :dependent => :destroy
|
41
|
-
has_many :rights, :through => :permission_groups
|
42
|
-
has_many :role_assignments, :dependent => :destroy
|
43
|
-
|
44
|
-
def has_right?(right)
|
45
|
-
rights.include? right
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class PermissionGroup < ActiveRecord::Base
|
50
|
-
belongs_to :right
|
51
|
-
belongs_to :role
|
52
|
-
end
|
53
|
-
|
54
|
-
class RoleAssignment < ActiveRecord::Base
|
55
|
-
belongs_to :user
|
56
|
-
belongs_to :role
|
57
|
-
end
|