Skip to content
This repository
Browse code

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
David Heinemeier Hansson authored April 07, 2005
2  activerecord/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Added quoting of column names for fixtures #997 [jcfischer@gmail.com]
  4
+
3 5
 * Fixed counter_sql when no records exist in database for PostgreSQL (would give error, not 0) #1039 [Caleb Tennis]
4 6
 
5 7
 * Fixed that benchmarking times for rendering included db runtimes #987 [skaes@web.de]
3  activerecord/lib/active_record/fixtures.rb
@@ -347,7 +347,8 @@ def to_hash
347 347
   end
348 348
 
349 349
   def key_list
350  
-    @fixture.keys.join(", ")
  350
+    columns = @fixture.keys.collect{ |column_name| ActiveRecord::Base.connection.quote_column_name(column_name) }
  351
+    columns.join(", ")
351 352
   end
352 353
 
353 354
   def value_list
1  activerecord/test/fixtures/db_definitions/db2.drop.sql
@@ -15,4 +15,5 @@ DROP TABLE mixins;
15 15
 DROP TABLE people;
16 16
 DROP TABLE binaries;
17 17
 DROP TABLE computers;
  18
+DROP TABLE tasks;
18 19
 
5  activerecord/test/fixtures/db_definitions/db2.sql
@@ -129,3 +129,8 @@ CREATE TABLE computers (
129 129
   developer int NOT NULL
130 130
 );
131 131
 
  132
+CREATE TABLE tasks (
  133
+  id int generated by default as identity (start with +10000),
  134
+  starting timestamp default NULL,
  135
+  ending timestamp default NULL
  136
+);
2  activerecord/test/fixtures/db_definitions/drop_oracle_tables.sql
@@ -32,4 +32,6 @@ DROP TABLE binaries;
32 32
 DROP SEQUENCE binaries_id;
33 33
 DROP TABLE computers;
34 34
 DROP SEQUENCE computers_id;
  35
+DROP TABLE tasks;
  36
+DROP SEQUENCE tasks_id;
35 37
 EXIT;
2  activerecord/test/fixtures/db_definitions/mysql.drop.sql
@@ -15,7 +15,7 @@ DROP TABLE mixins;
15 15
 DROP TABLE people;
16 16
 DROP TABLE binaries;
17 17
 DROP TABLE computers;
  18
+DROP TABLE tasks;
18 19
 DROP TABLE posts;
19 20
 DROP TABLE comments;
20 21
 DROP TABLE authors;
21  
-
6  activerecord/test/fixtures/db_definitions/mysql.sql
@@ -147,3 +147,9 @@ CREATE TABLE `authors` (
147 147
   `name` VARCHAR(255) NOT NULL
148 148
 ) TYPE=InnoDB;
149 149
 
  150
+CREATE TABLE `tasks` (
  151
+  `id` int(11) NOT NULL auto_increment,
  152
+  `starting` datetime NOT NULL default '0000-00-00 00:00:00',
  153
+  `ending` datetime NOT NULL default '0000-00-00 00:00:00',
  154
+  PRIMARY KEY  (`id`)
  155
+);
6  activerecord/test/fixtures/db_definitions/oci.sql
@@ -166,3 +166,9 @@ create table computers (
166 166
   id integer not null primary key,
167 167
   developer integer not null references developers initially deferred disable
168 168
 );
  169
+
  170
+create table tasks (
  171
+  id integer not null primary key,
  172
+  starting date default null,
  173
+  ending date default null
  174
+);
1  activerecord/test/fixtures/db_definitions/postgresql.drop.sql
@@ -15,4 +15,5 @@ DROP TABLE mixins;
15 15
 DROP TABLE people;
16 16
 DROP TABLE binaries;
17 17
 DROP TABLE computers;
  18
+DROP TABLE tasks;
18 19
 
6  activerecord/test/fixtures/db_definitions/postgresql.sql
@@ -147,3 +147,9 @@ CREATE TABLE computers (
147 147
   developer integer NOT NULL
148 148
 );
149 149
 
  150
+CREATE TABLE taske (
  151
+  id serial,
  152
+  starting timestamp,
  153
+  ending timestamp,
  154
+  PRIMARY KEY (id)
  155
+);
1  activerecord/test/fixtures/db_definitions/sqlite.drop.sql
@@ -15,6 +15,7 @@ DROP TABLE mixins;
15 15
 DROP TABLE people;
16 16
 DROP TABLE binaries;
17 17
 DROP TABLE computers;
  18
+DROP TABLE tasks;
18 19
 DROP TABLE posts;
19 20
 DROP TABLE comments;
20 21
 DROP TABLE authors;
6  activerecord/test/fixtures/db_definitions/sqlite.sql
@@ -134,3 +134,9 @@ CREATE TABLE 'authors' (
134 134
   'name' VARCHAR(255) NOT NULL
135 135
 );
136 136
 
  137
+CREATE TABLE 'tasks' (
  138
+  'id' INTEGER NOT NULL PRIMARY KEY,  
  139
+  'starting' DATETIME DEFAULT NULL,
  140
+  'ending' DATETIME DEFAULT NULL
  141
+);
  142
+
3  activerecord/test/fixtures/db_definitions/sqlserver.drop.sql
@@ -14,4 +14,5 @@ DROP TABLE colnametests;
14 14
 DROP TABLE mixins;
15 15
 DROP TABLE people;
16 16
 DROP TABLE binaries;
17  
-DROP TABLE computers;
  17
+DROP TABLE computers;
  18
+DROP TABLE tasks;
5  activerecord/test/fixtures/db_definitions/sqlserver.sql
@@ -116,3 +116,8 @@ CREATE TABLE computers (
116 116
   developer int NOT NULL
117 117
 );
118 118
 
  119
+CREATE TABLE tasks (
  120
+  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
  121
+  starting datetime default NULL,
  122
+  ending datetime default NULL
  123
+);
3  activerecord/test/fixtures/task.rb
... ...
@@ -0,0 +1,3 @@
  1
+class Task < ActiveRecord::Base
  2
+
  3
+end
7  activerecord/test/fixtures/tasks.yml
... ...
@@ -0,0 +1,7 @@
  1
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
  2
+first_task:
  3
+  id: 1
  4
+  starting: "2005-03-30 06:30:00"
  5
+  ending: "2005-03-30 08:30:00"
  6
+another_task:
  7
+  id: 2
12  activerecord/test/fixtures_test.rb
@@ -2,13 +2,14 @@
2 2
 require 'fixtures/topic'
3 3
 require 'fixtures/developer'
4 4
 require 'fixtures/company'
  5
+require 'fixtures/task'
5 6
 
6 7
 class FixturesTest < Test::Unit::TestCase
7  
-  fixtures :topics, :developers, :accounts
  8
+  fixtures :topics, :developers, :accounts, :tasks
8 9
 
9 10
   FIXTURES = %w( accounts companies customers
10 11
                  developers developers_projects entrants
11  
-                 movies projects subscribers topics )
  12
+                 movies projects subscribers topics tasks )
12 13
   MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-_\w]*/
13 14
 
14 15
   def test_clean_fixtures
@@ -46,6 +47,13 @@ def test_inserts
46 47
     assert_nil(secondRow["author_email_address"])
47 48
   end
48 49
 
  50
+  def test_insert_with_datetime
  51
+    topics = create_fixtures("tasks")
  52
+    first = Task.find(1)
  53
+    assert first
  54
+  end
  55
+
  56
+
49 57
   def test_bad_format
50 58
     path = File.join(File.dirname(__FILE__), 'fixtures', 'bad_fixtures')
51 59
     Dir.entries(path).each do |file|

0 notes on commit 7ad57c4

Please sign in to comment.
Something went wrong with that request. Please try again.