Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 7ad57c4f0295d1420f1853c0b1f1802b629d5375 1 parent 8afc284
@dhh dhh authored
View
2  activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*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]
View
3  activerecord/lib/active_record/fixtures.rb
@@ -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
View
1  activerecord/test/fixtures/db_definitions/db2.drop.sql
@@ -15,4 +15,5 @@ DROP TABLE mixins;
DROP TABLE people;
DROP TABLE binaries;
DROP TABLE computers;
+DROP TABLE tasks;
View
5 activerecord/test/fixtures/db_definitions/db2.sql
@@ -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
+);
View
2  activerecord/test/fixtures/db_definitions/drop_oracle_tables.sql
@@ -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;
View
2  activerecord/test/fixtures/db_definitions/mysql.drop.sql
@@ -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;
-
View
6 activerecord/test/fixtures/db_definitions/mysql.sql
@@ -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`)
+);
View
6 activerecord/test/fixtures/db_definitions/oci.sql
@@ -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
+);
View
1  activerecord/test/fixtures/db_definitions/postgresql.drop.sql
@@ -15,4 +15,5 @@ DROP TABLE mixins;
DROP TABLE people;
DROP TABLE binaries;
DROP TABLE computers;
+DROP TABLE tasks;
View
6 activerecord/test/fixtures/db_definitions/postgresql.sql
@@ -147,3 +147,9 @@ CREATE TABLE computers (
developer integer NOT NULL
);
+CREATE TABLE taske (
+ id serial,
+ starting timestamp,
+ ending timestamp,
+ PRIMARY KEY (id)
+);
View
1  activerecord/test/fixtures/db_definitions/sqlite.drop.sql
@@ -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;
View
6 activerecord/test/fixtures/db_definitions/sqlite.sql
@@ -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
+);
+
View
3  activerecord/test/fixtures/db_definitions/sqlserver.drop.sql
@@ -14,4 +14,5 @@ DROP TABLE colnametests;
DROP TABLE mixins;
DROP TABLE people;
DROP TABLE binaries;
-DROP TABLE computers;
+DROP TABLE computers;
+DROP TABLE tasks;
View
5 activerecord/test/fixtures/db_definitions/sqlserver.sql
@@ -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
+);
View
3  activerecord/test/fixtures/task.rb
@@ -0,0 +1,3 @@
+class Task < ActiveRecord::Base
+
+end
View
7 activerecord/test/fixtures/tasks.yml
@@ -0,0 +1,7 @@
+# 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
View
12 activerecord/test/fixtures_test.rb
@@ -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|
Please sign in to comment.
Something went wrong with that request. Please try again.