adapter_extensions 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -13,4 +13,7 @@
13
13
  0.3.0 - March 8, 2007
14
14
  * PostgreSQL adapter included
15
15
  * Added tests for bulk loading
16
- * bulk_load method now handles table missing and file missing as error cases
16
+ * bulk_load method now handles table missing and file missing as error cases
17
+
18
+ 0.3.1 - May 4, 2007
19
+ * Added support for modifying SELECT statements to add an INSERT INTO.
@@ -18,6 +18,19 @@ module ActiveRecord #:nodoc:
18
18
  do_bulk_load(file, table_name, options)
19
19
  end
20
20
 
21
+ # SQL select into statement constructs a new table from the results
22
+ # of a select. It is used to select data from a table and create a new
23
+ # table with its result set at the same time. Note that this method
24
+ # name does not necessarily match the implementation. E.g. MySQL's
25
+ # version of this is 'CREATE TABLE ... AS SELECT ...'
26
+ def support_select_into_table?
27
+ false
28
+ end
29
+
30
+ def add_select_into_table(new_table_name, sql_query)
31
+ raise NotImplementedError, "add_select_into_table is an abstract method"
32
+ end
33
+
21
34
  protected
22
35
 
23
36
  # for subclasses to implement
@@ -4,6 +4,15 @@ module ActiveRecord #:nodoc:
4
4
  # Adds new functionality to ActiveRecord MysqlAdapter.
5
5
  class MysqlAdapter < AbstractAdapter
6
6
 
7
+ def support_select_into_table?
8
+ true
9
+ end
10
+
11
+ # Inserts an INTO table_name clause to the sql_query.
12
+ def add_select_into_table(new_table_name, sql_query)
13
+ "CREATE TABLE #{new_table_name} " + sql_query
14
+ end
15
+
7
16
  protected
8
17
  # Call +bulk_load+, as that method wraps this method.
9
18
  #
@@ -3,6 +3,15 @@ module ActiveRecord #:nodoc:
3
3
  module ConnectionAdapters #:nodoc:
4
4
  # Adds new functionality to ActiveRecord SQLServerAdapter.
5
5
  class SQLServerAdapter < AbstractAdapter
6
+ def support_select_into_table?
7
+ true
8
+ end
9
+
10
+ # Inserts an INTO table_name clause to the sql_query.
11
+ def add_select_into_table(new_table_name, sql_query)
12
+ sql_query.sub(/FROM/i, "INTO #{new_table_name} FROM")
13
+ end
14
+
6
15
  protected
7
16
  # Call +bulk_load+, as that method wraps this method.
8
17
  #
@@ -16,7 +25,7 @@ module ActiveRecord #:nodoc:
16
25
  # * <tt>:delimited_by</tt> -- The field delimiter
17
26
  # * <tt>:enclosed_by</tt> -- The field enclosure
18
27
  def do_bulk_load(file, table_name, options={})
19
- env_name = attrs[:env] || RAILS_ENV
28
+ env_name = options[:env] || RAILS_ENV
20
29
  config = ActiveRecord::Base.configurations[env_name]
21
30
  puts "Loading table \"#{table_name}\" from file \"#{filename}\""
22
31
  cmd = "bcp \"#{config['database']}.dbo.#{table_name}\" in " +
@@ -3,7 +3,7 @@ module AdapterExtensions#:nodoc:
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 0
5
5
  MINOR = 3
6
- TINY = 0
6
+ TINY = 1
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0.10
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: adapter_extensions
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.0
7
- date: 2007-03-08 00:00:00 -05:00
6
+ version: 0.3.1
7
+ date: 2007-05-04 00:00:00 -04:00
8
8
  summary: Extensions to Rails ActiveRecord adapters.
9
9
  require_paths:
10
10
  - lib
@@ -34,13 +34,13 @@ files:
34
34
  - LICENSE
35
35
  - Rakefile
36
36
  - lib/adapter_extensions
37
- - lib/adapter_extensions.rb
38
37
  - lib/adapter_extensions/connection_adapters
39
- - lib/adapter_extensions/version.rb
40
38
  - lib/adapter_extensions/connection_adapters/abstract_adapter.rb
41
39
  - lib/adapter_extensions/connection_adapters/mysql_adapter.rb
42
40
  - lib/adapter_extensions/connection_adapters/postgresql_adapter.rb
43
41
  - lib/adapter_extensions/connection_adapters/sqlserver_adapter.rb
42
+ - lib/adapter_extensions/version.rb
43
+ - lib/adapter_extensions.rb
44
44
  test_files: []
45
45
 
46
46
  rdoc_options: