Permalink
Browse files

remove to_sql from TableDefinition

  • Loading branch information...
1 parent cd07f19 commit 1c9f7fa6e17d3b026ad6e0bc1f07a9dd47d8a360 @tenderlove tenderlove committed Mar 16, 2013
@@ -263,14 +263,6 @@ def references(*args)
end
alias :belongs_to :references
- # Returns a String whose contents are the column definitions
- # concatenated together. This string can then be prepended and appended to
- # to generate the final SQL to create the table.
- def to_sql
- viz = @base.schema_creation
- columns.map { |c| viz.accept c }.join ', '
- end
-
private
def create_column_definition(name, type)
ColumnDefinition.new name, type
@@ -189,7 +189,7 @@ def create_table(table_name, options = {})
create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE "
create_sql << "#{quote_table_name(table_name)} ("
- create_sql << td.to_sql
+ create_sql << schema_creation.accept(td)
create_sql << ") #{options[:options]}"
execute create_sql
td.indexes.each_pair { |c,o| add_index table_name, c, o }
@@ -124,6 +124,10 @@ def visit_ColumnDefinition(o)
column_sql
end
+ def visit_TableDefinition(o)
+ o.columns.map { |c| accept c }.join ', '
+ end
+
def quote_column_name(name)
@conn.quote_column_name name
end

0 comments on commit 1c9f7fa

Please sign in to comment.