Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
682e0e2
[Rails5] Initial gem change and DB support interfaces.
metaskills Jun 12, 2016
50bf4c0
[Rails5] Setup new CHANGELOG file.
metaskills Jun 12, 2016
5e35c77
[Rails5] Remove ODBC connection mode.
metaskills Jun 12, 2016
a66b506
Initial Rails v5 commit.
metaskills Jul 14, 2016
ac46eeb
Ensure connection#primary_keys checks blanks before identity check.
metaskills Aug 2, 2016
928cd79
Fix `data_source_exists?` tests on views.
metaskills Aug 2, 2016
253fbea
All strings for us fall thru as quoted nvarchar types.
metaskills Aug 2, 2016
f1e1138
Finish abstract adapter test case by passing proper type for type match.
metaskills Aug 2, 2016
d41ffc1
Fix a few deprecations.
metaskills Aug 4, 2016
2ef2e07
Fix up rake task tests with new silence/capture and deprecations.
metaskills Aug 4, 2016
21d77df
Fix sub class of max types.
metaskills Aug 5, 2016
e53125c
Pass all SQL Server type tests.
metaskills Aug 6, 2016
470e786
No more SQL Server `SchemaCache` subclass games.
metaskills Aug 7, 2016
bef27c2
Pass new schema dumper tests.
metaskills Aug 7, 2016
66ab865
Fix database_prefix tests and arel code.
metaskills Aug 7, 2016
3ddb5de
Fix column default quoting/expression and cache clear in schema state…
metaskills Aug 7, 2016
45669e5
Bundle update to v5.0.0 release.
metaskills Aug 9, 2016
e358b0f
Flip offset/limit.
metaskills Aug 9, 2016
99049eb
Test Rails v5.
metaskills Aug 9, 2016
ce05b82
[Rails5] Fix SHOWPLAN/EXPLAIN support.
metaskills Aug 10, 2016
ab0b9fd
Fix quoted id and NULL type cast.
metaskills Aug 10, 2016
a463f40
Final ONLY_SQLSERVER=1 test to pass.
metaskills Aug 11, 2016
a841d98
TODO
metaskills Aug 11, 2016
77e9d6b
Allow full test suite to run. Debug'able coerced_tests
metaskills Aug 11, 2016
99aaa7d
Misc PR feedback. Thanks @sgrif
metaskills Aug 14, 2016
a20b52f
Use ByeBug vs Pry.
metaskills Aug 20, 2016
bec007e
Ensure object saves maintains attributes for date/time types.
metaskills Aug 20, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 6 additions & 196 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,212 +1,22 @@
## v4.2.15

#### Fixed

* Removed errand puts statment from database tasks.
* Fix quoting of non-national columns.


## v4.2.14

#### Fixed

* Fix rescue constants for optional connection gems. Fixes #475.


## v4.2.13

#### Fixed

* Add to_s method to SQLServer::Type::Char::Data. Thanks @marceloeloelo.


## v4.2.12

#### Fixed

* Isolation levels not being reset on error. Fixes #469. Thanks @anthony


## v4.2.11

#### Fixed

* Undefined method `database_prefix_remote_server?' Fixes #450. Thanks @jippeholwerda
* Document two methods for avoiding N'' quoting on char/varchar columns.
* First run failure of `change_column` while dropping constraint. Fixes #420. Thanks @GrumpyRainbow @rkr090
* Rounding errors w/datetime2(0) types having no fractional seconds. Fixes #465. Thanks @alawton

#### Changed

* Supporting escape hatch for N'' quoting. Remove `#is_utf8` string check in `#_quote` method.
This duplicated strings and forced encoding which was actually wasteful.


## v4.2.10

#### Fixed

* Ensure small datetime/datetime2 fractionals are properly quoted. Fixes #457.


## v4.2.9

#### Fixed

* Conform to new data_sources interfaces. See: https://git.io/va4Fp
* The `primary_key` method falls back to Identity columns. Not the other way around. Fixes #454. Thanks @marceloeloelo
* Ensure that `execute_procedure` returns proper time zones. Fixes #449

#### Changed

* Run tests with verbose false.


## v4.2.8

#### Fixed

* Azure-Friendly Disable Referential Integrity. No more `sp_MSforeachtable` usage. Fixes #421
* Azure-Friendly DB create/drop. Fixes #442
- Create allows edition options like: MAXSIZE, EDITION, and SERVICE_OBJECTIVE.


## v4.2.7

#### Added

* Support 2008 Datatypes Using TDSVER=7.3. Fixes #433

#### Changed

* Test now use latest v0.9.5 of TinyTDS. Includes tests for `defncopy` Windows binstub.
* Make linked servers stronger. Fixes #427. Thanks @jippeholwerda
* Use proper module for the `sqlserver_connection` method. Fixes #431. Thanks @jippeholwerda
* All datetime casting using the `Time::DATE_FORMATS[:_sqlserver_*]` formats set after connection.

#### Removed

* The `SQLServer::Utils.with_sqlserver_db_date_formats` helper and `quoted_date` hacks.
* The `Quoter` value type which allowed column => type special case quoting.

#### Fixed

* Every time datatype has perfect micro/nano second handling.
* All supported datatypes dump defaults properly to schema.rb
* Partial indexes using `:where` in schema dumper. Fixes #153


## v4.2.6

#### Fixed

* Allow linked servers for table names. Fixes #426. Thanks @jippeholwerda


## v4.2.5

#### Removed

* Remove Type::Castable hacks for core type objects to force trust the DB. Allows Rails 5 attributes.

#### Fixed

* Tests for decimal scale. See Rails commit. http://git.io/vGotB
* Improve case comparision performace per column. Fixes #414
* DB rollback when reversable add_column has several options. Fixes #359
* Better column definitions for default objects. Fixes #412


## v4.2.4

#### Fixed

* Compatible with Rails 4.2.1.
* Fix schema limit reflection for char/varchar. Fixes #394.


## v4.2.3

#### Fixed

* Fix SET defaults when using Azure.
* Test insert 4-byte unicode chars.
* Make rollback transaction transcount aware for implicit error rollbacks. Fixes #390


## v4.2.2

#### Added

* DatabaseTasks support for all tasks! Uses FreeTDS `defncopy` for structure dump. Fixes #380.
* Provide class config for `use_output_inserted` (default true) for insert SQL. Fixed #381.


## v4.2.1

#### Fixed

* Guard against empty view definitions when `sb_helptext` fails silently. Fixes #337.
* Proper table/column escaping in the `change_column_null` method. Fixes #355.
* Use `send :include` for modules for 1.9 compatibility. Fixes #383.


## v4.2.0
## v5.0.0

#### Added

* New `ActiveRecord::Type` objects. See `active_record/connection_adapters/sqlserver/type` dir.
* Aliased `ActiveRecord::Type::SQLServer` to `ActiveRecord::ConnectionAdapters::SQLServer::Type`
* New `SQLServer::Utils::Name` object for decomposing and quoting SQL Server names/identifiers.
* Support for most all SQL Server types in schema statements and dumping.
* Support create table with query from relation or select statement.
* Foreign Key Support Fixes #375.
* ...

#### Changed

* The `create_database` now takes an options hash. Only key/value now is `collation`. Unknown keys just use raw values for SQL.
* Complete rewrite of our Arel visitor. Focuing on 2012 and upward so we can make FETCH happen.
* Testing enhancements.
* Guard support, check our Guardfile.
* Use `ARTest` namespace with `SQLServer` module for our helpers/objects.
* Simple 2012 schmea addition and extensive column/type_cast object tests.
* Follow Rails convention and remove varying character default limits.
* The `cs_equality_operator` is now s class configuration property only.
* The `with_identity_insert_enabled(table_name)` is now public.
* Use ActiveRecord tranasaction interface vs our own `run_with_isolation_level`.
* ...

#### Deprecated

* n/a
* ...

#### Removed

* SQL Server versions < 2012 which do not support OFFSET and FETCH. http://bit.ly/1B5Bwsd
* The `enable_default_unicode_types` option. Default to national types all the time.
* Native type configs for older DB support. Includes the following with new default value:
* native_string_database_type => `nvarchar`
* native_text_database_type => `nvarchar(max)`
* native_binary_database_type => `varbinary(max)`
* Various version and inspection methods removed. These include:
* database_version
* database_year
* product_level
* product_version
* edition
* Removed tests for old issue #164. Handled by core types now.
* The `activity_stats` method. Please put this in a gem if needed.
* We no longer use regular expressions to fix identity inserts. Use ActiveRecord or public ID insert helper.
* All auto reconnect and SQL retry logic. Got too complicated and stood in the way of AR's pool. Speed boost too.
* The adapter will no longer try to remove duplicate order by clauses. Use relation `reorder`, `unscope`, etc.
* We no longer use regular expressions to remove identity columns from updates. Now with `attributes_for_update` AR hook.
* ODBC connection mode. Not been maintained since Rails 4.0.

#### Fixed

* Default lock is now "WITH(UPDLOCK)". Fixes #368
* Better bind types & params for `sp_executesql`. Fixes #239.

#### Security

* The connection's `inspect` method no longer returns sensitive connection info. Very basic now.


* ...
31 changes: 15 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ else
require 'net/http'
require 'yaml'
spec = eval(File.read('activerecord-sqlserver-adapter.gemspec'))
version = spec.dependencies.detect{ |d|d.name == 'activerecord' }.requirement.requirements.first.last.version
major, minor, tiny = version.split('.')
uri = URI.parse "https://rubygems.org/api/v1/versions/activerecord.yaml"
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
YAML.load(http.request(Net::HTTP::Get.new(uri.request_uri)).body).select do |data|
a, b, c = data['number'].split('.')
!data['prerelease'] && major == a && (minor.nil? || minor == b)
end.first['number']
ver = spec.dependencies.detect{ |d|d.name == 'activerecord' }.requirement.requirements.first.last.version
major, minor, tiny, pre = ver.split('.')
if !pre
uri = URI.parse "https://rubygems.org/api/v1/versions/activerecord.yaml"
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
YAML.load(http.request(Net::HTTP::Get.new(uri.request_uri)).body).select do |data|
a, b, c = data['number'].split('.')
!data['prerelease'] && major == a && (minor.nil? || minor == b)
end.first['number']
else
ver
end
end
gem 'rails', git: "git://github.com/rails/rails.git", tag: "v#{version}"
end
Expand All @@ -44,15 +48,10 @@ group :tinytds do
end
end

group :odbc do
gem 'ruby-odbc'
end

group :development do
gem 'byebug'
gem 'mocha'
gem 'minitest', '< 5.3.4' # PENDING: [Rails5.x] Remove test order constraint.
gem 'minitest-spec-rails'
gem 'pry'
end

group :guard do
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '~> 4.2.0'
```

If you want to use ruby ODBC, please use the latest least. If you have any troubles installing the lower level libraries for the adapter, please consult the wiki pages for various platform installation guides. Tons of good info can be found and we ask that you contribute too!

http://wiki.github.com/rails-sqlserver/activerecord-sqlserver-adapter/platform-installation


## Contributing

Expand Down
17 changes: 0 additions & 17 deletions RUNNING_UNIT_TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ $ bundle exec rake test TEST_FILES_AR="test/cases/finder_test.rb"

The default names for the test databases are `activerecord_unittest` and `activerecord_unittest2`. If you want to use another database name then be sure to update the connection file that matches your connection method in test/connections/native_sqlserver_#{connection_method}/connection.rb. Define a user named 'rails' in SQL Server with all privileges granted for the test databases. Use an empty password for said user.

The connection files make certain assumptions. For instance, the ODBC connection assumes you have a DSN setup that matches the name of the default database names. Remember too you have to set an environment variable for the DSN of the adapter, see the connection.rb file that matches your connection mode for details.

```sql
CREATE DATABASE [activerecord_unittest];
CREATE DATABASE [activerecord_unittest2];
Expand Down Expand Up @@ -93,18 +91,6 @@ $ bundle exec rake test

## Testing Options

The Gemfile contains groups for `:tinytds` and `:odbc`. By default it will install both gems which allows you to run the full test suite in either connection mode. If for some reason any one of these is problematic or of no concern, you could always opt out of bundling either gem with something like this.

```
$ bundle install --without odbc
```

You can run different connection modes using the following rake commands. Again, the DBLIB connection mode using TinyTDS is the default test task.

```
$ bundle exec rake test:dblib
$ bundle exec rake test:odbc
```

By default, Bundler will download the Rails git repo and use the git tag that matches the dependency version in our gemspec. If you want to test another version of Rails, you can either temporarily change the :tag for Rails in the Gemfile. Likewise, you can clone the Rails repo your self to another directory and use the `RAILS_SOURCE` environment variable.

Expand All @@ -116,6 +102,3 @@ By default, Bundler will download the Rails git repo and use the git tag that ma
* Possibly change the SQL Server TCP/IP properties in "SQL Server Configuration Manager -> SQL Server Network Configuration -> Protocols for MSSQLSERVER", and ensure that TCP/IP is enabled and the appropriate entries on the "IP Addresses" tab are enabled.


## Current Expected Failures

* Misc Date/Time erros when using ODBC mode.
9 changes: 2 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ task default: [:test]

namespace :test do

%w(dblib odbc).each do |mode|
%w(dblib).each do |mode|

Rake::TestTask.new(mode) do |t|
t.libs = ARTest::SQLServer.test_load_paths
Expand All @@ -23,17 +23,12 @@ namespace :test do
ENV['ARCONN'] = 'dblib'
end

task 'odbc:env' do
ENV['ARCONN'] = 'odbc'
end

end

task 'test:dblib' => 'test:dblib:env'
task 'test:odbc' => 'test:odbc:env'

namespace :profile do
['dblib', 'odbc'].each do |mode|
['dblib'].each do |mode|
namespace mode.to_sym do
Dir.glob('test/profile/*_profile_case.rb').sort.each do |test_file|
profile_case = File.basename(test_file).sub('_profile_case.rb', '')
Expand Down
48 changes: 48 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

## SHORT TERM

Misc remidners while in the heat of adapting the adpater.

* Try removing `sp_executesql_sql_type` all together. Do we have to add more types?
* Did we get the schema cache right?



## LONG TERM

After we get some tests passing

* Is `primary_keys(table_name)` performant? Contribute to rails for abstract adapter.
* Check `sql_for_insert` can do without the table regular expresion.
* Do we need the `query_requires_identity_insert` check in `execute`?
* Will we have to add more Data types to our dates and use them in `quoted_date` or `quoted_string` or `_type_cast`?


#### Use #without_prepared_statement?

I think we always send everything thru `sp_executesql`. Consider re-evaulating if there are no `binds` that we get any benefit from this. By doing so we also give the users the ability to turn this off completly. Would be neat to see how our prepared statments actually perform again.

```ruby
def without_prepared_statement?(binds)
!prepared_statements || binds.empty?
end
```

Maybe just quick bail to `do_execute`. Maybe related:

* [Do not cache prepared statements that are unlikely to have cache hits](https://github.com/rails/rails/commit/cbcdecd2)




#### Does Find By SQL Work?

With binds and prepareable?

```ruby
# Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date]
# Post.find_by_sql ["SELECT body FROM comments WHERE author = :user_id OR approved_by = :user_id", { :user_id => user_id }]
#
def find_by_sql(sql, binds = [], preparable: nil)
result_set = connection.select_all(sanitize_sql(sql), "#{name} Load", binds, preparable: preparable)
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.15
5.0.0
2 changes: 1 addition & 1 deletion activerecord-sqlserver-adapter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']
spec.add_dependency 'activerecord', '~> 4.2.1'
spec.add_dependency 'activerecord', '~> 5.0.0'
end
Loading