Added quoting of column names for fixtures #997 [jcfischer@gmail.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1110 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 8afc284e
*SVN*
* Added quoting of column names for fixtures #997 [jcfischer@gmail.com]
* Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis]
* Fixed that benchmarking times for rendering included db runtimes #987 [skaes@web.de]
......
......@@ -347,7 +347,8 @@ def to_hash
end
def key_list
@fixture.keys.join(", ")
columns = @fixture.keys.collect{ |column_name| ActiveRecord::Base.connection.quote_column_name(column_name) }
columns.join(", ")
end
def value_list
......
......@@ -15,4 +15,5 @@ DROP TABLE mixins;
DROP TABLE people;
DROP TABLE binaries;
DROP TABLE computers;
DROP TABLE tasks;
......@@ -129,3 +129,8 @@ CREATE TABLE computers (
developer int NOT NULL
);
CREATE TABLE tasks (
id int generated by default as identity (start with +10000),
starting timestamp default NULL,
ending timestamp default NULL
);
......@@ -32,4 +32,6 @@ DROP TABLE binaries;
DROP SEQUENCE binaries_id;
DROP TABLE computers;
DROP SEQUENCE computers_id;
DROP TABLE tasks;
DROP SEQUENCE tasks_id;
EXIT;
......@@ -15,7 +15,7 @@ DROP TABLE mixins;
DROP TABLE people;
DROP TABLE binaries;
DROP TABLE computers;
DROP TABLE tasks;
DROP TABLE posts;
DROP TABLE comments;
DROP TABLE authors;
......@@ -147,3 +147,9 @@ CREATE TABLE `authors` (
`name` VARCHAR(255) NOT NULL
) TYPE=InnoDB;
CREATE TABLE `tasks` (
`id` int(11) NOT NULL auto_increment,
`starting` datetime NOT NULL default '0000-00-00 00:00:00',
`ending` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
);
......@@ -166,3 +166,9 @@ create table computers (
id integer not null primary key,
developer integer not null references developers initially deferred disable
);
create table tasks (
id integer not null primary key,
starting date default null,
ending date default null
);
......@@ -15,4 +15,5 @@ DROP TABLE mixins;
DROP TABLE people;
DROP TABLE binaries;
DROP TABLE computers;
DROP TABLE tasks;
......@@ -147,3 +147,9 @@ CREATE TABLE computers (
developer integer NOT NULL
);
CREATE TABLE taske (
id serial,
starting timestamp,
ending timestamp,
PRIMARY KEY (id)
);
......@@ -15,6 +15,7 @@ DROP TABLE mixins;
DROP TABLE people;
DROP TABLE binaries;
DROP TABLE computers;
DROP TABLE tasks;
DROP TABLE posts;
DROP TABLE comments;
DROP TABLE authors;
......@@ -134,3 +134,9 @@ CREATE TABLE 'authors' (
'name' VARCHAR(255) NOT NULL
);
CREATE TABLE 'tasks' (
'id' INTEGER NOT NULL PRIMARY KEY,
'starting' DATETIME DEFAULT NULL,
'ending' DATETIME DEFAULT NULL
);
......@@ -14,4 +14,5 @@ DROP TABLE colnametests;
DROP TABLE mixins;
DROP TABLE people;
DROP TABLE binaries;
DROP TABLE computers;
\ No newline at end of file
DROP TABLE computers;
DROP TABLE tasks;
......@@ -116,3 +116,8 @@ CREATE TABLE computers (
developer int NOT NULL
);
CREATE TABLE tasks (
id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
starting datetime default NULL,
ending datetime default NULL
);
class Task < ActiveRecord::Base
end
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first_task:
id: 1
starting: "2005-03-30 06:30:00"
ending: "2005-03-30 08:30:00"
another_task:
id: 2
......@@ -2,13 +2,14 @@
require 'fixtures/topic'
require 'fixtures/developer'
require 'fixtures/company'
require 'fixtures/task'
class FixturesTest < Test::Unit::TestCase
fixtures :topics, :developers, :accounts
fixtures :topics, :developers, :accounts, :tasks
FIXTURES = %w( accounts companies customers
developers developers_projects entrants
movies projects subscribers topics )
movies projects subscribers topics tasks )
MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-_\w]*/
def test_clean_fixtures
......@@ -46,6 +47,13 @@ def test_inserts
assert_nil(secondRow["author_email_address"])
end
def test_insert_with_datetime
topics = create_fixtures("tasks")
first = Task.find(1)
assert first
end
def test_bad_format
path = File.join(File.dirname(__FILE__), 'fixtures', 'bad_fixtures')
Dir.entries(path).each do |file|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册