Skip to content
Browse files

r3077@asus: jeremy | 2005-11-14 14:28:21 -0800

 Apply [3035] to stable.  SQLServer: insert uses given primary key value if not nil rather than SELECT @@IDENTITY.  Closes #2866.


git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@3037 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 49de64e commit 9decb1a46fa908fa30082cf4d9d307e6b9ba9628 @jeremy jeremy committed
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>]
+
* Correct documentation for Base.delete_all. #1568 [Newhydra]
* Oracle: test case for column default parsing. #2788 [Michael Schoen <schoenm@earthlink.net>]
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)

0 comments on commit 9decb1a

Please sign in to comment.
Something went wrong with that request. Please try again.