composite_primary_keys 7.0.13 → 7.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +615 -608
- data/lib/composite_primary_keys.rb +110 -110
- data/lib/composite_primary_keys/associations/association.rb +23 -23
- data/lib/composite_primary_keys/associations/association_scope.rb +77 -77
- data/lib/composite_primary_keys/associations/has_and_belongs_to_many_association.rb +59 -59
- data/lib/composite_primary_keys/associations/has_many_association.rb +56 -56
- data/lib/composite_primary_keys/associations/join_dependency.rb +89 -89
- data/lib/composite_primary_keys/associations/join_dependency/join_part.rb +38 -38
- data/lib/composite_primary_keys/associations/preloader/association.rb +78 -78
- data/lib/composite_primary_keys/associations/preloader/has_and_belongs_to_many.rb +46 -46
- data/lib/composite_primary_keys/attribute_methods/dirty.rb +26 -26
- data/lib/composite_primary_keys/attribute_methods/read.rb +34 -34
- data/lib/composite_primary_keys/attribute_methods/write.rb +36 -36
- data/lib/composite_primary_keys/base.rb +0 -6
- data/lib/composite_primary_keys/composite_arrays.rb +30 -30
- data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +4 -2
- data/lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb +17 -0
- data/lib/composite_primary_keys/core.rb +47 -47
- data/lib/composite_primary_keys/persistence.rb +60 -60
- data/lib/composite_primary_keys/relation.rb +56 -56
- data/lib/composite_primary_keys/relation/calculations.rb +75 -65
- data/lib/composite_primary_keys/relation/finder_methods.rb +196 -196
- data/lib/composite_primary_keys/sanitization.rb +52 -52
- data/lib/composite_primary_keys/validations/uniqueness.rb +37 -39
- data/lib/composite_primary_keys/version.rb +8 -8
- data/tasks/databases/sqlserver.rake +40 -27
- data/test/connections/databases.example.yml +18 -18
- data/test/connections/native_sqlserver/connection.rb +14 -11
- data/test/fixtures/db_definitions/mysql.sql +208 -208
- data/test/fixtures/db_definitions/postgresql.sql +210 -210
- data/test/fixtures/db_definitions/sqlite.sql +197 -197
- data/test/fixtures/db_definitions/sqlserver.drop.sql +94 -91
- data/test/fixtures/db_definitions/sqlserver.sql +232 -226
- data/test/fixtures/employee.rb +5 -5
- data/test/test_associations.rb +275 -275
- data/test/test_attributes.rb +60 -60
- data/test/test_create.rb +112 -112
- data/test/test_delete.rb +152 -148
- data/test/test_delete_all.rb +21 -21
- data/test/test_enum.rb +20 -20
- data/test/test_equal.rb +1 -1
- data/test/test_tutorial_example.rb +21 -21
- metadata +3 -2
data/test/test_delete_all.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class EmployeesGroup < ActiveRecord::Base
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
class TestValidations < ActiveSupport::TestCase
|
8
|
-
fixtures :employees
|
9
|
-
|
10
|
-
def test_delete_for_model_without_primary_key
|
11
|
-
EmployeesGroup.create(employee_id: 1, group_id: 100)
|
12
|
-
EmployeesGroup.create(employee_id: 2, group_id: 102)
|
13
|
-
EmployeesGroup.create(employee_id: 3, group_id: 103)
|
14
|
-
|
15
|
-
assert_equal(EmployeesGroup.all.size, 3)
|
16
|
-
assert_raises(ActiveRecord::StatementInvalid) {
|
17
|
-
EmployeesGroup.where(employee_id: 1).first.destroy
|
18
|
-
}
|
19
|
-
assert(EmployeesGroup.all.size == 3)
|
20
|
-
end
|
21
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
class EmployeesGroup < ActiveRecord::Base
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
class TestValidations < ActiveSupport::TestCase
|
8
|
+
fixtures :employees
|
9
|
+
|
10
|
+
def test_delete_for_model_without_primary_key
|
11
|
+
EmployeesGroup.create(employee_id: 1, group_id: 100)
|
12
|
+
EmployeesGroup.create(employee_id: 2, group_id: 102)
|
13
|
+
EmployeesGroup.create(employee_id: 3, group_id: 103)
|
14
|
+
|
15
|
+
assert_equal(EmployeesGroup.all.size, 3)
|
16
|
+
assert_raises(ActiveRecord::StatementInvalid) {
|
17
|
+
EmployeesGroup.where(employee_id: 1).first.destroy
|
18
|
+
}
|
19
|
+
assert(EmployeesGroup.all.size == 3)
|
20
|
+
end
|
21
|
+
end
|
data/test/test_enum.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestEnum < ActiveSupport::TestCase
|
4
|
-
fixtures :comments
|
5
|
-
|
6
|
-
def test_enum_was
|
7
|
-
comment = Comment.first
|
8
|
-
assert_nil comment.shown
|
9
|
-
|
10
|
-
comment.shown = :true
|
11
|
-
assert_equal 'true', comment.shown
|
12
|
-
assert_nil comment.shown_was
|
13
|
-
|
14
|
-
comment.save
|
15
|
-
|
16
|
-
comment.shown = :false
|
17
|
-
assert_equal 'false', comment.shown
|
18
|
-
assert_equal 'true', comment.shown_was
|
19
|
-
end
|
20
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
class TestEnum < ActiveSupport::TestCase
|
4
|
+
fixtures :comments
|
5
|
+
|
6
|
+
def test_enum_was
|
7
|
+
comment = Comment.first
|
8
|
+
assert_nil comment.shown
|
9
|
+
|
10
|
+
comment.shown = :true
|
11
|
+
assert_equal 'true', comment.shown
|
12
|
+
assert_nil comment.shown_was
|
13
|
+
|
14
|
+
comment.save
|
15
|
+
|
16
|
+
comment.shown = :false
|
17
|
+
assert_equal 'false', comment.shown
|
18
|
+
assert_equal 'true', comment.shown_was
|
19
|
+
end
|
20
|
+
end
|
data/test/test_equal.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestTutorialExample < ActiveSupport::TestCase
|
4
|
-
fixtures :users, :groups, :memberships, :membership_statuses
|
5
|
-
|
6
|
-
def test_membership
|
7
|
-
assert(membership = Membership.find([1, 1]), "Cannot find a membership")
|
8
|
-
assert(membership.user)
|
9
|
-
assert(membership.group)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_status
|
13
|
-
assert(membership = Membership.find([1, 1]), "Cannot find a membership")
|
14
|
-
assert(statuses = membership.statuses, "No has_many association to status")
|
15
|
-
assert_equal(membership, statuses.first.membership)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_count
|
19
|
-
assert(membership = Membership.find([1, 1]), "Cannot find a membership")
|
20
|
-
assert_equal(1, membership.statuses.count)
|
21
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
class TestTutorialExample < ActiveSupport::TestCase
|
4
|
+
fixtures :users, :groups, :memberships, :membership_statuses
|
5
|
+
|
6
|
+
def test_membership
|
7
|
+
assert(membership = Membership.find([1, 1]), "Cannot find a membership")
|
8
|
+
assert(membership.user)
|
9
|
+
assert(membership.group)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_status
|
13
|
+
assert(membership = Membership.find([1, 1]), "Cannot find a membership")
|
14
|
+
assert(statuses = membership.statuses, "No has_many association to status")
|
15
|
+
assert_equal(membership, statuses.first.membership)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_count
|
19
|
+
assert(membership = Membership.find([1, 1]), "Cannot find a membership")
|
20
|
+
assert_equal(1, membership.statuses.count)
|
21
|
+
end
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: composite_primary_keys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Savage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb
|
58
58
|
- lib/composite_primary_keys/connection_adapters/abstract_adapter.rb
|
59
59
|
- lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
|
60
|
+
- lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb
|
60
61
|
- lib/composite_primary_keys/core.rb
|
61
62
|
- lib/composite_primary_keys/dirty.rb
|
62
63
|
- lib/composite_primary_keys/fixtures.rb
|