activerecord-sqlserver-adapter 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5143ee7d732b5af4ef584e9d462d1bce08ab112
4
- data.tar.gz: f117c34a2a6ffaa6a156e3ce513e0767f2f53d21
3
+ metadata.gz: b31a0ea33247aafc00f6d836c4de3a1c76dca176
4
+ data.tar.gz: a66c59a131675c4cf381717e00e5211c4263fe7b
5
5
  SHA512:
6
- metadata.gz: 2ecdf97d6de086bbd9c2dbd0762f02c79bd190d788a947639db5cc24d10236a458936068a6259e0dcdf44f3f0924149b3472eb90e37745a1958e9c0d0ddc51b2
7
- data.tar.gz: 25de68a67a59689818cdd60ba13ba36598fff1be2b06194c68d481335c9c26af13cd8a021e6e54df677cf9d02e8a363db4b8549af0dbbf54ba408093ef38fb2e
6
+ metadata.gz: b6a8fc99daef2bbd923eb5aa7ccee8f1dcdab3dcd4b3edbda58242201ae93a4cd5bf453996a568a8af847c0f72ec230df0b06185bdc70eeb4981c184656e7bb7
7
+ data.tar.gz: 3a68c7e45dd613fc89901d61cf1ab82cd3cc02cda3f93d2f37f95ff52d3f9ea8aed0d2dad61faf552996c5355fc53a457b020f55b277f4a0f2e096eb55a83701
@@ -1,3 +1,13 @@
1
+ ## v5.0.1
2
+
3
+ #### Changed
4
+
5
+ * Set `tds_version` fallback to `7.3`.
6
+
7
+ #### Fixed
8
+
9
+ * Support 2014, 2012 drop table statement.
10
+
1
11
 
2
12
  ## v5.0.0
3
13
 
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ gemspec
3
3
 
4
4
  gem 'sqlite3'
5
5
  gem 'minitest', '< 5.3.4'
6
- gem 'bcrypt', platforms: [:mri]
6
+ gem 'bcrypt'
7
7
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
8
8
 
9
9
  if RbConfig::CONFIG["host_os"] =~ /darwin/
data/README.md CHANGED
@@ -7,95 +7,19 @@
7
7
  * [![Gem Version](http://img.shields.io/gem/v/activerecord-sqlserver-adapter.svg)](https://rubygems.org/gems/activerecord-sqlserver-adapter) - Gem Version
8
8
  * [![Gitter chat](https://img.shields.io/badge/%E2%8A%AA%20GITTER%20-JOIN%20CHAT%20%E2%86%92-brightgreen.svg?style=flat)](https://gitter.im/rails-sqlserver/activerecord-sqlserver-adapter) - Community
9
9
 
10
- ## RAILS v5 COMING!!!
11
10
 
12
- 2017-01-04 - All core adapter tests are passing on Rails v5. We have ~60 failures under the full AcitveRecord suite. At this time, the foundation of the adapter is considered to be solid and the remaining tests will not likely require any refactors of the adapter internals.
11
+ The SQL Server adapter for ActiveRecord v5.0 using SQL Server 2012 or higher.
13
12
 
14
- This means you can technically bundle to the adapter's master branch and work with Rails 5. However, but reports should not be given till we have a release and pass all ActiveRecord tests. Please follow the `RAILS5-TODO.md` and `RAILS5-FAILS.txt` notes before filing issues.
15
-
16
- * [RAILS5-TODO.md](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/master/RAILS5-TODO.md)
17
- * [RAILS5-FAILS.txt](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/master/RAILS5-FAILS.txt)
18
- * [All Rails 5.0 Issues - Closed](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues?q=label%3A%22Rails+5.0%22+is%3Aclosed)
19
- * [All Rails 5.0 Issues - Open](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/labels/Rails%205.0)
20
-
21
- * **Can I help?** - Thanks so much! Feel free to jump in. I suggest chatting on Gitter or GitHub to make sure we are not dupliating work.
22
- * **What is the ETA of an initial release?** - My guess is that we can have an initial release by mid January easily.
23
-
24
-
25
- #### Using Rails v4
26
-
27
- Use these commands to use the latest of Rails v4 till our v5 release is ready.
28
-
29
- ```shell
30
- $ gem install rails -v 4.2.7.1
31
- $ rails _4.2.7.1_ new MYAPP --database=sqlserver
32
- ```
33
-
34
- ![kantishna-wide](https://cloud.githubusercontent.com/assets/2381/5895051/aa6a57e0-a4e1-11e4-95b9-23627af5876a.jpg)
35
-
36
- ## Code Name Kantishna
37
-
38
- The SQL Server adapter for ActiveRecord v4.2 using SQL Server 2012 or higher.
39
-
40
- Interested in older versions? We follow a rational versioning policy that tracks Rails. That means that our 4.2.x version of the adapter is only for the latest 4.2 version of Rails. If you need the adapter for SQL Server 2008 or 2005, you are still in the right spot. Just install the latest 3.2.x to 4.1.x version of the adapter that matches your Rails version. We also have stable branches for each major/minor release of ActiveRecord.
41
-
42
-
43
- #### Executing Stored Procedures
44
-
45
- Every class that sub classes ActiveRecord::Base will now have an execute_procedure class method to use. This method takes the name of the stored procedure which can be a string or symbol and any number of variables to pass to the procedure. Arguments will automatically be quoted per the connection's standards as normal. For example:
46
-
47
- ```ruby
48
- Account.execute_procedure :update_totals, 'admin', nil, true
49
- # Or with named parameters.
50
- Account.execute_procedure :update_totals, named: 'params'
51
- ```
13
+ Interested in older versions? We follow a rational versioning policy that tracks Rails. That means that our 5.0.x version of the adapter is only for the latest 5.0 version of Rails. If you need the adapter for SQL Server 2008 or 2005, you are still in the right spot. Just install the latest 3.2.x to 4.1.x version of the adapter that matches your Rails version. We also have stable branches for each major/minor release of ActiveRecord.
52
14
 
53
15
 
54
16
  #### Native Data Type Support
55
17
 
56
- We support every data type supported by FreeTDS and then a few more. All simplified Rails types in migrations will coorespond to a matching SQL Server national (unicode) data type. Here is a basic chart. Always check the `initialize_native_database_types` method for an updated list.
57
-
58
- ```ruby
59
- integer: { name: 'int', limit: 4 }
60
- bigint: { name: 'bigint' }
61
- boolean: { name: 'bit' }
62
- decimal: { name: 'decimal' }
63
- money: { name: 'money' }
64
- smallmoney: { name: 'smallmoney' }
65
- float: { name: 'float' }
66
- real: { name: 'real' }
67
- date: { name: 'date' }
68
- datetime: { name: 'datetime' }
69
- datetime2: { name: 'datetime2', precision: 7 }
70
- datetimeoffset: { name: 'datetimeoffset', precision: 7 }
71
- smalldatetime: { name: 'smalldatetime' }
72
- timestamp: { name: 'datetime' }
73
- time: { name: 'time' }
74
- char: { name: 'char' }
75
- varchar: { name: 'varchar', limit: 8000 }
76
- varchar_max: { name: 'varchar(max)' }
77
- text_basic: { name: 'text' }
78
- nchar: { name: 'nchar' }
79
- string: { name: 'nvarchar', limit: 4000 }
80
- text: { name: 'nvarchar(max)' }
81
- ntext: { name: 'ntext' }
82
- binary_basic: { name: 'binary' }
83
- varbinary: { name: 'varbinary', limit: 8000 }
84
- binary: { name: 'varbinary(max)' }
85
- uuid: { name: 'uniqueidentifier' }
86
- ss_timestamp: { name: 'timestamp' }
87
- ```
88
-
89
- The following types require TDS version 7.3 with TinyTDS. This requires the latest FreeTDS v0.95 or higher.
18
+ We support every data type supported by FreeTDS. All simplified Rails types in migrations will coorespond to a matching SQL Server national (unicode) data type. Always check the `initialize_native_database_types` [(here)](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/master/lib/active_record/connection_adapters/sqlserver/schema_statements.rb#L243) for an updated list.
90
19
 
91
- * date
92
- * datetime2
93
- * datetimeoffset
94
- * time
20
+ The following types (date, datetime2, datetimeoffset, time) all require TDS version 7.3 with TinyTDS. We recommend using FreeTDS 1.0 or higher which default to using `TDSVER` to "7.3". The adapter also sets TinyTDS's `tds_version` to this as well if non is specified.
95
21
 
96
- Set `tds_version` in your database.yml or the `TDSVER` environment variable to `7.3` to ensure you are using the proper protocol version till 7.3 becomes the default.
97
-
98
- **Zone Conversion** - The `[datetimeoffset]` type is the only ActiveRecord time based datatype that does not cast the zone to ActiveRecord's default - typically UTC. As intended, this datatype is meant to maintain the zone you pass to it and/or retreived from the database.
22
+ The Rails v5 adapter supports ActiveRecord's `datetime_with_precision` setting. This means that passing `:precision` to a datetime column is supported. Using a pecision with the `:datetime` type will signal the adapter to use the `datetime2` type under the hood.
99
23
 
100
24
 
101
25
  #### Force Schema To Lowercase
@@ -138,6 +62,16 @@ module ActiveRecord
138
62
  end
139
63
  ```
140
64
 
65
+ #### Executing Stored Procedures
66
+
67
+ Every class that sub classes ActiveRecord::Base will now have an execute_procedure class method to use. This method takes the name of the stored procedure which can be a string or symbol and any number of variables to pass to the procedure. Arguments will automatically be quoted per the connection's standards as normal. For example:
68
+
69
+ ```ruby
70
+ Account.execute_procedure :update_totals, 'admin', nil, true
71
+ # Or with named parameters.
72
+ Account.execute_procedure :update_totals, named: 'params'
73
+ ```
74
+
141
75
  #### Explain Support (SHOWPLAN)
142
76
 
143
77
  The 3.2 version of the adapter support ActiveRecord's explain features. In SQL Server, this is called the showplan. By default we use the `SHOWPLAN_ALL` option and format it using a simple table printer. So the following ruby would log the plan table below it.
@@ -170,18 +104,13 @@ ActiveRecord::ConnectionAdapters::SQLServerAdapter.showplan_option = 'SHOWPLAN_X
170
104
  **NOTE:** The method we utilize to make SHOWPLANs work is very brittle to complex SQL. There is no getting around this as we have to deconstruct an already prepared statement for the sp_executesql method. If you find that explain breaks your app, simple disable it. Do not open a github issue unless you have a patch. Please [consult the Rails guides](http://guides.rubyonrails.org/active_record_querying.html#running-explain) for more info.
171
105
 
172
106
 
173
- ## Versions
174
-
175
- The adapter follows a rational versioning policy that also tracks ActiveRecord's major and minor version. That means the latest 3.1.x version of the adapter will always work for the latest 3.1.x version of ActiveRecord.
176
-
177
-
178
107
  ## Installation
179
108
 
180
109
  The adapter has no strict gem dependencies outside of ActiveRecord. You will have to pick a connection mode, the default is dblib which uses the TinyTDS gem. Just bundle the gem and the adapter will use it.
181
110
 
182
111
  ```ruby
183
112
  gem 'tiny_tds'
184
- gem 'activerecord-sqlserver-adapter', '~> 4.2.0'
113
+ gem 'activerecord-sqlserver-adapter'
185
114
  ```
186
115
 
187
116
 
@@ -199,6 +128,7 @@ Many many people have contributed. If you do not see your name here and it shoul
199
128
 
200
129
 
201
130
  ## Contributers
131
+
202
132
  Up-to-date list of contributors: http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/contributors
203
133
 
204
134
  * metaskills (Ken Collins)
@@ -221,5 +151,5 @@ Up-to-date list of contributors: http://github.com/rails-sqlserver/activerecord-
221
151
 
222
152
  ## License
223
153
 
224
- Copyright © 2008-2016. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
154
+ Copyright © 2008-2017. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
225
155
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.0
1
+ 5.0.1
@@ -12,6 +12,8 @@ install:
12
12
  - ruby --version
13
13
  - gem --version
14
14
  - bundle install
15
+ - gem uninstall bcrypt
16
+ - gem install bcrypt --platform=ruby
15
17
  build: off
16
18
  test_script:
17
19
  - powershell -File "%APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.ps1"
@@ -42,6 +42,14 @@ module ActiveRecord
42
42
  res
43
43
  end
44
44
 
45
+ def drop_table(table_name, options = {})
46
+ if options[:if_exists] && @version_year != 2016
47
+ execute "IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = #{quote(table_name)}) DROP TABLE #{quote_table_name(table_name)}"
48
+ else
49
+ super
50
+ end
51
+ end
52
+
45
53
  def indexes(table_name, name = nil)
46
54
  data = select("EXEC sp_helpindex #{quote(table_name)}", name) rescue []
47
55
  data.reduce([]) do |indexes, index|
@@ -339,6 +339,7 @@ module ActiveRecord
339
339
  dblib_connect(config)
340
340
  end
341
341
  @spid = _raw_select('SELECT @@SPID', fetch: :rows).first.first
342
+ @version_year = version_year
342
343
  configure_connection
343
344
  end
344
345
 
@@ -356,7 +357,7 @@ module ActiveRecord
356
357
  username: config[:username],
357
358
  password: config[:password],
358
359
  database: config[:database],
359
- tds_version: config[:tds_version],
360
+ tds_version: config[:tds_version] || '7.3',
360
361
  appname: config_appname(config),
361
362
  login_timeout: config_login_timeout(config),
362
363
  timeout: config_timeout(config),
@@ -415,6 +416,13 @@ module ActiveRecord
415
416
  }
416
417
  end
417
418
 
419
+ def version_year
420
+ vstring = _raw_select('SELECT @@version', fetch: :rows).first.first.to_s
421
+ /SQL Server (\d+)/.match(vstring).to_a.last.to_s.to_i
422
+ rescue Exception => e
423
+ 2016
424
+ end
425
+
418
426
  end
419
427
  end
420
428
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-sqlserver-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2017-01-16 00:00:00.000000000 Z
17
+ date: 2017-01-17 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: activerecord