Skip to content

Commit 96fd6d9

Browse files
committed
Merge branch '60-stable'
2 parents cd64050 + 7930006 commit 96fd6d9

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

src/java/arjdbc/jdbc/RubyJdbcConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,7 @@ protected IRubyObject dateToRuby(final ThreadContext context,
21822182
return RubyString.newString(runtime, DateTimeUtils.dateToString(value));
21832183
}
21842184

2185-
return DateTimeUtils.newDateAsTime(context, value, null).callMethod(context, "to_date");
2185+
return DateTimeUtils.newDateAsTime(context, value, DateTimeZone.UTC).callMethod(context, "to_date");
21862186
}
21872187

21882188
protected IRubyObject timeToRuby(final ThreadContext context,

src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,57 @@ public IRubyObject call(final Connection connection) throws SQLException {
200200
});
201201
}
202202

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+
203254
@Override
204255
protected Integer jdbcTypeFor(final String type) {
205256

0 commit comments

Comments
 (0)