File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed
lib/active_record/connection_adapters/sqlserver Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 77* Aliased ` ActiveRecord::Type::SQLServer ` to ` ActiveRecord::ConnectionAdapters::SQLServer::Type `
88* New ` SQLServer::Utils::Name ` object for decomposing and quoting SQL Server names/identifiers.
99* Support for most all SQL Server types in schema statements and dumping.
10- * Support create table with query from relation.
10+ * Support create table with query from relation or select statement .
1111
1212#### Changed
1313
Original file line number Diff line number Diff line change @@ -16,14 +16,9 @@ def visit_ColumnDefinition(o)
1616
1717 def visit_TableDefinition ( o )
1818 if o . as
19- visitor = o . as . connection . visitor
20- table_name = o . temporary ? "##{ o . name } " : o . name
21- select_into = "SELECT "
22- select_into << "(#{ visitor . accept ( o . as . arel . projections , Arel ::Collectors ::PlainString . new ) . value } ) "
23- select_into << "INTO "
24- select_into << "#{ quote_table_name ( table_name ) } "
25- select_into << "FROM "
26- select_into << "#{ visitor . accept ( o . as . arel . froms [ 0 ] , Arel ::Collectors ::PlainString . new ) . value } "
19+ table_name = quote_table_name ( o . temporary ? "##{ o . name } " : o . name )
20+ projections , source = @conn . to_sql ( o . as ) . match ( %r{SELECT\s +(.*)?\s +FROM\s +(.*)?} ) . captures
21+ select_into = "SELECT #{ projections } INTO #{ table_name } FROM #{ source } "
2722 else
2823 o . instance_variable_set :@as , nil
2924 super
Original file line number Diff line number Diff line change @@ -291,6 +291,16 @@ def test_take_and_first_and_last_with_integer_should_use_sql_limit_coerced
291291
292292
293293
294+ class HasOneAssociationsTest < ActiveRecord ::TestCase
295+
296+ # We use OFFSET/FETCH vs TOP. So we always have an order.
297+ coerce_tests! :test_has_one_does_not_use_order_by
298+
299+ end
300+
301+
302+
303+
294304require 'models/company'
295305class InheritanceTest < ActiveRecord ::TestCase
296306
You can’t perform that action at this time.
0 commit comments