Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SQLServer: insert uses given primary key value if not nil rather than…

… SELECT @@IDENTITY. References #2866.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3035 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit fb1efcaf91511285a0a656621a823a97a75975b3 1 parent 415d274
@jeremy jeremy authored
View
2  activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY. #2866 [kajism@yahoo.com, Tom Ward <tom@popdog.net>]
+
* Oracle: active? and reconnect! methods for handling stale connections. Optionally retry queries after reconnect. #428 [Michael Schoen <schoenm@earthlink.net>]
* Correct documentation for Base.delete_all. #1568 [Newhydra]
View
2  activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -236,7 +236,7 @@ def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
end
log(sql, name) do
@connection.execute(sql)
- select_one("SELECT @@IDENTITY AS Ident")["Ident"]
+ id_value || select_one("SELECT @@IDENTITY AS Ident")["Ident"]
end
ensure
if ii_enabled
View
1  activerecord/test/pk_test.rb
@@ -54,6 +54,7 @@ def test_string_key
assert_equal("jdoe", subscriber.id)
subscriber.name = "John Doe"
assert_nothing_raised { subscriber.save! }
+ assert_equal("jdoe", subscriber.id)
subscriberReloaded = Subscriber.find("jdoe")
assert_equal("John Doe", subscriberReloaded.name)
Please sign in to comment.
Something went wrong with that request. Please try again.