@@ -200,6 +200,57 @@ public IRubyObject call(final Connection connection) throws SQLException {
200
200
});
201
201
}
202
202
203
+ /**
204
+ * Executes an INSERT SQL statement
205
+ * @param context
206
+ * @param sql
207
+ * @param pk Rails PK
208
+ * @return ActiveRecord::Result
209
+ * @throws SQLException
210
+ */
211
+ @ Override
212
+ @ JRubyMethod (name = "execute_insert_pk" , required = 2 )
213
+ public IRubyObject execute_insert_pk (final ThreadContext context , final IRubyObject sql , final IRubyObject pk ) {
214
+
215
+ // MSSQL does not like composite primary keys here so chop it if there is more than one column
216
+ IRubyObject modifiedPk = pk ;
217
+
218
+ if (pk instanceof RubyArray ) {
219
+ RubyArray ary = (RubyArray ) pk ;
220
+ if (ary .size () > 0 ) {
221
+ modifiedPk = ary .eltInternal (0 );
222
+ }
223
+ }
224
+
225
+ return super .execute_insert_pk (context , sql , modifiedPk );
226
+ }
227
+
228
+ /**
229
+ * Executes an INSERT SQL statement using a prepared statement
230
+ * @param context
231
+ * @param sql
232
+ * @param binds RubyArray of values to be bound to the query
233
+ * @param pk Rails PK
234
+ * @return ActiveRecord::Result
235
+ * @throws SQLException
236
+ */
237
+ @ Override
238
+ @ JRubyMethod (name = "execute_insert_pk" , required = 3 )
239
+ public IRubyObject execute_insert_pk (final ThreadContext context , final IRubyObject sql , final IRubyObject binds ,
240
+ final IRubyObject pk ) {
241
+ // MSSQL does not like composite primary keys here so chop it if there is more than one column
242
+ IRubyObject modifiedPk = pk ;
243
+
244
+ if (pk instanceof RubyArray ) {
245
+ RubyArray ary = (RubyArray ) pk ;
246
+ if (ary .size () > 0 ) {
247
+ modifiedPk = ary .eltInternal (0 );
248
+ }
249
+ }
250
+
251
+ return super .execute_insert_pk (context , sql , binds , modifiedPk );
252
+ }
253
+
203
254
@ Override
204
255
protected Integer jdbcTypeFor (final String type ) {
205
256
0 commit comments