Browse files

Added compatibility with camelCase column names for dynamic finders #533

 [Dee.Zsombor]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1263 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent eefe4d0 commit 2bf223051effaaf08c23936aaac16df672ccc899 @dhh dhh committed Apr 30, 2005
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added compatibility with camelCase column names for dynamic finders #533 [Dee.Zsombor]
+
* Fixed extraneous comma in count() function that made it not work with joins #1156 [jarkko/Dee.Zsombor]
* Fixed incompatibility with Base#find with an array of ids that would fail when using eager loading #1186 [Alisdair McDiarmid]
View
2 activerecord/lib/active_record/base.rb
@@ -782,7 +782,7 @@ def undecorated_table_name(class_name = class_name_of_active_record_descendant(s
def method_missing(method_id, *arguments)
method_name = method_id.id2name
- if method_name =~ /find_(all_by|by)_([_a-z][_a-z\d]*)/
+ if method_name =~ /find_(all_by|by)_([_a-zA-Z]\w*)/
finder, attributes = ($1 == "all_by" ? :all : :first), $2.split("_and_")
attributes.each { |attr_name| super unless column_methods_hash[attr_name.intern] }
View
3 activerecord/test/base_test.rb
@@ -12,6 +12,7 @@ class Smarts < ActiveRecord::Base; end
class CreditCard < ActiveRecord::Base; end
class MasterCreditCard < ActiveRecord::Base; end
class Post < ActiveRecord::Base; end
+class Computer < ActiveRecord::Base; end
class LoosePerson < ActiveRecord::Base
attr_protected :credit_rating, :administrator
@@ -32,7 +33,7 @@ class TightDescendant < TightPerson
class Booleantest < ActiveRecord::Base; end
class BasicsTest < Test::Unit::TestCase
- fixtures :topics, :companies, :projects
+ fixtures :topics, :companies, :projects, :computers
def test_set_attributes
topic = Topic.find(1)
View
3 activerecord/test/fixtures/computers.yml
@@ -1,3 +1,4 @@
workstation:
id: 1
- developer: 1
+ developer: 1
+ extendedWarranty: 1
View
3 activerecord/test/fixtures/db_definitions/db2.sql
@@ -126,7 +126,8 @@ CREATE TABLE binaries (
CREATE TABLE computers (
id int generated by default as identity (start with +10000),
- developer int NOT NULL
+ developer int NOT NULL,
+ extendedWarranty int NOT NULL
);
CREATE TABLE posts (
View
3 activerecord/test/fixtures/db_definitions/mysql.sql
@@ -126,7 +126,8 @@ CREATE TABLE `binaries` (
CREATE TABLE `computers` (
`id` INTEGER NOT NULL PRIMARY KEY,
- `developer` INTEGER NOT NULL
+ `developer` INTEGER NOT NULL,
+ `extendedWarranty` INTEGER NOT NULL
) TYPE=InnoDB;
CREATE TABLE `posts` (
View
3 activerecord/test/fixtures/db_definitions/oci.sql
@@ -164,7 +164,8 @@ create table binaries (
create table computers (
id integer not null primary key,
- developer integer not null references developers initially deferred disable
+ developer integer not null references developers initially deferred disable,
+ extendedWarranty integer not null
);
create table posts (
View
3 activerecord/test/fixtures/db_definitions/postgresql.sql
@@ -144,7 +144,8 @@ CREATE TABLE binaries (
CREATE TABLE computers (
id serial,
- developer integer NOT NULL
+ developer integer NOT NULL,
+ extendedWarranty integer NOT NULL
);
CREATE TABLE posts (
View
3 activerecord/test/fixtures/db_definitions/sqlite.sql
@@ -113,7 +113,8 @@ CREATE TABLE 'binaries' (
CREATE TABLE 'computers' (
'id' INTEGER NOT NULL PRIMARY KEY,
- 'developer' INTEGER NOT NULL
+ 'developer' INTEGER NOT NULL,
+ 'extendedWarranty' INTEGER NOT NULL
);
CREATE TABLE 'posts' (
View
3 activerecord/test/fixtures/db_definitions/sqlserver.sql
@@ -113,7 +113,8 @@ CREATE TABLE binaries (
CREATE TABLE computers (
id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
- developer int NOT NULL
+ developer int NOT NULL,
+ extendedWarranty int NOT NULL
);
CREATE TABLE posts (

0 comments on commit 2bf2230

Please sign in to comment.