ar-extensions 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +10 -0
- data/Rakefile +6 -1
- data/db/migrate/generic_schema.rb +26 -1
- data/db/migrate/mysql_schema.rb +1 -1
- data/db/migrate/version.rb +1 -1
- data/init.rb +18 -0
- data/lib/ar-extensions/adapters/abstract_adapter.rb +25 -2
- data/lib/ar-extensions/adapters/mysql.rb +2 -0
- data/lib/ar-extensions/create_and_update.rb +509 -0
- data/lib/ar-extensions/create_and_update/mysql.rb +7 -0
- data/lib/ar-extensions/csv.rb +32 -32
- data/lib/ar-extensions/delete.rb +143 -0
- data/lib/ar-extensions/delete/mysql.rb +3 -0
- data/lib/ar-extensions/extensions.rb +6 -1
- data/lib/ar-extensions/finder_options.rb +275 -0
- data/lib/ar-extensions/finder_options/mysql.rb +6 -0
- data/lib/ar-extensions/finders.rb +7 -1
- data/lib/ar-extensions/import/mysql.rb +8 -1
- data/lib/ar-extensions/insert_select.rb +178 -0
- data/lib/ar-extensions/insert_select/mysql.rb +7 -0
- data/lib/ar-extensions/union.rb +204 -0
- data/lib/ar-extensions/union/mysql.rb +6 -0
- data/lib/ar-extensions/util/sql_generation.rb +27 -0
- data/lib/ar-extensions/util/support_methods.rb +32 -0
- data/lib/ar-extensions/version.rb +1 -1
- metadata +15 -2
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
#Extend this module on ActiveRecord to access global functions
|
3
|
+
module ActiveRecord
|
4
|
+
module Extensions
|
5
|
+
module SqlGeneration#:nodoc:
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def post_sql_statements(options)#:nodoc:
|
10
|
+
connection.post_sql_statements(quoted_table_name, options).join(' ')
|
11
|
+
end
|
12
|
+
|
13
|
+
def pre_sql_statements(options)#:nodoc:
|
14
|
+
connection.pre_sql_statements({:command => 'SELECT'}.merge(options)).join(' ').strip + " "
|
15
|
+
end
|
16
|
+
|
17
|
+
def construct_ar_extension_sql(options={}, valid_options = [], &block)#:nodoc:
|
18
|
+
options.assert_valid_keys(valid_options)if valid_options.any?
|
19
|
+
|
20
|
+
sql = pre_sql_statements(options)
|
21
|
+
yield sql, options
|
22
|
+
sql << post_sql_statements(options)
|
23
|
+
sql
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#Extend this module on ActiveRecord to access global functions
|
2
|
+
class ExtensionNotSupported < Exception; end;
|
3
|
+
|
4
|
+
module ActiveRecord
|
5
|
+
module Extensions
|
6
|
+
module SupportMethods#:nodoc:
|
7
|
+
def supports_extension(name)
|
8
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
9
|
+
def self.supports_#{name}?#:nodoc:
|
10
|
+
connection.supports_#{name}?
|
11
|
+
rescue NoMethodError
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def supports_#{name}?#:nodoc:
|
16
|
+
self.class.supports_#{name}?
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.supports_#{name}!#:nodoc:
|
20
|
+
supports_#{name}? or raise ExtensionNotSupported.new("#{name} extension is not supported. Please require the adapter file.")
|
21
|
+
end
|
22
|
+
|
23
|
+
def supports_#{name}!#:nodoc:
|
24
|
+
self.class.supports_#{name}!
|
25
|
+
end
|
26
|
+
EOS
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
ActiveRecord::Base.send :extend, ActiveRecord::Extensions::SupportMethods
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Dennis
|
8
8
|
- Mark Van Holstyn
|
9
|
+
- Blythe Dunham
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
13
|
|
13
|
-
date: 2009-
|
14
|
+
date: 2009-04-20 00:00:00 -04:00
|
14
15
|
default_executable:
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
@@ -50,8 +51,14 @@ files:
|
|
50
51
|
- lib/ar-extensions/adapters/oracle.rb
|
51
52
|
- lib/ar-extensions/adapters/postgresql.rb
|
52
53
|
- lib/ar-extensions/adapters/sqlite.rb
|
54
|
+
- lib/ar-extensions/create_and_update/mysql.rb
|
55
|
+
- lib/ar-extensions/create_and_update.rb
|
53
56
|
- lib/ar-extensions/csv.rb
|
57
|
+
- lib/ar-extensions/delete/mysql.rb
|
58
|
+
- lib/ar-extensions/delete.rb
|
54
59
|
- lib/ar-extensions/extensions.rb
|
60
|
+
- lib/ar-extensions/finder_options/mysql.rb
|
61
|
+
- lib/ar-extensions/finder_options.rb
|
55
62
|
- lib/ar-extensions/finders.rb
|
56
63
|
- lib/ar-extensions/foreign_keys.rb
|
57
64
|
- lib/ar-extensions/fulltext/mysql.rb
|
@@ -60,9 +67,15 @@ files:
|
|
60
67
|
- lib/ar-extensions/import/postgresql.rb
|
61
68
|
- lib/ar-extensions/import/sqlite.rb
|
62
69
|
- lib/ar-extensions/import.rb
|
70
|
+
- lib/ar-extensions/insert_select/mysql.rb
|
71
|
+
- lib/ar-extensions/insert_select.rb
|
63
72
|
- lib/ar-extensions/synchronize.rb
|
64
73
|
- lib/ar-extensions/temporary_table/mysql.rb
|
65
74
|
- lib/ar-extensions/temporary_table.rb
|
75
|
+
- lib/ar-extensions/union/mysql.rb
|
76
|
+
- lib/ar-extensions/union.rb
|
77
|
+
- lib/ar-extensions/util/sql_generation.rb
|
78
|
+
- lib/ar-extensions/util/support_methods.rb
|
66
79
|
- lib/ar-extensions/version.rb
|
67
80
|
- lib/ar-extensions.rb
|
68
81
|
has_rdoc: true
|