Permalink
Browse files

Don't use a schema when creating a temporary table

At least PostgreSQL doesn't allow schemas to be used when creating
temporary tables.
  • Loading branch information...
1 parent 40879f1 commit 1fd397626413b394bf771ea69669efc7b91c92f7 @jeremyevans committed Mar 1, 2011
Showing with 11 additions and 1 deletion.
  1. +2 −0 CHANGELOG
  2. +1 −1 lib/sequel/database/schema_methods.rb
  3. +8 −0 spec/core/database_spec.rb
View
@@ -1,5 +1,7 @@
=== HEAD
+* Don't use a schema when creating a temporary table (jeremyevans)
+
* Make migrator work correctly when a default_schema is set (jeremyevans) (#331)
=== 3.21.0 (2011-03-01)
@@ -366,7 +366,7 @@ def create_table_indexes_from_generator(name, generator, options)
# DDL statement for creating a table with the given name, columns, and options
def create_table_sql(name, generator, options)
- "CREATE #{temporary_table_sql if options[:temp]}TABLE #{quote_schema_table(name)} (#{column_list_sql(generator)})"
+ "CREATE #{temporary_table_sql if options[:temp]}TABLE #{options[:temp] ? quote_identifier(name) : quote_schema_table(name)} (#{column_list_sql(generator)})"
end
# Default index name for the table and columns, may be too long
@@ -523,6 +523,14 @@ def dataset
'CREATE UNIQUE INDEX test_tmp_name_index ON test_tmp (name)'
]
end
+
+ specify "should not use default schema when creating a temporary table" do
+ @db.default_schema = :foo
+ @db.create_table :test_tmp, :temp => true do
+ column :name, :text
+ end
+ @db.sqls.should == ['CREATE TEMPORARY TABLE test_tmp (name text)']
+ end
end
describe "Database#alter_table" do

0 comments on commit 1fd3976

Please sign in to comment.