@@ -1369,13 +1369,13 @@ if Code.ensure_loaded?(Tds) do
13691369 quote_name ( name ) ,
13701370 " " ,
13711371 reference_column_type ( ref . type , opts ) ,
1372- column_options ( table , name , ref . type , opts ) ,
1372+ column_options ( table , name , opts ) ,
13731373 reference_expr ( ref , table , name )
13741374 ]
13751375 end
13761376
13771377 defp column_definition ( table , { :add , name , type , opts } ) do
1378- [ quote_name ( name ) , " " , column_type ( type , opts ) , column_options ( table , name , type , opts ) ]
1378+ [ quote_name ( name ) , " " , column_type ( type , opts ) , column_options ( table , name , opts ) ]
13791379 end
13801380
13811381 defp column_changes ( statement , table , columns ) do
@@ -1396,7 +1396,7 @@ if Code.ensure_loaded?(Tds) do
13961396 quote_name ( name ) ,
13971397 " " ,
13981398 reference_column_type ( ref . type , opts ) ,
1399- column_options ( table , name , ref . type , opts ) ,
1399+ column_options ( table , name , opts ) ,
14001400 "; "
14011401 ] ,
14021402 [ statement_prefix , "ADD" , constraint_expr ( ref , table , name ) , "; " ]
@@ -1411,7 +1411,7 @@ if Code.ensure_loaded?(Tds) do
14111411 quote_name ( name ) ,
14121412 " " ,
14131413 column_type ( type , opts ) ,
1414- column_options ( table , name , type , opts ) ,
1414+ column_options ( table , name , opts ) ,
14151415 "; "
14161416 ]
14171417 ]
@@ -1430,7 +1430,7 @@ if Code.ensure_loaded?(Tds) do
14301430 quote_name ( column_name ) ,
14311431 " " ,
14321432 column_type ( type , opts ) ,
1433- column_options ( table , column_name , type , opts ) ,
1433+ column_options ( table , column_name , opts ) ,
14341434 "; "
14351435 ]
14361436 ]
@@ -1446,7 +1446,7 @@ if Code.ensure_loaded?(Tds) do
14461446 quote_name ( name ) ,
14471447 " " ,
14481448 reference_column_type ( ref . type , opts ) ,
1449- column_options ( table , name , ref . type , opts ) ,
1449+ column_options ( table , name , opts ) ,
14501450 "; "
14511451 ] ,
14521452 [ statement_prefix , "ADD" , constraint_expr ( ref , table , name ) , "; " ] ,
@@ -1467,7 +1467,7 @@ if Code.ensure_loaded?(Tds) do
14671467 " " ,
14681468 column_type ( type , opts ) ,
14691469 null_expr ( Keyword . get ( opts , :null ) ) ,
1470- collation_expr ( collation , type ) ,
1470+ collation_expr ( collation ) ,
14711471 "; "
14721472 ] ,
14731473 [ column_default_value ( statement_prefix , table , name , opts ) ]
@@ -1500,14 +1500,12 @@ if Code.ensure_loaded?(Tds) do
15001500 ]
15011501 end
15021502
1503- defp column_options ( table , name , type , opts ) do
1503+ defp column_options ( table , name , opts ) do
15041504 default = Keyword . fetch ( opts , :default )
15051505 null = Keyword . get ( opts , :null )
1506+ collation = Keyword . fetch ( opts , :collation )
15061507
1507- collation =
1508- Keyword . fetch ( opts , :collation )
1509-
1510- [ null_expr ( null ) , default_expr ( table , name , default ) , collation_expr ( collation , type ) ]
1508+ [ null_expr ( null ) , default_expr ( table , name , default ) , collation_expr ( collation ) ]
15111509 end
15121510
15131511 defp column_default_value ( statement_prefix , table , name , opts ) do
@@ -1523,12 +1521,8 @@ if Code.ensure_loaded?(Tds) do
15231521 defp null_expr ( true ) , do: [ " NULL" ]
15241522 defp null_expr ( _ ) , do: [ ]
15251523
1526- defp collation_expr ( { :ok , collation_name } , text_type )
1527- when text_type in ~w/ string char varchar nchar nvarchar text ntext/ a do
1528- " COLLATE #{ collation_name } "
1529- end
1530-
1531- defp collation_expr ( _ , _ ) , do: [ ]
1524+ defp collation_expr ( { :ok , collation_name } ) , do: " COLLATE #{ collation_name } "
1525+ defp collation_expr ( _ ) , do: [ ]
15321526
15331527 defp default_expr ( _table , _name , { :ok , nil } ) ,
15341528 do: [ ]
0 commit comments