wunderbread-ar-extensions 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. data/ChangeLog +131 -0
  2. data/README +156 -0
  3. data/Rakefile +99 -0
  4. data/config/database.yml +7 -0
  5. data/config/database.yml.template +7 -0
  6. data/config/mysql.schema +72 -0
  7. data/config/postgresql.schema +39 -0
  8. data/db/migrate/generic_schema.rb +87 -0
  9. data/db/migrate/mysql_schema.rb +31 -0
  10. data/db/migrate/oracle_schema.rb +5 -0
  11. data/db/migrate/version.rb +4 -0
  12. data/init.rb +29 -0
  13. data/lib/ar-extensions.rb +5 -0
  14. data/lib/ar-extensions/adapters/abstract_adapter.rb +146 -0
  15. data/lib/ar-extensions/adapters/jdbcmysql.rb +10 -0
  16. data/lib/ar-extensions/adapters/mysql.rb +10 -0
  17. data/lib/ar-extensions/adapters/oracle.rb +14 -0
  18. data/lib/ar-extensions/adapters/postgresql.rb +9 -0
  19. data/lib/ar-extensions/adapters/sqlite.rb +7 -0
  20. data/lib/ar-extensions/csv.rb +309 -0
  21. data/lib/ar-extensions/extensions.rb +506 -0
  22. data/lib/ar-extensions/finder_options.rb +208 -0
  23. data/lib/ar-extensions/finder_options/mysql.rb +6 -0
  24. data/lib/ar-extensions/finders.rb +95 -0
  25. data/lib/ar-extensions/foreign_keys.rb +70 -0
  26. data/lib/ar-extensions/fulltext.rb +62 -0
  27. data/lib/ar-extensions/fulltext/mysql.rb +44 -0
  28. data/lib/ar-extensions/import.rb +348 -0
  29. data/lib/ar-extensions/import/jdbcmysql.rb +5 -0
  30. data/lib/ar-extensions/import/mysql.rb +5 -0
  31. data/lib/ar-extensions/import/mysql_generic.rb +41 -0
  32. data/lib/ar-extensions/import/postgresql.rb +0 -0
  33. data/lib/ar-extensions/import/sqlite.rb +22 -0
  34. data/lib/ar-extensions/insert_select.rb +184 -0
  35. data/lib/ar-extensions/insert_select/mysql.rb +6 -0
  36. data/lib/ar-extensions/synchronize.rb +30 -0
  37. data/lib/ar-extensions/temporary_table.rb +124 -0
  38. data/lib/ar-extensions/temporary_table/mysql.rb +3 -0
  39. data/lib/ar-extensions/util/sql_generation.rb +27 -0
  40. data/lib/ar-extensions/util/support_methods.rb +43 -0
  41. data/lib/ar-extensions/version.rb +9 -0
  42. metadata +107 -0
@@ -0,0 +1,131 @@
1
+ 2009-03-16 zdennis <zach.dennis@gmail.com>
2
+
3
+ * fixed Rails 2.3.1 and 2.3.2 compatibility issue (Stephen Heuer)
4
+
5
+ 2009-02-09 zdennis <zach.dennis@gmail.com>
6
+
7
+ * fixed issue in http://zdennis.lighthouseapp.com/projects/14379/tickets/14-join-table-conditions-broken
8
+ * Updated usage of Inflector to point to ActiveSupport::Inflector
9
+ * Fixed bug where finder conditions which use arext-suffixed keys and normal field keys would fail when using a conditions hash. (Gabe da Silveira)
10
+ * added timestamps options to not automatically add timestamps even if record timestamps is disabled in ActiveRecord::Base (Thibaud Guillaume-Gentil)
11
+ * Updated to use alias_method_chain so that multiple aliased finders remain intact (Marcus Crafter)
12
+
13
+ 2007-07-20 zdennis <zdennis@dhcp-22.atomicobject.localnet>
14
+
15
+ * Added patch from Michael Flester to fix bug with created_at/updated_at fields to use proper timezone.
16
+
17
+ 2007-07-18 zdennis <zdennis@dhcp-22.atomicobject.localnet>
18
+
19
+ * Added patch for Oracle support from Michael Flester.
20
+
21
+ 2007-05-05 zdennis <zdennis@elijah.local>
22
+
23
+ * Added ActiveRecord::Base::AbstractAdapter#synchronize method which allows a mass re-synchronization of ActiveRecord instances. This is similar to ActiveRecord::Base#reload except that it works on multiple instances at a time rather then one. This sends one query for all instances rather then 1 per instance reloaded.
24
+
25
+ * Fixed bug with URI encoded strings with a workaround in the Comparison extension. ActiveRecord needs to be fixed to not use the String#% method so strings that do contains percentage signs will not fail
26
+
27
+ * Applied patch from Grant Goodale to allow the Like extension to support arrays when using the '_contains' suffix
28
+
29
+ 2007-03-14 zdennis <zdennis@elijah.xrite.com>
30
+
31
+ * Fixed a bug by renaming the alias for the ActiveRecord::Base#quote method in finders.rb. See rubyforge bug #8996
32
+
33
+ * Made a .gemspec for ar-extensions
34
+
35
+ 2007-03-13 zdennis <zdennis@elijah>
36
+
37
+ * Added :datetime searching support for better finder support.
38
+
39
+ 2007-02-11 zdennis <zdennis@admin.aries>
40
+
41
+ * Updated to_csv and import functionality to work with Sqlite, Sqlite3, PostgreSQL and MySQL
42
+
43
+ * Updated RDOC for import, to_csv, better finders, temporary tables and foreign key support
44
+
45
+ 2007-01-29 zdennis <zdennis@mktec.com>
46
+
47
+ * Added initial support for temporary tables and permanent like tables.
48
+
49
+ 2007-01-24 zdennis <zdennis@mktec.com>
50
+
51
+ * Added dependency for Mocha 0.4.0 or higher for testing
52
+
53
+ * Fixed bug for import functionality where it was never actually splitting up values correctly (thx to Mark Van Holstyn!!)
54
+
55
+ 2007-01-09 zdennis <zdennis@aries>
56
+
57
+ * Added support for embedded to_csv includes
58
+
59
+ 2007-01-07 zdennis <zdennis@aries>
60
+
61
+ * Added fix to init.rb to only load CSV functionality if FasterCSV
62
+ is available, otherwise print a message to STDERR and continue.
63
+
64
+ * Added fix to tests/boot.rb which solves fixture_path issues in
65
+ ActiveRecord 1.14.4 and earlier. The fix is included Rails trunk
66
+ and will be available in Rails 1.2.
67
+
68
+ 2007-01-05 zdennis <zdennis@aries>
69
+
70
+ * Added ActiveRecord::Extensions::VERSION module which has the following constants: MAJOR, MINOR, REVISION
71
+
72
+ * Running rake tests are now smart enough to rebuild the database if they are required based on schema_info table.
73
+
74
+ * Added schema_info table for test database schemas.
75
+
76
+ 2006-12-29 zdennis <zdennis@aries>
77
+
78
+ * Updated the Rakefile to run an external ruby process when running test files rather then in the same ruby process that runs the Rakefile
79
+
80
+ * Updated the directory structure of lib/ to solve namespace issues.
81
+
82
+ 2006-12-22 Zach Dennis <zdennis@silver.dennis.network>
83
+
84
+ * Added rake tasks for sqlite and sqlite3 databases
85
+
86
+ * Added "does_not_match" as a suffix to better finders when working with Regular Expressions
87
+
88
+ * Added "not_between" suffix to better finders when working with Ranges
89
+
90
+ 2006-12-17 zdennis <zdennis@aries>
91
+
92
+ * Added :only and :except options to to_csv method. Forcing
93
+ compatibility with http://blog.integralimpressions.com/articles/2006/09/01/tocsv-plugin
94
+
95
+ * Changed to_csv option :headers take a boolean rather then an
96
+ array of column names.
97
+
98
+ * Added rake task db:prepare_<adapter_name> to build test
99
+ database.
100
+
101
+ 2006-12-16 Zach Dennis <zdennis@silver.dennis.network>
102
+
103
+ * Added more tests for better finder support
104
+
105
+ * Added to_csv support for Arrays returned by ActiveRecord::Base.find
106
+
107
+ * Refactored ActiveRecord::Extensions::Registry to use an Array instead of hash
108
+
109
+ 2006-12-06 Zach Dennis <zdennis@silver.dennis.network>
110
+
111
+ * PostgreSQL has tested support for everything MySQL has except for Full Text Searching. This is not implemented.
112
+
113
+ * Refactored how import and full text searching implementation is handled, this is largely handled by duck typing certain method calls.
114
+
115
+ * Added generic import support for any adapter that doesn't support multi-value insert statements. This provides generic support which is guaranteed to be no slower then ActiveRecord#create.
116
+
117
+ 2006-11-23 Zach Dennis <zdennis@silver.dennis.network>
118
+
119
+ * Added finder support for PostgreSQL including Regexp Searching. (No full text searching though)
120
+
121
+ * Fixed bug in finders.rb where NULL searches were not correctly being translated into IS NULL when doing { :column => nil }
122
+
123
+ 2006-11-20 Zach Dennis <zach.dennis@gmail.com>
124
+
125
+ * Refactored core finder components out into ActiveRecord extensions
126
+
127
+ * Duck typing support for any object that is passed in to a conditions hash. ie: MyModel.find( :all, :conditions=>{ :name=>NameSearchObject.new } )
128
+
129
+ * Duck typing support for any object that is passed in as a condition. ie: MyModel.find( :all, :conditions=>SearchObject.new )
130
+
131
+
data/README ADDED
@@ -0,0 +1,156 @@
1
+ LICENSE
2
+ ----------
3
+ This is licensed under the ruby license.
4
+
5
+ Author: Zach Dennis
6
+ Web Site: http://www.continuousthinking.com/tags/arext
7
+ Email: zach.dennis@gmail.com
8
+
9
+ - For How-To information see http://www.continuousthinking.com/tags/arext
10
+ - For project information and feedback please consult http://rubyforge.org/projects/arext/
11
+ - For release information please see below
12
+
13
+ ActiveRecord::Extensions 0.8.2
14
+ ------------------------------
15
+ March 16th, 2009
16
+ - Rails 2.3.1 and 2.3.2 compatibility added
17
+ - Rails 2.1.2 and 2.2.2 compatibility preserved
18
+
19
+ AciveRecord::Extensions 0.7.0
20
+ -----------------------------
21
+ July 20th, 2007
22
+ - Fixes timezone issue (thanks Michael Flester)
23
+ - Adds better finder and import support for Oracle (thanks Michael Flester)
24
+ - Committed patch to fix MySQL query padding, thanks to Gabe da Silveira
25
+ - Added functionality for MySQL to work with created_on, created_at, updated_on or updated_at fields
26
+ - Added more test coverage for import functionality
27
+
28
+ ActiveRecord::Extensions 0.6.0
29
+ ------------------------------
30
+ May 5th, 2007
31
+ - Fixed bug with URI escaped strings and the Comparison better finder extension
32
+ - Added support for arrays with the Like better finder extension when using the '_contains' suffix
33
+ - Added 'synchronize' support for ActiveRecord::Base instances when using Import functionality
34
+
35
+ ActiveRecord::Extensions 0.5.2
36
+ ------------------------------
37
+ March 14th, 2007
38
+ - Fixed Rubyforge bug #8996 by renaming alias in finders.rb to the ActiveRecord::Base#quote method
39
+
40
+ ActiveRecord::Extensions 0.5.1
41
+ ------------------------------
42
+ March 14th, 2007
43
+ - Released as a rubygem
44
+ - Added a .gemspec file
45
+
46
+ ActiveRecord::Extensions 0.5.0
47
+ ------------------------------
48
+ March 13th, 2007
49
+ - Added Time based query support which works on ActiveRecord columns which match a type supported by :datetime
50
+
51
+ ActiveRecord::Extensions 0.4.0
52
+ ------------------------------
53
+ February 11th, 2007
54
+ - Added to_csv functionality
55
+ - Added temporary table support (MySQL)
56
+ - Added foreign key support (MySQL)
57
+ - Updated tests to keep schema information. Test database will automatically rebuild themselves if they are out of sync
58
+ - Added dependency for Mocha 0.4.0 or higher for tests
59
+
60
+ ActiveRecord::Extensions 0.3.0
61
+ ------------------------------
62
+ December 29th, 2006
63
+ - Updates to the lib/ directory structure to avoid namespace issues.
64
+ - Updates to the Rakefile to run an external ruby process for tests rather then the same
65
+ ruby process that runs the rake tasks
66
+
67
+ ActiveRecord::Extensions 0.2.0
68
+ ------------------------------
69
+ December 22nd, 2006
70
+ - Updates to_csv method for arrays returned by ActiveRecord::Base.find
71
+ - Adds does_not_match suffix for regular expression based conditions, ie: :field_does_not_match => /regex/
72
+ - Adds not_between suffix for ange based conditions, ie: :id_not_between => ( 0 .. 1 )
73
+ - Adds SQLite and SQLite3 support for better finders.
74
+ - Updates rake tasks for sqlite and sqlite3.
75
+ - Added rake tasks to use database migrations rather then raw SQL schema files.
76
+
77
+ ActiveRecord::Extensions 0.1.0
78
+ -------------------------------
79
+ December 16th, 2006
80
+ - Adds to_csv method to arrays returned by ActiveRecord::Base.find.
81
+ - Fixes bug in ActiveRecord::Extensions::Registry when processing key/value pairs where
82
+ the order of certain Extensions was not handled correctly due to Hash usage.
83
+ - Refactoring of ActiveRecord::Extensions::Registry
84
+ - Added more tests for better finder support
85
+
86
+ ActiveRecord::Extensions 0.0.6
87
+ ------------------------------
88
+ December 5th, 2006
89
+ - Added generic support for import functionality for all adapters
90
+ - Includes rake testing tasks for postgresql
91
+ - Includes postgresql support for all extensions except for full text searching (which is only mysql)
92
+ - Refactored directory structure of tests, import functionality and fulltext functionality
93
+
94
+
95
+ ActiveRecord::Extensions 0.0.5
96
+ ------------------------------
97
+ October 20th, 2006.
98
+ - Fixes two bugs which broke normal ActiveRecord behavior
99
+ - Fully complaint with Rails 1.1.0 thru 1.1.6 (and all ActiveRecord versions released with those)
100
+ - Inlcudes new Rakefile
101
+ - Includes rake task "test:mysql" which allows ActiveRecord::Extensions to be tested with mysql
102
+ - Includes rake test "test:activerecord:mysql" which allows ActiveRecord's tests to be tested with the
103
+ ActiveRecord::Extensions library
104
+
105
+
106
+ ActiveRecord::Extensions 0.0.4
107
+ -------------------------------
108
+ August 26th, 2006. Released at RubyConf*MI.
109
+ September 24th, 2006, Rubyforge release.
110
+ - Inlcudes "Better Finder" support for ActiveRecord
111
+ http://blogs.mktec.com/zdennis/pages/ARE_finders
112
+
113
+
114
+ ActiveRecord::Extensions 0.0.3
115
+ -------------------------------
116
+ Released.... ????
117
+ - the project has been named ActiveRecord::Extensions.
118
+
119
+
120
+ ActiveRecord::Optimizations 0.0.2
121
+ ---------------------------------
122
+ July 20th, 11:27pm, Zach Dennis
123
+
124
+ This includes some of the optimizations for the ActiveRecord::Base. This release only supports the MysqlAdapter, although other adapters will be supported in upcoming releases.
125
+
126
+ HOW-TO USAGE
127
+ ------------
128
+ Require the two files in the lib/ directory and then create records using:
129
+ Model.create array_of_hashes
130
+
131
+ Example:
132
+ class LogEntry < ActiveRecord::Base ; end
133
+ LogEntry.import [ { :log_entry_name=>"Name" }, {:log_entry_name=>"Name2"}, ... ], :optimize=>true
134
+
135
+ Using the optimized create method will return the number of inserts performed, rather then an array of LogEntry objects. This currently skips model validation.
136
+
137
+
138
+ CHANGELOG
139
+ ----------
140
+ 0.0.2
141
+ - add some documentation to the updated methods for ActiveRecord and MysqlAdapter
142
+ - renamed the create optimizatin to import. Multi-value inserts can be obtained using ActiveRecord::Base.import
143
+ 0.0.1
144
+ - introduced updates to ActiveRecord::Base.create to support multi-value inserts
145
+
146
+
147
+ UPCOMING
148
+ ----------
149
+ - model validation on imports
150
+ - postgresql support for imports
151
+ - ability to use regular expressions for db searches
152
+ - ability to use db functions
153
+ - temporary table support
154
+ - memory table support
155
+ - complex update with on duplicate key update support
156
+
@@ -0,0 +1,99 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |s|
8
+ s.name = %q{ar-extensions}
9
+ s.summary = %q{Extends ActiveRecord functionality.}
10
+ s.email = %q{zach.dennis@gmail.com}
11
+ s.homepage = %q{http://www.continuousthinking.com/tags/arext}
12
+ s.description = %q{Extends ActiveRecord functionality by adding better finder/query support, as well as supporting mass data import, foreign key, CSV and temporary tables}
13
+ s.require_path = 'lib'
14
+ s.has_rdoc = true
15
+ s.authors = ["Zach Dennis", "Mark Van Holstyn"]
16
+ s.files = FileList[ 'init.rb', 'db/**/*', 'Rakefile', 'ChangeLog', 'README', 'config/**/*', 'lib/**/*.rb', 'test/**/*' ]
17
+ s.rdoc_options = ["--main", "README"]
18
+ s.extra_rdoc_files = ["README"]
19
+ s.add_dependency(%q<activerecord>, [">= 2.1.2"])
20
+ end
21
+ rescue LoadError
22
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
23
+ end
24
+
25
+ DIR = File.dirname( __FILE__ )
26
+
27
+ task :default => [ "test:mysql" ]
28
+
29
+ task :boot do
30
+ require File.expand_path( File.join( DIR, 'lib', 'ar-extensions' ) )
31
+ require File.expand_path( File.join( DIR, 'tests', 'connections', "native_#{ENV['ARE_DB']}", 'connection' ) )
32
+ require File.expand_path( File.join( DIR, 'db/migrate/version' ) )
33
+ end
34
+
35
+ ADAPTERS = %w( mysql postgresql sqlite sqlite3 oracle )
36
+
37
+ namespace :db do
38
+
39
+ namespace :test do
40
+ ADAPTERS.each do |adapter|
41
+ desc "builds test database for #{adapter}"
42
+ task "prepare_#{adapter}" do |t|
43
+ file2run = File.join( DIR, 'tests/prepare.rb' )
44
+ system( "ruby #{file2run} #{adapter}" )
45
+ end
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ namespace :test do
52
+
53
+ ADAPTERS.each do |adapter|
54
+ desc "test base extensions for #{adapter}"
55
+ task adapter do |t|
56
+ ENV['ARE_DB'] = adapter
57
+
58
+ task = Rake::Task[ "db:test:prepare_#{adapter}" ]
59
+ begin
60
+ task = false if SchemaInfo::VERSION == SchemaInfo.find( :first ).version
61
+ rescue Exception => ex
62
+ end
63
+ task.invoke if task
64
+
65
+ system "ruby #{File.join( DIR, 'tests/run.rb ' )} #{adapter}"
66
+ end
67
+ end
68
+
69
+ namespace :activerecord do
70
+
71
+ ADAPTERS.each do |adapter|
72
+ desc "runs ActiveRecord unit tests for #{adapter} with ActiveRecord::Extensions"
73
+ task adapter.to_sym do |t|
74
+ activerecord_dir = ARGV[1]
75
+ if activerecord_dir.nil? or ! File.directory?( activerecord_dir )
76
+ STDERR.puts "ERROR: Pass in the path to ActiveRecord. Eg: /home/zdennis/rails_trunk/activerecord"
77
+ exit
78
+ end
79
+
80
+ old_dir, old_env = Dir.pwd, ENV['RUBYOPT']
81
+ Dir.chdir( activerecord_dir )
82
+ ENV['RUBYOPT'] = "-r#{File.join(old_dir,'init.rb')}"
83
+
84
+ load "Rakefile"
85
+ Rake::Task[ "test_#{adapter}" ].invoke
86
+ Dir.chdir( old_dir )
87
+ ENV['RUBYOPT'] = old_env
88
+ end
89
+
90
+ desc "runs ActiveRecord unit tests for #{adapter} with ActiveRecord::Extensions with ALL available #{adapter} functionality"
91
+ task "#{adapter}_all" do |t|
92
+ ENV['LOAD_ADAPTER_EXTENSIONS'] = adapter.to_s
93
+ Rake::Task["test:activerecord:#{adapter}"].invoke
94
+ end
95
+ end
96
+
97
+ end
98
+
99
+ end
@@ -0,0 +1,7 @@
1
+ development:
2
+ adapter: mysql
3
+ database: aroptests
4
+ username: rails
5
+ password:
6
+ port: 3306
7
+ host: localhost
@@ -0,0 +1,7 @@
1
+ development:
2
+ adapter: mysql
3
+ database: aroptests
4
+ username: rails
5
+ password:
6
+ port: 3306
7
+ host: localhost
@@ -0,0 +1,72 @@
1
+
2
+ create table test_myisam(
3
+ id int(11) unsigned not null auto_increment,
4
+ my_name varchar(20) not null,
5
+ description varchar(255) default '',
6
+ primary key (id)
7
+ )ENGINE=MyISAM;
8
+
9
+
10
+ create table test_innodb(
11
+ id int(11) unsigned not null auto_increment,
12
+ my_name varchar(20) not null,
13
+ description varchar(255) default '',
14
+ primary key (id)
15
+ )ENGINE=InnoDb;
16
+
17
+
18
+ create table test_memory(
19
+ id int(11) unsigned not null auto_increment,
20
+ my_name varchar(20) not null,
21
+ description varchar(255) default '',
22
+ primary key (id)
23
+ )ENGINE=memory;
24
+
25
+
26
+ create temporary table test_temp(
27
+ id int(11) unsigned not null auto_increment,
28
+ my_name varchar(20) not null,
29
+ description varchar(255) default '',
30
+ primary key (id)
31
+ );
32
+
33
+ CREATE TABLE `topics` (
34
+ `id` int(11) NOT NULL auto_increment,
35
+ `title` varchar(255) default NULL,
36
+ `author_name` varchar(255) default NULL,
37
+ `author_email_address` varchar(255) default NULL,
38
+ `written_on` datetime default NULL,
39
+ `bonus_time` time default NULL,
40
+ `last_read` date default NULL,
41
+ `content` text,
42
+ `approved` tinyint(1) default '1',
43
+ `replies_count` int(11) default '0',
44
+ `parent_id` int(11) default NULL,
45
+ `type` varchar(50) default NULL,
46
+ PRIMARY KEY (`id`)
47
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
48
+
49
+ CREATE TABLE `projects` (
50
+ `id` int(11) NOT NULL auto_increment,
51
+ `name` varchar(100) default NULL,
52
+ `type` varchar(255) NOT NULL,
53
+ PRIMARY KEY (`id`)
54
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
55
+
56
+ CREATE TABLE `developers` (
57
+ `id` int(11) NOT NULL auto_increment,
58
+ `name` varchar(100) default NULL,
59
+ `salary` int(11) default '70000',
60
+ `created_at` datetime default NULL,
61
+ `updated_at` datetime default NULL,
62
+ PRIMARY KEY (`id`)
63
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
64
+
65
+ CREATE TABLE `books` (
66
+ `id` int(11) NOT NULL auto_increment,
67
+ `title` varchar(255) NOT NULL,
68
+ `publisher` varchar(255) NOT NULL,
69
+ `author_name` varchar(255) NOT NULL,
70
+ PRIMARY KEY (`id`),
71
+ FULLTEXT( `title`, `publisher`, `author_name` )
72
+ ) ENGINE=MyISAM;