Permalink
Browse files

[dm-migrations] Changed to use DataObjectsAdapter#select instead of #…

…query
  • Loading branch information...
1 parent 900d088 commit 25193c90c6586515c1341c10e246a2d3166d3e86 @dkubb dkubb committed Oct 6, 2009
View
2 lib/dm-migrations/migration.rb
@@ -177,7 +177,7 @@ def migration_info_table_exists?
# Fetch the record for this migration out of the migration_info table
def migration_record
return [] unless migration_info_table_exists?
- @adapter.query("SELECT #{migration_name_column} FROM #{migration_info_table} WHERE #{migration_name_column} = #{quoted_name}")
+ @adapter.select("SELECT #{migration_name_column} FROM #{migration_info_table} WHERE #{migration_name_column} = #{quoted_name}")
end
# True if the migration needs to be run
View
2 lib/dm-migrations/sql/mysql.rb
@@ -36,7 +36,7 @@ def property_schema_statement(connection, schema)
class Table
def initialize(adapter, table_name)
@columns = []
- adapter.query_table(table_name).each do |col_struct|
+ adapter.table_info(table_name).each do |col_struct|
@columns << SQL::Mysql::Column.new(col_struct)
end
end
View
4 lib/dm-migrations/sql/postgresql.rb
@@ -48,10 +48,10 @@ def initialize(adapter, table_name)
end
def query_column_constraints
- @adapter.query(
+ @adapter.select(
"SELECT * FROM information_schema.table_constraints WHERE table_name='#{@name}' AND table_schema=current_schema()"
).each do |table_constraint|
- @adapter.query(
+ @adapter.select(
"SELECT * FROM information_schema.constraint_column_usage WHERE constraint_name='#{table_constraint.constraint_name}' AND table_schema=current_schema()"
).each do |constrained_column|
@columns.each do |column|
View
2 lib/dm-migrations/sql/sqlite3.rb
@@ -28,7 +28,7 @@ def supports_serial?
class Table < SQL::Table
def initialize(adapter, table_name)
@columns = []
- adapter.query_table(table_name).each do |col_struct|
+ adapter.table_info(table_name).each do |col_struct|
@columns << SQL::Sqlite3::Column.new(col_struct)
end
end
View
4 lib/spec/example/migration_example_group.rb
@@ -58,8 +58,8 @@ def this_migration
@@migrations.select { |m| m.name.to_s == migration_name }.first
end
- def query(sql)
- this_migration.adapter.query(sql)
+ def select(sql)
+ this_migration.adapter.select(sql)
end
def table(table_name)
View
4 spec/unit/migration_spec.rb
@@ -375,15 +375,15 @@
describe '#migration_record' do
it 'should query for the migration' do
- @adapter.should_receive(:query).with(
+ @adapter.should_receive(:select).with(
%Q{SELECT 'migration_name' FROM 'migration_info' WHERE 'migration_name' = 'do_nothing'}
)
@m.migration_record
end
it 'should not try to query if the table does not exist' do
@m.stub!(:migration_info_table_exists?).and_return(false)
- @adapter.should_not_receive(:query)
+ @adapter.should_not_receive(:select)
@m.migration_record
end
View
2 spec/unit/sql/postgresql_spec.rb
@@ -32,7 +32,7 @@ class PostgresqlExtension
before do
@cs1 = mock('Column Struct')
@cs2 = mock('Column Struct')
- @adapter = mock('adapter', :query => [])
+ @adapter = mock('adapter', :select => [])
@adapter.stub!(:query_table).with('users').and_return([@cs1, @cs2])
@col1 = mock('SQLite3 Column')
View
4 spec/unit/sql/sqlite3_extensions_spec.rb
@@ -43,7 +43,7 @@ class Sqlite3Extension
@cs1 = mock('Column Struct')
@cs2 = mock('Column Struct')
@adapter = mock('adapter')
- @adapter.stub!(:query_table).with('users').and_return([@cs1, @cs2])
+ @adapter.stub!(:table_info).with('users').and_return([@cs1, @cs2])
@col1 = mock('SQLite3 Column')
@col2 = mock('SQLite3 Column')
@@ -52,7 +52,7 @@ class Sqlite3Extension
it 'should initialize columns by querying the table' do
SQL::Sqlite3::Column.should_receive(:new).with(@cs1).and_return(@col1)
SQL::Sqlite3::Column.should_receive(:new).with(@cs2).and_return(@col2)
- @adapter.should_receive(:query_table).with('users').and_return([@cs1,@cs2])
+ @adapter.should_receive(:table_info).with('users').and_return([@cs1,@cs2])
SQL::Sqlite3::Table.new(@adapter, 'users')
end

0 comments on commit 25193c9

Please sign in to comment.