objectid_columns 1.0.1 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA512:
3
- metadata.gz: 216e3a0b18aa9ff589f728a7ba6d95fa56ada067b51a99cff26dac0b19cb3f49cb4fa9deb2b2ae227498123bb5d8aa286aa76760eed1fbf96cfc6599dd7e423f
4
- data.tar.gz: c9a48a9b4e065da3a3b45555cf7c2acd0c3a5687c6e5cf752318934553110fed9906d7d72b4e87cef431a4df7386e5fab1001c0ffbcf4cef655b8e59f8d1a169
5
2
  SHA1:
6
- metadata.gz: 522783d13b6a7e03735ae0c8d793a545ef4926aa
7
- data.tar.gz: c69aed130528349b56f2c60effed8ca0e73213eb
3
+ data.tar.gz: a7f678bd14b88d042886baff1b5414b11deb4707
4
+ metadata.gz: e7b852e2a9fd9f1d1ca584b2cfd7e3af2cd9f03f
5
+ SHA512:
6
+ data.tar.gz: 9dd1a74b4e4923f9502f46ddded57492019f7cea242cf57ca7289174c4e37babadd0eb2ceb32a32df464cc83d7932462ead3d8ed8079e1d105524e2f6e7f10b2
7
+ metadata.gz: bf0a9bcf3f653674d3a04ddc84bd25a2127cf05465be7582baa3e62445a95993b92c52c0b83cae4822b70c2b84d74f436a81ac876a59e192310863afea6ce0ad
data/.travis.yml CHANGED
@@ -11,12 +11,15 @@ env:
11
11
  - OBJECTID_COLUMNS_AR_TEST_VERSION=3.1.12 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=mysql
12
12
  - OBJECTID_COLUMNS_AR_TEST_VERSION=3.1.12 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=postgres
13
13
  - OBJECTID_COLUMNS_AR_TEST_VERSION=3.1.12 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
14
- - OBJECTID_COLUMNS_AR_TEST_VERSION=3.2.16 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=mysql
15
- - OBJECTID_COLUMNS_AR_TEST_VERSION=3.2.16 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=postgres
16
- - OBJECTID_COLUMNS_AR_TEST_VERSION=3.2.16 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
17
- - OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.2 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=mysql
18
- - OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.2 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=postgres
19
- - OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.2 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
14
+ - OBJECTID_COLUMNS_AR_TEST_VERSION=3.2.17 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=mysql
15
+ - OBJECTID_COLUMNS_AR_TEST_VERSION=3.2.17 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=postgres
16
+ - OBJECTID_COLUMNS_AR_TEST_VERSION=3.2.17 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
17
+ - OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.4 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=mysql
18
+ - OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.4 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=postgres
19
+ - OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.4 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
20
+ - OBJECTID_COLUMNS_AR_TEST_VERSION=4.1.0 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=mysql
21
+ - OBJECTID_COLUMNS_AR_TEST_VERSION=4.1.0 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=postgres
22
+ - OBJECTID_COLUMNS_AR_TEST_VERSION=4.1.0 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
20
23
  before_script:
21
24
  - mysql -e 'create database myapp_test;'
22
25
  - psql -c 'create database myapp_test;' -U postgres
@@ -24,12 +27,18 @@ matrix:
24
27
  exclude:
25
28
  # ActiveRecord 4.x doesn't support Ruby 1.8.7
26
29
  - rvm: 1.8.7
27
- env: OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.2 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=mysql
30
+ env: OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.4 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=mysql
28
31
  - rvm: 1.8.7
29
- env: OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.2 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=postgres
32
+ env: OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.4 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=postgres
30
33
  - rvm: 1.8.7
31
- env: OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.2 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
34
+ env: OBJECTID_COLUMNS_AR_TEST_VERSION=4.0.4 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
35
+ - rvm: 1.8.7
36
+ env: OBJECTID_COLUMNS_AR_TEST_VERSION=4.1.0 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=mysql
37
+ - rvm: 1.8.7
38
+ env: OBJECTID_COLUMNS_AR_TEST_VERSION=4.1.0 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=postgres
39
+ - rvm: 1.8.7
40
+ env: OBJECTID_COLUMNS_AR_TEST_VERSION=4.1.0 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
32
41
  allow_failures:
33
42
  - env: OBJECTID_COLUMNS_AR_TEST_VERSION=3.1.12 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
34
43
  - rvm: 1.8.7
35
- env: OBJECTID_COLUMNS_AR_TEST_VERSION=3.2.16 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
44
+ env: OBJECTID_COLUMNS_AR_TEST_VERSION=3.2.17 OBJECTID_COLUMNS_TRAVIS_CI_DATABASE_TYPE=sqlite
data/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change History for ObjectidColumns
2
2
 
3
+ ### Version 1.0.2: April 14, 2014
4
+
5
+ * Fixed an issue where, if you tried to pass an ObjectID instance in a `where` clause for a column that didn't exist or wasn't on a table that declared any ObjectID columns, you could get an error from deep down in `ObjectidColumns`. (Now, you'll still get an error, but it will be the ActiveRecord error you expect, instead.)
6
+ * Rails 4.1 support.
7
+ * Bumped Travis version matrix to the latest point-releases of Rails 3.2 and 4.0.
8
+
3
9
  ### Version 1.0.1: March 7, 2014
4
10
 
5
11
  * Compatibility with the [`composite_primary_keys`](https://github.com/composite-primary-keys/composite_primary_keys)
data/README.md CHANGED
@@ -26,9 +26,10 @@ want to allow you to use either one. It will accept either one when assigning Ob
26
26
  whichever one you have loaded, (currently) preferring `BSON::ObjectId` if you have both.
27
27
 
28
28
  ObjectidColumns supports Ruby 1.8.7, 1.9.3, 2.0.0, and 2.1.0, plus JRuby 1.7.9; it supports ActiveRecord 3.0.20,
29
- 3.1.12, 3.2.16, and 4.0.2. It supports SQLite 3.x, MySQL 5.x, and PostgreSQL 8.x. (These are just the versions it's
30
- tested against; while it will not work with ActiveRecord 2.x, it is otherwise highly unlikely to be sensitive to
31
- exact ActiveRecord or Ruby versions, or type of RDBMS, and generally should work with most combinations.)
29
+ 3.1.12, 3.2.17, 4.0.4, and 4.1.0. It supports SQLite 3.x, MySQL 5.x, and PostgreSQL 8.x. (These are just the
30
+ versions it's tested against; while it will not work with ActiveRecord 2.x, it is otherwise highly unlikely to
31
+ be sensitive to exact ActiveRecord or Ruby versions, or type of RDBMS, and generally should work with most
32
+ combinations.)
32
33
 
33
34
  *Note*: If you use SQLite3 with ActiveRecord 3.1.x on MRI (_i.e._, not JRuby), or SQLite3 with ActiveRecord 3.2.x on
34
35
  MRI 1.8.7, there is a bug in the SQLite3-ActiveRecord integration that causes ObjectId primary keys to not work. (They
@@ -45,8 +45,7 @@ module ObjectidColumns
45
45
  column = if a then column_for(a) else last_column end
46
46
  relation = if a then a.relation else last_relation end
47
47
 
48
- raise "no column?!?" unless column
49
- raise "no relation?!?" unless relation
48
+ return quote(o.to_s) unless column && relation
50
49
 
51
50
  quote(bson_objectid_value_from_parameter(o, column, relation), column)
52
51
  end
@@ -77,7 +76,7 @@ that contains a BSON ObjectId value -- you're trying to use the value '#{o}'
77
76
 
78
77
  While we can find a record of some ObjectId columns being declared for
79
78
  that table, they don't appear to include #{column_name.inspect}. As such,
80
- we don't knwo whether this column should be treated as a binary or a hexadecimal
79
+ we don't know whether this column should be treated as a binary or a hexadecimal
81
80
  ObjectId, and hence don't know how to transform this value properly.}
82
81
  end
83
82
 
@@ -1,4 +1,4 @@
1
1
  # What's the current version of this gem?
2
2
  module ObjectidColumns
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
@@ -461,6 +461,23 @@ describe "ObjectidColumns basic operations" do
461
461
  expect(::Spectable.where(:perfect_s_oid => @oid2.to_binary).to_a.map(&:id)).to eq([ r2.id ])
462
462
  expect(::Spectable.where(:perfect_s_oid => [ @oid1, @oid2 ].map(&:to_binary)).to_a.map(&:id).sort).to eq([ r1.id, r2.id ].sort)
463
463
  end
464
+
465
+ it "should give a good exception if you try to pass an ObjectID for a column that isn't an official ObjectID column" do
466
+ oid = new_oid
467
+ expect { ::Spectable.where(:perfect_b_oid => oid).to_a }.to raise_error(/ObjectidColumns:.*perfect_b_oid/mi)
468
+ end
469
+
470
+ it "should not blow up (and instead let ActiveRecord blow up) if you try to pass an ObjectID for a column that isn't a column at all" do
471
+ oid = new_oid
472
+ expect { ::Spectable.where(:something => oid).to_a }.to raise_error(/something/mi)
473
+ end
474
+
475
+ it "should not blow up (and instead let ActiveRecord just find no records, or blow up) if you try to pass an ObjectID for a column on a table that isn't using this gem at all" do
476
+ define_model_class(:SpectableNondeclared, 'objectidcols_spec_table') { }
477
+ expect(::SpectableNondeclared.where(:perfect_s_oid => new_oid).to_a).to eq([ ])
478
+
479
+ expect { ::SpectableNondeclared.where(:something => new_oid).to_a }.to raise_error(/something/i)
480
+ end
464
481
  end
465
482
 
466
483
  it "should allow using any column that's long enough, including binary or string columns" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: objectid_columns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Geweke
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-03-08 00:00:00 Z
12
+ date: 2014-04-14 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord