activerecord 1.6.0 → 1.7.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.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- data/CHANGELOG +78 -0
- data/README +20 -29
- data/RUNNING_UNIT_TESTS +1 -2
- data/examples/validation.rb +0 -3
- data/install.rb +3 -16
- data/lib/active_record.rb +11 -4
- data/lib/active_record/aggregations.rb +2 -2
- data/lib/active_record/associations.rb +8 -8
- data/lib/active_record/associations/association_collection.rb +1 -1
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +1 -1
- data/lib/active_record/base.rb +117 -43
- data/lib/active_record/callbacks.rb +2 -2
- data/lib/active_record/connection_adapters/abstract_adapter.rb +7 -14
- data/lib/active_record/connection_adapters/db2_adapter.rb +33 -22
- data/lib/active_record/connection_adapters/mysql_adapter.rb +74 -33
- data/lib/active_record/connection_adapters/oci_adapter.rb +265 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +23 -3
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +13 -4
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +158 -67
- data/lib/active_record/deprecated_associations.rb +4 -4
- data/lib/active_record/fixtures.rb +12 -5
- data/lib/active_record/locking.rb +22 -22
- data/lib/active_record/observer.rb +6 -3
- data/lib/active_record/timestamp.rb +15 -5
- data/lib/active_record/transactions.rb +4 -4
- data/lib/active_record/validations.rb +272 -189
- data/lib/active_record/wrappings.rb +2 -2
- data/rakefile +17 -2
- data/test/aaa_create_tables_test.rb +58 -0
- data/test/abstract_unit.rb +3 -2
- data/test/aggregations_test.rb +0 -1
- data/test/associations_test.rb +27 -28
- data/test/base_test.rb +74 -2
- data/test/binary_test.rb +6 -2
- data/test/class_inheritable_attributes_test.rb +1 -1
- data/test/column_alias_test.rb +9 -2
- data/test/connections/native_oci/connection.rb +25 -0
- data/test/connections/native_sqlite/connection.rb +4 -1
- data/test/connections/native_sqlite3/connection.rb +4 -2
- data/test/deprecated_associations_test.rb +4 -5
- data/test/finder_test.rb +20 -4
- data/test/fixtures/db_definitions/create_oracle_db.bat +5 -0
- data/test/fixtures/db_definitions/create_oracle_db.sh +5 -0
- data/test/fixtures/db_definitions/db2.drop.sql +18 -0
- data/test/fixtures/db_definitions/db2.sql +1 -0
- data/test/fixtures/db_definitions/db22.drop.sql +2 -0
- data/test/fixtures/db_definitions/db22.sql +1 -0
- data/test/fixtures/db_definitions/drop_oracle_tables.sql +35 -0
- data/test/fixtures/db_definitions/drop_oracle_tables2.sql +3 -0
- data/test/fixtures/db_definitions/mysql.drop.sql +18 -0
- data/test/fixtures/db_definitions/mysql.sql +2 -1
- data/test/fixtures/db_definitions/mysql2.drop.sql +2 -0
- data/test/fixtures/db_definitions/mysql2.sql +1 -0
- data/test/fixtures/db_definitions/oci.drop.sql +18 -0
- data/test/fixtures/db_definitions/oci.sql +167 -0
- data/test/fixtures/db_definitions/oci2.drop.sql +2 -0
- data/test/fixtures/db_definitions/oci2.sql +6 -0
- data/test/fixtures/db_definitions/postgresql.drop.sql +18 -0
- data/test/fixtures/db_definitions/postgresql.sql +2 -1
- data/test/fixtures/db_definitions/postgresql2.drop.sql +2 -0
- data/test/fixtures/db_definitions/postgresql2.sql +2 -1
- data/test/fixtures/db_definitions/sqlite.drop.sql +18 -0
- data/test/fixtures/db_definitions/sqlite.sql +2 -1
- data/test/fixtures/db_definitions/sqlite2.drop.sql +2 -0
- data/test/fixtures/db_definitions/sqlite2.sql +1 -0
- data/test/fixtures/db_definitions/sqlserver.drop.sql +18 -0
- data/test/fixtures/db_definitions/sqlserver.sql +1 -0
- data/test/fixtures/db_definitions/sqlserver2.drop.sql +2 -0
- data/test/fixtures/db_definitions/sqlserver2.sql +1 -0
- data/test/fixtures/fixture_database.sqlite +0 -0
- data/test/fixtures/fixture_database_2.sqlite +0 -0
- data/test/fixtures/topics.yml +3 -3
- data/test/lifecycle_test.rb +0 -1
- data/test/modules_test.rb +0 -1
- data/test/reflection_test.rb +0 -1
- data/test/validations_test.rb +229 -41
- metadata +36 -28
- data/dev-utils/eval_debugger.rb +0 -14
- data/lib/active_record/support/binding_of_caller.rb +0 -83
- data/lib/active_record/support/breakpoint.rb +0 -518
- data/lib/active_record/support/class_attribute_accessors.rb +0 -57
- data/lib/active_record/support/class_inheritable_attributes.rb +0 -117
- data/lib/active_record/support/clean_logger.rb +0 -10
- data/lib/active_record/support/core_ext.rb +0 -1
- data/lib/active_record/support/core_ext/hash.rb +0 -5
- data/lib/active_record/support/core_ext/hash/keys.rb +0 -35
- data/lib/active_record/support/core_ext/numeric.rb +0 -7
- data/lib/active_record/support/core_ext/numeric/bytes.rb +0 -33
- data/lib/active_record/support/core_ext/numeric/time.rb +0 -59
- data/lib/active_record/support/core_ext/object_and_class.rb +0 -24
- data/lib/active_record/support/core_ext/string.rb +0 -5
- data/lib/active_record/support/core_ext/string/inflections.rb +0 -45
- data/lib/active_record/support/dependencies.rb +0 -63
- data/lib/active_record/support/inflector.rb +0 -84
- data/lib/active_record/support/misc.rb +0 -8
- data/lib/active_record/support/module_attribute_accessors.rb +0 -57
@@ -1,84 +0,0 @@
|
|
1
|
-
# The Inflector transforms words from singular to plural, class names to table names, modulized class names to ones without,
|
2
|
-
# and class names to foreign keys.
|
3
|
-
module Inflector
|
4
|
-
extend self
|
5
|
-
|
6
|
-
def pluralize(word)
|
7
|
-
result = word.to_s.dup
|
8
|
-
plural_rules.each do |(rule, replacement)|
|
9
|
-
break if result.gsub!(rule, replacement)
|
10
|
-
end
|
11
|
-
return result
|
12
|
-
end
|
13
|
-
|
14
|
-
def singularize(word)
|
15
|
-
result = word.to_s.dup
|
16
|
-
singular_rules.each do |(rule, replacement)|
|
17
|
-
break if result.gsub!(rule, replacement)
|
18
|
-
end
|
19
|
-
return result
|
20
|
-
end
|
21
|
-
|
22
|
-
def camelize(lower_case_and_underscored_word)
|
23
|
-
lower_case_and_underscored_word.to_s.gsub(/(^|_)(.)/){$2.upcase}
|
24
|
-
end
|
25
|
-
|
26
|
-
def underscore(camel_cased_word)
|
27
|
-
camel_cased_word.to_s.gsub(/([A-Z]+)([A-Z])/,'\1_\2').gsub(/([a-z])([A-Z])/,'\1_\2').downcase
|
28
|
-
end
|
29
|
-
|
30
|
-
def humanize(lower_case_and_underscored_word)
|
31
|
-
lower_case_and_underscored_word.to_s.gsub(/_/, " ").capitalize
|
32
|
-
end
|
33
|
-
|
34
|
-
def demodulize(class_name_in_module)
|
35
|
-
class_name_in_module.to_s.gsub(/^.*::/, '')
|
36
|
-
end
|
37
|
-
|
38
|
-
def tableize(class_name)
|
39
|
-
pluralize(underscore(class_name))
|
40
|
-
end
|
41
|
-
|
42
|
-
def classify(table_name)
|
43
|
-
camelize(singularize(table_name))
|
44
|
-
end
|
45
|
-
|
46
|
-
def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
|
47
|
-
Inflector.underscore(Inflector.demodulize(class_name)) +
|
48
|
-
(separate_class_name_and_id_with_underscore ? "_id" : "id")
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
def plural_rules #:doc:
|
53
|
-
[
|
54
|
-
[/(x|ch|ss|sh)$/, '\1es'], # search, switch, fix, box, process, address
|
55
|
-
[/([^aeiouy]|qu)ies$/, '\1y'],
|
56
|
-
[/([^aeiouy]|qu)y$/, '\1ies'], # query, ability, agency
|
57
|
-
[/(?:([^f])fe|([lr])f)$/, '\1\2ves'], # half, safe, wife
|
58
|
-
[/sis$/, 'ses'], # basis, diagnosis
|
59
|
-
[/([ti])um$/, '\1a'], # datum, medium
|
60
|
-
[/person$/, 'people'], # person, salesperson
|
61
|
-
[/man$/, 'men'], # man, woman, spokesman
|
62
|
-
[/child$/, 'children'], # child
|
63
|
-
[/s$/, 's'], # no change (compatibility)
|
64
|
-
[/$/, 's']
|
65
|
-
]
|
66
|
-
end
|
67
|
-
|
68
|
-
def singular_rules #:doc:
|
69
|
-
[
|
70
|
-
[/(x|ch|ss)es$/, '\1'],
|
71
|
-
[/movies$/, 'movie'],
|
72
|
-
[/([^aeiouy]|qu)ies$/, '\1y'],
|
73
|
-
[/([lr])ves$/, '\1f'],
|
74
|
-
[/([^f])ves$/, '\1fe'],
|
75
|
-
[/(analy|ba|diagno|parenthe|progno|synop|the)ses$/, '\1sis'],
|
76
|
-
[/([ti])a$/, '\1um'],
|
77
|
-
[/people$/, 'person'],
|
78
|
-
[/men$/, 'man'],
|
79
|
-
[/status$/, 'status'],
|
80
|
-
[/children$/, 'child'],
|
81
|
-
[/s$/, '']
|
82
|
-
]
|
83
|
-
end
|
84
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# Extends the module object with module and instance accessors for class attributes,
|
2
|
-
# just like the native attr* accessors for instance attributes.
|
3
|
-
class Module # :nodoc:
|
4
|
-
def mattr_reader(*syms)
|
5
|
-
syms.each do |sym|
|
6
|
-
class_eval <<-EOS
|
7
|
-
if ! defined? @@#{sym.id2name}
|
8
|
-
@@#{sym.id2name} = nil
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.#{sym.id2name}
|
12
|
-
@@#{sym}
|
13
|
-
end
|
14
|
-
|
15
|
-
def #{sym.id2name}
|
16
|
-
@@#{sym}
|
17
|
-
end
|
18
|
-
|
19
|
-
def call_#{sym.id2name}
|
20
|
-
case @@#{sym.id2name}
|
21
|
-
when Symbol then send(@@#{sym})
|
22
|
-
when Proc then @@#{sym}.call(self)
|
23
|
-
when String then @@#{sym}
|
24
|
-
else nil
|
25
|
-
end
|
26
|
-
end
|
27
|
-
EOS
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def mattr_writer(*syms)
|
32
|
-
syms.each do |sym|
|
33
|
-
class_eval <<-EOS
|
34
|
-
if ! defined? @@#{sym.id2name}
|
35
|
-
@@#{sym.id2name} = nil
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.#{sym.id2name}=(obj)
|
39
|
-
@@#{sym.id2name} = obj
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.set_#{sym.id2name}(obj)
|
43
|
-
@@#{sym.id2name} = obj
|
44
|
-
end
|
45
|
-
|
46
|
-
def #{sym.id2name}=(obj)
|
47
|
-
@@#{sym} = obj
|
48
|
-
end
|
49
|
-
EOS
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def mattr_accessor(*syms)
|
54
|
-
mattr_reader(*syms)
|
55
|
-
mattr_writer(*syms)
|
56
|
-
end
|
57
|
-
end
|