rails-sqlserver-2000-2005-adapter 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG ADDED
@@ -0,0 +1,25 @@
1
+
2
+ sqlserver_adapter.rb -- ActiveRecord adapter for Microsoft SQL Server
3
+
4
+ Author: Joey Gibson <joey@joeygibson.com>
5
+ Date: 10/14/2004
6
+
7
+ Modifications: DeLynn Berry <delynnb@megastarfinancial.com>
8
+ Date: 3/22/2005
9
+
10
+ Modifications (ODBC): Mark Imbriaco <mark.imbriaco@pobox.com>
11
+ Date: 6/26/2005
12
+
13
+ Modifications (Migrations): Tom Ward <tom@popdog.net>
14
+ Date: 27/10/2005
15
+
16
+ Modifications (Numerous fixes as maintainer): Ryan Tomayko <rtomayko@gmail.com>
17
+ Date: Up to July 2006
18
+
19
+ Previous maintainer: Tom Ward <tom@popdog.net>
20
+
21
+
22
+
23
+
24
+
25
+ Current (interim/unofficial) maintainer: Shawn Balestracci <shawn@vegantech.com>
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
File without changes
@@ -0,0 +1,60 @@
1
+ == Creating the test database
2
+
3
+ The default names for the test databases are "activerecord_unittest" and
4
+ "activerecord_unittest2". If you want to use another database name then be sure
5
+ to update the connection adapter setups you want to test with in
6
+ test/connections/<your database>/connection.rb.
7
+
8
+
9
+ == Requirements
10
+
11
+ The following gems need to be installed. Make sure you have gems.github.com as a
12
+ source. http://github.com/blog/97-github-loves-rubygems-1-2
13
+
14
+ * gem install thoughbot-shoulda
15
+ * gem install mocha
16
+
17
+ The tests of this adapter depend on the existence of rails checkout. All the tests
18
+ defined by rails are re-used. For this to work the following directory structure
19
+ is assumed to exist:
20
+
21
+ #{RAILS_ROOT}/vendor/plugins/adapters/sqlserver
22
+ #{RAILS_ROOT}/vendor/rails/activerecord/test
23
+
24
+ Define a user named 'rails' in SQL Server with all privileges granted. Use an empty
25
+ password for user 'rails', or alternatively use the OSQLPASSWORD environment variable
26
+ which allows you to set a default password for the current session.
27
+
28
+ Then run "rake create_databases".
29
+
30
+
31
+ == Running with Rake
32
+
33
+ The easiest way to run the unit tests is through Rake. Either run "rake test_sqlserver"
34
+ or "rake test_sqlserver_odbc". For more information, checkout the full array
35
+ of rake tasks with "rake -T"
36
+
37
+ Rake can be found at http://rake.rubyforge.org
38
+
39
+
40
+ == Running with Autotest
41
+
42
+ Using autotest is easy, just run "autotest" and the tests will run continually in the
43
+ same order as the rake test command. By default autotest will use ODBC connection. If
44
+ you want to change this you can edit the autotest/sqlserver.rb file and set odbc_mode
45
+ to false.
46
+
47
+ Lastly, you can run autotest on just the adapter specific tests with "autotest sqlserver".
48
+ This will continuously run ONLY the SQL Sever specific behavior tests which are much
49
+ quicker to run than the entire active record test suite.
50
+
51
+
52
+ == Running by hand
53
+
54
+ Unit tests are located in test directory. If you only want to run a single test suite,
55
+ you can do so with:
56
+
57
+ rake test_sqlserver TEST=base_test.rb
58
+
59
+ That'll run the base suite using the SQLServer-Ruby adapter.
60
+
data/Rakefile ADDED
@@ -0,0 +1,95 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/packagetask'
5
+ require 'rake/gempackagetask'
6
+ require 'rake/contrib/rubyforgepublisher'
7
+
8
+ PKG_NAME = 'activerecord-sqlserver-adapter'
9
+ PKG_BUILD = (".#{ENV['PKG_BUILD']}" if ENV['PKG_BUILD'])
10
+ PKG_VERSION = "1.0.0.314#{PKG_BUILD}"
11
+
12
+ spec = Gem::Specification.new do |s|
13
+ s.name = PKG_NAME
14
+ s.summary = 'SQL Server adapter for Active Record - ABR'
15
+ s.version = PKG_VERSION
16
+
17
+ s.add_dependency 'activerecord', '>= 1.15.5.7843'
18
+ s.require_path = 'lib'
19
+
20
+ s.files = %w(lib/active_record/connection_adapters/sqlserver_adapter.rb)
21
+
22
+ s.author = 'Tom Ward'
23
+ s.email = 'tom@popdog.net'
24
+ s.homepage = 'http://wiki.rubyonrails.org/rails/pages/SQL+Server'
25
+ s.rubyforge_project = 'activerecord'
26
+ end
27
+
28
+ Rake::GemPackageTask.new(spec) do |p|
29
+ p.gem_spec = spec
30
+ p.need_tar = true
31
+ p.need_zip = true
32
+ end
33
+
34
+ desc "Publish the beta gem"
35
+ task :pgem => :package do
36
+ Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_NAME}-#{PKG_VERSION}.gem").upload
37
+ `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
38
+ end
39
+
40
+ desc "Publish the release files to RubyForge."
41
+ task :release => :package do
42
+ require 'rubyforge'
43
+
44
+ packages = %w(gem tgz zip).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
45
+
46
+ rubyforge = RubyForge.new
47
+ rubyforge.login
48
+ rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
49
+ end
50
+
51
+ desc 'Create the SQL Server test databases'
52
+ task :create_databases do
53
+ # Define a user named 'rails' in SQL Server with all privileges granted
54
+ # Use an empty password for user 'rails', or alternatively use the OSQLPASSWORD environment variable
55
+ # which allows you to set a default password for the current session.
56
+ %x( osql -S localhost -U rails -Q "create database activerecord_unittest" -P )
57
+ %x( osql -S localhost -U rails -Q "create database activerecord_unittest2" -P )
58
+ %x( osql -S localhost -U rails -d activerecord_unittest -Q "exec sp_grantdbaccess 'rails'" -P )
59
+ %x( osql -S localhost -U rails -d activerecord_unittest2 -Q "exec sp_grantdbaccess 'rails'" -P )
60
+ %x( osql -S localhost -U rails -d activerecord_unittest -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
61
+ %x( osql -S localhost -U rails -d activerecord_unittest2 -Q "grant BACKUP DATABASE, BACKUP LOG, CREATE DEFAULT, CREATE FUNCTION, CREATE PROCEDURE, CREATE RULE, CREATE TABLE, CREATE VIEW to 'rails';" -P )
62
+ end
63
+
64
+ desc 'Drop the SQL Server test databases'
65
+ task :drop_databases do
66
+ %x( osql -S localhost -U rails -Q "drop database activerecord_unittest" -P )
67
+ %x( osql -S localhost -U rails -Q "drop database activerecord_unittest2" -P )
68
+ end
69
+
70
+ desc 'Recreate the SQL Server test databases'
71
+ task :recreate_databases => [:drop_databases, :create_databases]
72
+
73
+
74
+ for adapter in %w( sqlserver sqlserver_odbc )
75
+ Rake::TestTask.new("test_#{adapter}") { |t|
76
+ t.libs << "test"
77
+ t.libs << "test/connections/native_#{adapter}"
78
+ t.libs << "../../../rails/activerecord/test/"
79
+ t.test_files = (
80
+ Dir.glob("test/cases/**/*_test_sqlserver.rb").sort +
81
+ Dir.glob("../../../rails/activerecord/test/**/*_test.rb").sort )
82
+ t.verbose = true
83
+ }
84
+
85
+ namespace adapter do
86
+ task :test => "test_#{adapter}"
87
+ end
88
+ end
89
+
90
+
91
+ desc 'Clean existing gems out'
92
+ task :clean do
93
+ packages = %w(gem tgz zip).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
94
+ FileUtils.rm(packages, :force => true)
95
+ end
@@ -0,0 +1,4 @@
1
+
2
+ Autotest.add_discovery do
3
+ ARGV.first || 'railssqlserver'
4
+ end
@@ -0,0 +1,16 @@
1
+ require 'autotest/sqlserver'
2
+
3
+ class Autotest::Railssqlserver < Autotest::Sqlserver
4
+
5
+ def initialize
6
+ super
7
+ self.libs << "#{File::PATH_SEPARATOR}../../../rails/activerecord/test/"
8
+ self.extra_files = ['../../../rails/activerecord/test/']
9
+ self.add_mapping %r%../../../rails/activerecord/test/.*/.*_test.rb$% do |filename, _|
10
+ filename
11
+ end
12
+ end
13
+
14
+
15
+ end
16
+
@@ -0,0 +1,54 @@
1
+ require 'autotest'
2
+ require 'activesupport'
3
+
4
+ class Autotest::Sqlserver < Autotest
5
+
6
+ def initialize
7
+ super
8
+
9
+ odbc_mode = true
10
+
11
+ clear_mappings
12
+
13
+ self.libs = [
14
+ "lib",
15
+ "test",
16
+ "test/connections/native_sqlserver#{odbc_mode ? '_odbc' : ''}",
17
+ "../../../rails/activerecord/test/"
18
+ ].join(File::PATH_SEPARATOR)
19
+
20
+ @test_sqlserver_file_match = %r%^test/cases/.*_test_sqlserver\.rb$%
21
+
22
+ add_exception %r%^\./(?:autotest)%
23
+ add_exception %r%^\./(.*LICENSE|debug.log|README.*|CHANGELOG.*)$%i
24
+
25
+ # Any *_test_sqlserver file saved runs that file
26
+ self.add_mapping @test_sqlserver_file_match do |filename, matchs|
27
+ filename
28
+ end
29
+
30
+ # If any the adapter changes
31
+ # the test directory, ofcourse having _test.rb at the end, will run that test.
32
+ self.add_mapping(%r%^lib/(.*)\.rb$%) do |filename, matchs|
33
+ files_matching @test_sqlserver_file_match
34
+ end
35
+
36
+ # If any core file like the test helper, connections, fixtures, migratinos,
37
+ # and other support files, then run all matching *_test_sqlserver files.
38
+ add_mapping %r%^test/(cases/(sqlserver_helper)\.rb|connections|fixtures|migrations|schema/.*)% do
39
+ files_matching @test_sqlserver_file_match
40
+ end
41
+
42
+ end
43
+
44
+ # Have to use a custom reorder method since the normal :alpha for Autotest would put the
45
+ # files with ../ in the path before others.
46
+ def reorder(files_to_test)
47
+ ar_tests, sqlsvr_tests = files_to_test.partition { |k,v| k.starts_with?('../../../') }
48
+ ar_tests.sort! { |a,b| a[0] <=> b[0] }
49
+ sqlsvr_tests.sort! { |a,b| a[0] <=> b[0] }
50
+ sqlsvr_tests + ar_tests
51
+ end
52
+
53
+ end
54
+