@@ -59,8 +59,10 @@ defmodule Ecto.Adapters.TdsTest do
5959 defp delete_all ( query ) , do: query |> SQL . delete_all ( ) |> IO . iodata_to_binary ( )
6060 defp execute_ddl ( query ) , do: query |> SQL . execute_ddl ( ) |> Enum . map ( & IO . iodata_to_binary / 1 )
6161
62- defp insert ( prefx , table , header , rows , on_conflict , returning ) do
63- IO . iodata_to_binary ( SQL . insert ( prefx , table , header , rows , on_conflict , returning , [ ] ) )
62+ defp insert ( prefx , table , header , rows , on_conflict , returning , placeholders \\ [ ] ) do
63+ IO . iodata_to_binary (
64+ SQL . insert ( prefx , table , header , rows , on_conflict , returning , placeholders )
65+ )
6466 end
6567
6668 defp update ( prefx , table , fields , filter , returning ) do
@@ -1034,20 +1036,21 @@ defmodule Ecto.Adapters.TdsTest do
10341036 # Schema based
10351037
10361038 test "insert" do
1037- # prefx, table, header, rows, on_conflict, returning
1038- query = insert ( nil , "schema" , [ :x , :y ] , [ [ :x , :y ] ] , { :raise , [ ] , [ ] } , [ ] )
1039- assert query == ~s{ INSERT INTO [schema] ([x],[y]) VALUES (@1, @2)}
1039+ # prefx, table, header, rows, on_conflict, returning, placeholders
1040+ assert insert ( nil , "schema" , [ :x , :y ] , [ [ :x , :y ] ] , { :raise , [ ] , [ ] } , [ ] ) ==
1041+ ~s{ INSERT INTO [schema] ([x],[y]) VALUES (@1, @2)}
10401042
1041- query = insert ( nil , "schema" , [ :x , :y ] , [ [ :x , :y ] , [ nil , :y ] ] , { :raise , [ ] , [ ] } , [ :id ] )
1042-
1043- assert query ==
1043+ assert insert ( nil , "schema" , [ :x , :y ] , [ [ :x , :y ] , [ nil , :y ] ] , { :raise , [ ] , [ ] } , [ :id ] ) ==
10441044 ~s{ INSERT INTO [schema] ([x],[y]) OUTPUT INSERTED.[id] VALUES (@1, @2),(DEFAULT, @3)}
10451045
1046- query = insert ( nil , "schema" , [ ] , [ [ ] ] , { :raise , [ ] , [ ] } , [ :id ] )
1047- assert query == ~s{ INSERT INTO [schema] OUTPUT INSERTED.[id] DEFAULT VALUES}
1046+ assert insert ( nil , "schema" , [ :x , :y ] , [ [ :x , :y ] , [ nil , :y ] ] , { :raise , [ ] , [ ] } , [ :id ] , [ 1 , 2 ] ) ==
1047+ ~s{ INSERT INTO [schema] ([x],[y]) OUTPUT INSERTED.[id] VALUES (@3, @4),(DEFAULT, @5)}
1048+
1049+ assert insert ( nil , "schema" , [ ] , [ [ ] ] , { :raise , [ ] , [ ] } , [ :id ] ) ==
1050+ ~s{ INSERT INTO [schema] OUTPUT INSERTED.[id] DEFAULT VALUES}
10481051
1049- query = insert ( "prefix" , "schema" , [ ] , [ [ ] ] , { :raise , [ ] , [ ] } , [ :id ] )
1050- assert query == ~s{ INSERT INTO [prefix].[schema] OUTPUT INSERTED.[id] DEFAULT VALUES}
1052+ assert insert ( "prefix" , "schema" , [ ] , [ [ ] ] , { :raise , [ ] , [ ] } , [ :id ] ) ==
1053+ ~s{ INSERT INTO [prefix].[schema] OUTPUT INSERTED.[id] DEFAULT VALUES}
10511054 end
10521055
10531056 test "insert with query" do
0 commit comments