This substantial commit provides much better support for Microsoft SQL Server. Specific MSSQL subadapters were added for the ado, odbc, and jdbc adapters. Mostly the subadapters involve getting insert working properly to return the last inserted id. While making these changes I've noticed that the ado adapter has huge problems, enough so that I wouldn't recommend that anyone use it. It doesn't use a stable native connection, which means it can't work correctly with transactions. It requires a pretty ugly hack to get insert to return the id inserted. Transactions on ado now unconditionally yield nil. I thought about them raising an exception instead, but that would make the ado adapter not work well with models (without fiddling). It's possible the behavior will be changed in the future. As bad as the ado adapter is now, it's still much better than before. Before, the ado adapter would run all queries twice when fetching rows, and if you did any nonidempotent actions inside the SQL, you'd have problems (as I found out when I used the ugly hack to get insert to return the id inserted). The ado and odbc adapters now catch the native exceptions and raise Sequel::DatabaseError exceptions. Also, the behavior to handle blank identifiers has been standardized. Sequel will now assume an identifier of 'untitled' if a blank identifier is given. The shared MSSQL adapter now supports Database#tables and Database#schema, using the INFORMATION_SCHEMA views (very similarly to what was used in Sequel 2.0). Now, it also supports add_column, rename_column, set_columns_type, set_column_null, and set_column_default. The shared MSSQL's schema method doesn't include primary key info, so some of the model logic changed so that it doesn't try to set no primary key unless all schema hashes include a primary key entry. The shared MSSQL adapter now uses the datetime type instead of the timestamp type for generic datetimes, and uses bit and image for boolean and file types. It uses 0 and 1 for false and true, and no longer attempts to use IS TRUE. The odbc adapter's literal_time method has been fixed. In order to ease the connection to MSSQL servers with instances using a connection string, Sequel now will unescape URL parts. So the following now works: Sequel.connect(ado:///db?host=server%5cinstance) The ado adapter specs were removed, because the ado adapter itself doesn't really have any specific behavior that should be tested. Now that Sequel has the generic integration tests, those should be used instead. I removed the spec_ado rake task. and replaced it with a spec_firebird rake task. Here's the results for integration testing on MSSQL with each adapter: * ado: 115 examples, 42 failures * jdbc: 117 examples, 22 failures * odbc: 115 examples, 19 failures Many of the remaining failures are due to the fact that some tests try to insert values into an autoincrementing primary key field, which MSSQL doesn't allow. Those tests should be refactored unless they are explicitly testing that feature.
The integration tests can also be thought of as generic adapter specs. In my testing, I was always running both the adapter specs and the integration tests. Combining them should make my test suite run faster (especially the JRuby tests because of the startup time). Implementation is fairly simple, just assigning the adapter database constant to the integration database constant and including the integration spec files. The integration rake task stays, for backwards compatibility and because some adapters don't have adapter specs (e.g. H2 on JDBC). Combining the two is what helped me find the PostgreSQL Database#indexes problem. Finally, change the start_logging/stop_logging helper methods to a single log method that takes a block. Almost always I use the logging methods when debugging where an exception is raised, and the log method makes that a lot easier.
The website now will have 3 separate rdoc sections, one for core/model, one for adapters, and one for extensions/plugins. I think this will make the RDoc less cluttered and more approachable. The Rakefile website and website_rdoc tasks are now able to generate a fully functional local version of the site. In order for this to work, I changed all of the internal website links to relative links instead of the absolute links used previously. You can now use the Rakefile without rspec installed, though obviously you can't use the spec tasks. I refactored the Rakefile to use lambdas to reduce the amount of work done just by parsing the Rakefile, by only running code inside the tasks that need it. I removed the install_no_docs task. If anyone really wants it I can add it back. I made the .gitignore patterns absolute. I don't think this will cause any problems, and with normal usage of the sequel repository, there should be no effect. This commit changes the website task to only generate the base website, and adds a website_rdoc task to generate the 3 rdoc pages. You now need to use the website_rf task to update the sequel.rubyforge.org site. As I'm the only person that does that, I don't expect any complaints. I'm also switching the website upload to use rsync instead of scp, to improve the speed.
This commit also adds the deprec helper method to spec/core/spec_helper.rb. A few spec_core specs were previously broken because of this. I usually run the full test suite (since that is rake default task), which is why I didn't notice this earlier.
This is the first half of the merge, the merge of sequel_model into sequel will come next. I'm going this because it makes things cleaner. I've wanted to do this for a while, but it wasn't worth the minor breakage. Now that Sequel 3.0 is coming soon, it seemed like a good time. To make life easier and to allow for more flexibility, I'm adding a Sequel.require method that simplifies requiring multiple files. It also only loads files in the same directory or a subdirectory of the directory containing lib/sequel/core.rb. Sequel used to do this many moons ago, and I removed it to give users more flexibility to override stuff. I've come to the conclusion that removing it caused more problems than it solved. There have been a couple of cases during the recent refactoring where I got obscure errors because I deleted a file but still had it required somewhere, and it loaded a file in a previous gem. If people want to customize sequel, they should fork the repository or unpack the gem to make their modifications. This requires simple changes to all adapters. I hope I didn't screw anything up, but it should be easy to fix if I did. This also fixes a reference to Schema::SQL in the shared MySQL adapter.
… methods of using them This large commit was necessary because caching and STI both depended on the hook class methods. This commit refactors the plugin support to try loading plugins from sequel/plugins/plugin_name before sequel_plugin_name. It also makes the plugins code use Model::ClassMethods. This commit moves Sequel::Model constants and instance variables to sequel_model.rb, so they will be loaded before other files. This commit refactors Model. inherited because subclass.superclass == self, and to remove the hook class method and STI stuff. This commit removes the PRIVATE_HOOKS, before_update_values and before_delete. They are not needed as with the recent commits, you can just override update_values and delete in the InstanceMethods plugin submodule, do the hook stuff and then call super. Finally, this commit adds a spec_plugin rake task. It's not possible to run the specs for the plugins/extensions in the same task as the model/core specs, because the plugin specs may modify the workings of model/core, and those changes can't be a factor when running the model/core specs. All plugins and extensions are loaded and tested simultaneously, in order to make sure they all work together (currently fairly easy, as they all were available by default).
… 11/03/2008, bump version It turns out the PostgreSQL optimization for dates went too far. I should have only changed the output format specification, not the input/output specification for year/month/day ordering. It turns out this breaks the standard American date format. This is a significant enough bug that it warrants a new release, so I'm also bumping the version to 2.7.1.
Instead of just hosting the RDoc at sequel.rubyforge.org, have an actual website, based on boof's design for www.ruby-sequel.org. However, drop the Rails project and instead create a plain html site generated with a simple script, a single template, and ERB. Also, add a fifth main feature to the README, showing off the improvements coming in 2.4.0.
…ith nothing mocked After a long wait, I've finally put together an integration test suite for sequel. Currently, it only covers the examples shown in the advanced_associations.rdoc file, but hopefully now that it is here, more people will contribute real specs. The integration specs have two ways of running, one where the database is specified, and one where it is not. If the database is not specified, it uses a sqlite memory database, and addition to checking for the correct functionality, it also checks that the correct SQL is being issued to the server. If the database is specified, it uses that database and ignores the SQL (since it can be different depending on the database). This gives the best of both worlds, the ability to check that sequel works with real databases, and the ability to see what SQL sequel is actual issuing to the server when nothing is mocked. Incidently, a prototype of this test suite is what helped me discover the Database#columns bug. You can run the integration test suite with "rake integration", and configure it via the INTEGRATION_URL constant in spec_config.rb, or via the SEQUEL_INTEGRATION_URL environment variable. While here, change the MYSQL_DB and POSTGRES_DB examples in spec_config.rb to MYSQL_URL and POSTGRES_URL, as it is preferable to use the URL instead of DB constant.
For merging the READMEs, I put the model README at the bottom of the core README and used that. For merging the CHANGELOGs, I merged them manually back to 1.4.0, and copied the rest of the model CHANGELOG to the bottom of the file. Most of the Rakefile code was duplicative, but I think I got all tasks except spec_adapters. I figure few people have all 5 adapters necessary to run the adapter specs. I only have 3 of them, so I never used spec_adapters. The specs are still split up so they can be run independently. Additionally, the adapter specs are split off from the core specs, which helps if you want to put Sequel.connect lines in spec_config.rb. The only other spec changes were for path changes. There weren't conflicts merging anything else, IIRC. I hope there is no fallout from this. I haven't noticed any yet, running the specs and the test suites for all of my apps that use Sequel.
…ss filters Add the doc/*.rdoc files to the list of RDoc files
Move stats.rb file from both sequel/extra and sequel_core/extra subdirectories, place in the extra directory in the root of the repository. Move the stress tests from sequel_core/stress to extra/stress. Remove the postgres_perf.rb stress test. Remove the TODO files, since I don't plan on implementing the suggestions therein. Remove the autotest files. Remove the sequel_core/examples files. Make the clean tests delete the temporary directories created, such as pkg, rdoc, and coverage.
This should fix the problem of gems not having the correct RDoc options. The directory structure is changing so that RDoc is now stored in rdoc instead of doc/rdoc. This is because doc is now going to hold additional documentation files.
…, plus some refactoring