Every repository with this icon (
Every repository with this icon (
| Description: | SQL Server 2000, 2005 and 2008 Adapter For Rails edit |
-
3 comments Created 5 months ago by metaskillsdocsxADO Might Not Work. Add ODBC database.yml ExamplefeaturexHere was my understanding and goals.
- I'd really like to not support ADO at some point in time, especially since the DBD for it is non existent anymore for DBI moving forward.
- The working version (#?) of ADO for DBI is old and I believe only works with DBI v0.1 or even v0.023 or something like that.
So when I did the adapter, I knew the versions of DBI/DBD-ODBC were not ADO friendly and they were not going to be from what I heard from the author. That said, there may only be a few needed tweaks to make those old versions of DBI work for the ADO.
All of this may be wrong info to. I'd look forward to seeing what errors happen and knowing the version numbers of the moving parts.
Comments
-
2 comments Created 3 months ago by WCWedinSELECT DISTINCT with a subquery get mangledneed-infoxQueries containing a DISTINCT clause and a subquery are mangled by the method add_order_by_for_association_limiting! in lib/active_record/sqlserver_adapter.rb at line 701. It uses an eager regular expression match as follows:
columns = sql.match(/SELECT\s+DISTINCT(.*)FROM/)[1].stripThat causes it to transform this:
SELECT DISTINCT [column] FROM [table] WHERE EXISTS (SELECT NULL FROM
[another_table])into this:
SELECT [column] FROM [table] WHERE EXISTS (SELECT NULL FROM
[another_table]) GROUP BY [column] FROM [table] WHERE EXISTS (SELECT NULLThe expected behavior is this:
SELECT [column] FROM [table] WHERE EXISTS (SELECT NULL FROM
[another_table]) GROUP BY [column]Changing the eager match to a lazy match fixes the problem:
columns = sql.match(/SELECT\s+DISTINCT(.*?)FROM/)[1].stripThis fix has not been tested for regression.
Comments
metaskills
Wed Aug 12 16:25:30 -0700 2009
| link
Well I added the change because it did not break anything. A regression test would have been ideal as it would mean this does not get removed in later version. Can you come up with one?
Unfortunately, I'm not that strong in either Ruby or Rails, and I don't have the time at the moment to dig through the test suit and figure out all of the appropriate idioms. I pretty much only discovered this bug because Redmine is affected by it; I'm more of a savvy consumer than a legit developer in that regard. That said, if I can dedicate myself to the task in the near future, I'll take a crack at it.
-
3 comments Created 3 months ago by psy-qbugx2.2.19 breaks on tables with non-ASCII chars in column namesneed-infoxAs reported via Google Group: http://groups.google.com/group/rails-sqlserver-adapter/browse_thread/thread/b8037769e73a391c
Thanks :)
RegexpError (premature end of regular expression: /([\w-]*)\s+as\s
+AnlassLektionPeriodizit t/): /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.19/ lib/active_record/connection_adapters/sqlserver_adapter.rb:1004:in
views_real_column_name' /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.19/ lib/active_record/connection_adapters/sqlserver_adapter.rb:1076:in<br/>column_definitions' /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.19/ lib/active_record/connection_adapters/sqlserver_adapter.rb:1062:in
collect' /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.19/ lib/active_record/connection_adapters/sqlserver_adapter.rb:1062:in<br/>column_definitions' /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.19/ lib/active_record/connection_adapters/sqlserver_adapter.rb:618:in
columns' /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.19/ lib/active_record/connection_adapters/sqlserver_adapter.rb:1109:in<br/>special_columns' /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.19/ lib/active_record/connection_adapters/sqlserver_adapter.rb:1113:in
repair_special_columns' /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.19/ lib/active_record/connection_adapters/sqlserver_adapter.rb:815:in<br/>select' app/models/evento/sync.rb:10:inwrite_course' app/models/course.rb:90:insync_write' app/controllers/courses_controller.rb:80:in `update'Is there any way to debug this further or is there anything else that
would help you solve this or narrow down where the problem is? We are
using:UNIXODBC 2.2.11 FreeTDS 0.82 Debian GNU/Linux 5 Rails and AR 2.3.2
Comments
metaskills
Wed Aug 12 14:32:46 -0700 2009
| link
Just getting to looking at bugs. Have you defined a regex that addresses this?
We couldn't figure out exactly why and where it failed (on the UTF-8 characters? On some UTF-8 settings?) so we simply excluded that field from the list of fields passed to the adapter. It's only a workaround, but it works for now.
I'm sorry we're not more useful in this :(
metaskills
Thu Oct 15 12:47:08 -0700 2009
| link
I'll keep this open and hopefully someone can post more info
-
4 comments Created 2 months ago by bfabryAdapter doesn't extract default values containing newlines fullyneed-infoxLine 1084 of sqlserver_adapter.rb attempts to extract the default value for a column from a string returned from the database:
match_data = ci[:default_value].match(/\A(+N?'?(.*?)'?)+\Z/)
It appears that this regex won't correctly match a default value that contains a newline, which for an older version of the adapter would cause it to crash, and for the current version to return nil. Adding m to the end of the regex so that . matches newlines fixed the crash for me
Comments
Noticed this issue is heavily related to #8. Though the fix for that will still not return the correct value if contains a newline
metaskills
Wed Sep 09 15:47:13 -0700 2009
| link
Could you contribute a patch that would?
http://github.com/bfabry/2000-2005-adapter
Fix there, but I haven't had time to get the unit tests running yet so it's a bit take-it-or-leave-it.
metaskills
Thu Oct 15 11:45:43 -0700 2009
| link
Just went to look and could not see anything in that repo??? Perhaps your data got lost from the github migration to rackspace?
-
3 comments Created about 1 month ago by penwellrROW_NUMBER based limit for 2005 and laterfeaturexAltered
add_limit_offset!to use newROW_NUMBER()method of limiting in
SQL 2005 and higherComments
metaskills
Mon Nov 02 13:23:20 -0800 2009
| link
I will be working on this at some point in time.
I saw a comment on the commit, how do you think we should handle the case when no order is applied as ROW_NUMBER required some order (which my patch uses a little hack to find the primary key of a table)
metaskills
Mon Nov 02 13:58:00 -0800 2009
| link
Good points. I'll have to thread that comment in when I get to this ROW_NUMBER() function stuff. BTW, I plan on doing that after I do all the rails 3 compatibility. So it may be awhile.
-
5 comments Created 23 days ago by SimonHohenadlLast character in nchar and nvarchar columns breaksneed-infoxHi,
I'm using:
Windows Vista SP1
SQLServer 2008 Express
Rails 2.3.4
activerecord-sqlserver-adapter (2.2.22)
dbd-odbc (0.2.4)
dbi (0.4.1)
SQL Server ODBC driver (non-native)I created the following table:
CREATE TABLE [dbo].[Region] ( [RegionID] [int] NOT NULL , [RegionDescription] [nchar] (50) NOT NULL ) ON [PRIMARY]I used this model:
class Region < ActiveRecord::Base set_table_name 'Region' set_primary_key "RegionID" endAnd these database.yml settings:
development: adapter: sqlserver mode: odbc dsn: northwind_dev username: *** password: *** host: localhostThe last character of the RegionDescription column is interpreted as binary or breaks in a way I cannot explain. See the following rails console excerpt:
>> r = Region.new => #<Region RegionID: nil, RegionDescription: nil> >> r.RegionID = 5 => 5 >> r.RegionDescription = 'Test' => "Test" >> y r --- !ruby/object:Region attributes: RegionDescription: Test RegionID: 5 attributes_cache: {} changed_attributes: RegionDescription: RegionID: new_record: true => nil >> r => #<Region RegionID: 5, RegionDescription: "Test"> >> r.save => true >> r.reload => #<Region RegionID: 5, RegionDescription: "Test \000\000..."> >> y r --- &id001 !ruby/object:Region attributes: RegionDescription: !binary | VGVzdCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIAAA RegionID: 5 attributes_cache: {} changed_attributes: {} errors: !ruby/object:ActiveRecord::Errors base: *id001 errors: {} marked_for_destruction: false new_record: false => nilI get the same problem with nvarchar columns, but only if they are full. E. g. if I have nvarchar(5) and put in 'ABCD', there is no problem. With 'ABCDE', something like 'ABCD\000\000...' is returned.
This does not happen with the SQL Server Native Client 10.0 ODBC driver. However, I experience other issues here (with ntext and nvarchar(max) columns).
Maybe I am doing something wrong or missing a workaround. I tried to google for this but couldn't find anything. Any ideas?
Thanks,
SimonComments
metaskills
Thu Oct 29 06:24:23 -0700 2009
| link
Let's see what we can do. First, the adapter has tons of tests for the "national/unicode" column types. I even use the UTF8 version of ruby ODBC and test this heavily too under 1.8/1.9. So I'm sure you are experience a local configuration issue or bug in the low level stack for the connection as you noted.
The only way I can help is if someone (perhaps you) on windows runs some tests and/or helps me understand how to install things on Windows so I too can run the tests. Can you do this? There are docs that talk about how to get the test setup going. For this bug you would want to run
autotest sqlserverto focus on our tests at this point. Perhaps you can make a contribution to the wiki on what steps you went thru on Windows to get the stack setup?
SimonHohenadl
Wed Nov 04 22:18:27 -0800 2009
| link
Thanks for the quick answer. Unfortunately, I am a bit slower to respond. :-/
I will run the tests as soon as I find some time and let you know.
SimonHohenadl
Mon Nov 09 00:11:53 -0800 2009
| link
I tried to run the tests. Couldn't get autotest to give me anything useful. Manually executing the tests gives me the following error:
C:\Program Files\ruby\lib\ruby\gems\1.8\gems\activerecord-sqlserver-adapter-2.2.22>rake test (in C:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.22) "C:/Program Files/ruby/bin/ruby.exe" -I"lib;test;test/connections/native_sqlserver_odbc;../../../rails/activerecord/test/" "C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/cases/aaaa_create_tables_test_sqlserver.rb" "test/cases/adapter_test_sqlserver.rb" "test/cases/attribute_methods_test_sqlserver.rb" "test/cases/basics_test_sqlserver.rb" "test/cases/calculations_test_sqlserver.rb" "test/cases/column_test_sqlserver.rb" "test/cases/connection_test_sqlserver.rb" "test/cases/eager_association_test_sqlserver.rb" "test/cases/execute_procedure_test_sqlserver.rb" "test/cases/inheritance_test_sqlserver.rb" "test/cases/method_scoping_test_sqlserver.rb" "test/cases/migration_test_sqlserver.rb" "test/cases/offset_and_limit_test_sqlserver.rb" "test/cases/pessimistic_locking_test_sqlserver.rb" "test/cases/query_cache_test_sqlserver.rb" "test/cases/schema_dumper_test_sqlserver.rb" "test/cases/specific_schema_test_sqlserver.rb" "test/cases/table_name_test_sqlserver.rb" "test/cases/transaction_test_sqlserver.rb" "test/cases/unicode_test_sqlserver.rb" C:/Program Files/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- cases/helper (LoadError) from C:/Program Files/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from ./test/cases/sqlserver_helper.rb:4 from C:/Program Files/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from C:/Program Files/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from ./test/cases/aaaa_create_tables_test_sqlserver.rb:2 from C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load' from C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5 from C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each' from C:/Program Files/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5 rake aborted! Command failed with status (1): ["C:/Program Files/ruby/bin/ruby.exe" -I"li...] (See full trace by running task with --trace)What's missing?
Anyway, I will describe the setup I went through in the wiki as soon as I get around to it.
I have the exact same setup but using SQLServer 2005. Same results as you pointed out in the original post. Will investigate a bit and come back.
-
:limit => 3, :offset => 5
SELECT FROM (SELECT TOP 3 FROM (SELECT TOP 8 * FROM books) AS tmp1) AS tmp2the result of this sql maybe equals this?
:limit => 3, :offset => 80000
SELECT FROM (SELECT TOP 3 FROM (SELECT TOP 80003 * FROM books) AS tmp1) AS tmp2
Comments
metaskills
Fri Nov 06 17:47:37 -0800 2009
| link
Can you detail more what this ticket is about?












If you insist on using the ADO, this adapter is tested with versions of DBI all the way down to 0.0.23 which includes ADO. This means you can run this adapter by using a config.gem of that lower DBI version which includes ADO and keep using the adapter the same way.
That said, it is really recommended that you use ODBC OR someone in the windows world steps up to the OSS community and develops a ADO DBD for the current DBI vs relying on other people. Sound bitter :) yes, most windows users do not contribute to OSS stuff, hopefully that will change, but moot since ya'll have a solid work around if you insist on using ADO.
Right now ADO is definitely an issue. Support for this may be dropped in favor of an ADO NET in-conjunction with IronRuby
For me the problem isn't which system is used, but rather finding the information needed to configure it. As a Windows user (we run a Rails intranet on Windows 2003 servers) my main problem with not using ADO is that most of the guides and documentation on the net concerning using Rails with SQL 2005, detail methods that use the ADO technique. I set up our system to use ADO because that was what all the guides (including the rubyonrails.com wiki) were telling me was the method to use.
If http://wiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServer was reinstated showing the ODBC technique instead of the ADO technique it used to show before it disappeared, then job done. Moving to ODBC wouldn't be a problem :- just ensure the documentation is there to demonstrate how to do it.