mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -782,7 +782,7 @@ module ActiveRecord #:nodoc:
|
||||
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] }
|
||||
|
||||
|
||||
@@ -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 @@ end
|
||||
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)
|
||||
|
||||
3
activerecord/test/fixtures/computers.yml
vendored
3
activerecord/test/fixtures/computers.yml
vendored
@@ -1,3 +1,4 @@
|
||||
workstation:
|
||||
id: 1
|
||||
developer: 1
|
||||
developer: 1
|
||||
extendedWarranty: 1
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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` (
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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' (
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user