This project is archived and is in readonly mode.
table_name_prefix not honored under rake test
-
kenmazaika
I do not believe MySQL supports having periods in table names, because if it did queries could be ambiguous with federated tables:
mysql> create table something.test (id INT);
ERROR 1049 (42000): Unknown database 'something'
mysql> create table something_test (id INT);
Query OK, 0 rows affected (0.00 sec)I suspect this will work with other database engines though.
-ken
-
Fredrik Thuresson
kenmazaika: The period is separating the database and the table name.
Database: bogus_test, Table Name: itemsThe following worked for me in test/test_helper.rb
Replaced
@connection = class_name.connection if class_name.respond_to?(:connection) with
@connection = table_name.classify.constantize.connectionclass Fixtures
def initialize(connection, table_name, class_name, fixture_path, file_filter = DEFAULT_FILTER_RE)@connection, @table_name, @fixture_path, @file_filter = connection, table_name, fixture_path, file_filter @name = table_name # preserve fixture base name @class_name = class_name || (ActiveRecord::Base.pluralize_table_names ? @table_name.singularize.camelize : @table_name.camelize) @table_name = "#{ActiveRecord::Base.table_name_prefix}#{@table_name}#{ActiveRecord::Base.table_name_suffix}" @table_name = class_name.table_name if class_name.respond_to?(:table_name) @connection = table_name.classify.constantize.connection read_fixture_filesend end
-Fredrik
-
Fredrik Thuresson
Obviously I don't know how to format. Here is another attempt. Ignore the previous comment.
kenmazaika: The period is separating the database and the table name.
Database: bogus_test, Table Name: items
The following worked for me in test/test_helper.rbReplaced @connection = class_name.connection if class_name.respond_to?(:connection) with @connection = table_name.classify.constantize.connectionclass Fixtures def initialize(connection, table_name, class_name, fixture_path, file_filter = DEFAULT_FILTER_RE) @connection, @table_name, @fixture_path, @file_filter = connection, table_name, fixture_path, file_filter @name = table_name # preserve fixture base name @class_name = class_name || (ActiveRecord::Base.pluralize_table_names ? @table_name.singularize.camelize : @table_name.camelize) @table_name = "#{ActiveRecord::Base.table_name_prefix}#{@table_name}#{ActiveRecord::Base.table_name_suffix}" @table_name = class_name.table_name if class_name.respond_to?(:table_name) @connection = table_name.classify.constantize.connection read_fixture_files end end-Fredrik