@@ -153,7 +153,7 @@ public void AdjustCommand_InsertWithParamsInSelect_ParameterIsNotCasted_WhenColu
153153 {
154154 _driver . AdjustCommand ( cmd ) ;
155155
156- var expected = "insert into table1 (col1_select_aaa) values(@p0) from table2" ;
156+ var expected = "insert into table1 (col1_select_aaa, select_aaa, col1_select ) values(@p0, @p1, @p2 ) from table2" ;
157157 Assert . That ( cmd . CommandText , Is . EqualTo ( expected ) ) ;
158158 }
159159 }
@@ -165,11 +165,47 @@ public void AdjustCommand_InsertWithParamsInSelect_ParameterIsNotCasted_WhenColu
165165 {
166166 _driver . AdjustCommand ( cmd ) ;
167167
168- var expected = "insert into table1 (col1_where_aaa) values(@p0) from table2" ;
168+ var expected = "insert into table1 (col1_where_aaa, where_aaa, col1_where ) values(@p0, @p1, @p2 ) from table2" ;
169169 Assert . That ( cmd . CommandText , Is . EqualTo ( expected ) ) ;
170170 }
171171 }
172172
173+ [ Test ]
174+ public void AdjustCommand_ParameterWithinBetween_ParameterIsNotCasted ( )
175+ {
176+ using ( var cmd = BuildBetweenCommand ( SqlTypeFactory . GetString ( 255 ) ) )
177+ {
178+ var originalSql = cmd . CommandText ;
179+ _driver . AdjustCommand ( cmd ) ;
180+
181+ Assert . That ( cmd . CommandText , Is . EqualTo ( originalSql ) ) ;
182+ }
183+ }
184+
185+ [ Test ]
186+ public void AdjustCommand_ParameterWithinPaging_ParameterIsNotCasted ( )
187+ {
188+ using ( var cmd = BuildPagingCommand ( SqlTypeFactory . Int32 ) )
189+ {
190+ var originalSql = cmd . CommandText ;
191+ _driver . AdjustCommand ( cmd ) ;
192+
193+ Assert . That ( cmd . CommandText , Is . EqualTo ( originalSql ) ) ;
194+ }
195+ }
196+
197+ [ Test ]
198+ public void AdjustCommand_ParameterWithinIn_ParameterIsNotCasted ( )
199+ {
200+ using ( var cmd = BuildInCommand ( SqlTypeFactory . GetString ( 255 ) ) )
201+ {
202+ var originalSql = cmd . CommandText ;
203+ _driver . AdjustCommand ( cmd ) ;
204+
205+ Assert . That ( cmd . CommandText , Is . EqualTo ( originalSql ) ) ;
206+ }
207+ }
208+
173209 private DbConnection MakeConnection ( )
174210 {
175211 var result = _driver . CreateConnection ( ) ;
@@ -251,25 +287,76 @@ private DbCommand BuildInsertWithParamsInSelectCommand(SqlType paramType)
251287 private DbCommand BuildInsertWithParamsInSelectCommandWithSelectInColumnName ( SqlType paramType )
252288 {
253289 var sqlString = new SqlStringBuilder ( )
254- . Add ( "insert into table1 (col1_select_aaa) " )
290+ . Add ( "insert into table1 (col1_select_aaa, select_aaa, col1_select ) " )
255291 . Add ( "values(" )
256292 . AddParameter ( )
293+ . Add ( ", " )
294+ . AddParameter ( )
295+ . Add ( ", " )
296+ . AddParameter ( )
257297 . Add ( ") from table2" )
258298 . ToSqlString ( ) ;
259299
260- return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType } ) ;
300+ return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType , paramType , paramType } ) ;
261301 }
262302
263303 private DbCommand BuildInsertWithParamsInSelectCommandWithWhereInColumnName ( SqlType paramType )
264304 {
265305 var sqlString = new SqlStringBuilder ( )
266- . Add ( "insert into table1 (col1_where_aaa) " )
306+ . Add ( "insert into table1 (col1_where_aaa, where_aaa, col1_where ) " )
267307 . Add ( "values(" )
268308 . AddParameter ( )
309+ . Add ( ", " )
310+ . AddParameter ( )
311+ . Add ( ", " )
312+ . AddParameter ( )
269313 . Add ( ") from table2" )
270314 . ToSqlString ( ) ;
271315
272- return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType } ) ;
316+ return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType , paramType , paramType } ) ;
317+ }
318+
319+ private DbCommand BuildBetweenCommand ( SqlType paramType )
320+ {
321+ var sqlString =
322+ new SqlStringBuilder ( )
323+ . Add ( "select col1 from table where col2 between " )
324+ . AddParameter ( )
325+ . Add ( " and " )
326+ . AddParameter ( )
327+ . ToSqlString ( ) ;
328+
329+ return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType , paramType } ) ;
330+ }
331+
332+ private DbCommand BuildPagingCommand ( SqlType paramType )
333+ {
334+ var sqlString =
335+ new SqlStringBuilder ( )
336+ . Add ( "select first " )
337+ . AddParameter ( )
338+ . Add ( " skip " )
339+ . AddParameter ( )
340+ . Add ( " col1 from table" )
341+ . ToSqlString ( ) ;
342+
343+ return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType , paramType } ) ;
344+ }
345+
346+ private DbCommand BuildInCommand ( SqlType paramType )
347+ {
348+ var sqlString =
349+ new SqlStringBuilder ( )
350+ . Add ( "select col1 from table where col2 in (" )
351+ . AddParameter ( )
352+ . Add ( ", " )
353+ . AddParameter ( )
354+ . Add ( ", " )
355+ . AddParameter ( )
356+ . Add ( ")" )
357+ . ToSqlString ( ) ;
358+
359+ return _driver . GenerateCommand ( CommandType . Text , sqlString , new [ ] { paramType , paramType } ) ;
273360 }
274361 }
275362}
0 commit comments