directory_diff 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +0 -2
  3. data/directory_diff.gemspec +1 -0
  4. data/lib/directory_diff/transformer/temp_table.rb +1 -1
  5. data/lib/directory_diff/version.rb +1 -1
  6. metadata +16 -19
  7. data/vendor/gems/activerecord_pg_stuff-0.0.1/.gitignore +0 -17
  8. data/vendor/gems/activerecord_pg_stuff-0.0.1/.rspec +0 -3
  9. data/vendor/gems/activerecord_pg_stuff-0.0.1/.travis.yml +0 -9
  10. data/vendor/gems/activerecord_pg_stuff-0.0.1/Gemfile +0 -4
  11. data/vendor/gems/activerecord_pg_stuff-0.0.1/LICENSE.txt +0 -22
  12. data/vendor/gems/activerecord_pg_stuff-0.0.1/README.md +0 -72
  13. data/vendor/gems/activerecord_pg_stuff-0.0.1/Rakefile +0 -6
  14. data/vendor/gems/activerecord_pg_stuff-0.0.1/activerecord_pg_stuff.gemspec +0 -27
  15. data/vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff.rb +0 -12
  16. data/vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff/connection/temporary_table.rb +0 -22
  17. data/vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff/relation/pivot.rb +0 -54
  18. data/vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff/relation/temporary_table.rb +0 -38
  19. data/vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff/version.rb +0 -3
  20. data/vendor/gems/activerecord_pg_stuff-0.0.1/spec/lib/connection_temporary_table_spec.rb +0 -35
  21. data/vendor/gems/activerecord_pg_stuff-0.0.1/spec/lib/relation_pivot_spec.rb +0 -25
  22. data/vendor/gems/activerecord_pg_stuff-0.0.1/spec/lib/relation_temporary_table_spec.rb +0 -30
  23. data/vendor/gems/activerecord_pg_stuff-0.0.1/spec/spec_helper.rb +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a89a7f35cf12a031752e0da373d448dc0f1830da
4
- data.tar.gz: cf5ccd904a6bcb6d51dc2c83137dd0e3cc12d8e3
2
+ SHA256:
3
+ metadata.gz: 56998e670060afe5e065f84f4f6fd2a9697a94e3e6fe01e780f828af7fcc863e
4
+ data.tar.gz: 090ced8feb045cbd309573f2658eefc4276422c900809f5fb9e2b1905e273929
5
5
  SHA512:
6
- metadata.gz: 6988dfe0d13df75fe7b39c6067d87b5def0301ea5095e3e5b2f376a05a81dc4270b21d233dd51d017e7e30607208c8ba34609397a10e9f9b95e835851178c83c
7
- data.tar.gz: 17b5a5780b648c543df87f75eb1791c7f03427e912d7175960d7011a8a1a421469fca5c56378cbd223c21e494cba648a02aa9b815cb4724ec5e49fdf6604cc87
6
+ metadata.gz: c5f52e1550f7867b6b6a2994be0f4ca045066d3f507d9bce90fa1e41521db33d0710399bc82eeb8f42c70a59f2b4851dfb9dabe3c54435bf371ceef03de9095e
7
+ data.tar.gz: ae6c99b399f8d48acf64afb56f2c195ab0e4df546585333a00213515135179249b70477ff4a8cf07decb9becd0a89b430817c7e0cc57ed128053d42abc768543
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in directory_diff.gemspec
4
4
  gemspec
5
-
6
- gem "activerecord_pg_stuff", "~> 0.0.1", path: "vendor/gems/activerecord_pg_stuff-0.0.1"
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "activerecord", ">= 5.1.4"
23
23
  spec.add_dependency "pg", "~> 1.1.3"
24
24
  spec.add_dependency "temping", "~> 3.10.0"
25
+ spec.add_dependency "envoy-activerecord_pg_stuff", "~> 0.0.3"
25
26
 
26
27
  spec.add_development_dependency "bundler", "~> 1.11"
27
28
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,4 +1,4 @@
1
- require "activerecord_pg_stuff"
1
+ require "envoy/activerecord_pg_stuff"
2
2
 
3
3
  Arel::Predications.module_eval do
4
4
  def contains(other)
@@ -1,3 +1,3 @@
1
1
  module DirectoryDiff
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: directory_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kamal Mahyuddin
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.10.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: envoy-activerecord_pg_stuff
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.3
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -119,23 +133,6 @@ files:
119
133
  - lib/directory_diff/transformer/in_memory.rb
120
134
  - lib/directory_diff/transformer/temp_table.rb
121
135
  - lib/directory_diff/version.rb
122
- - vendor/gems/activerecord_pg_stuff-0.0.1/.gitignore
123
- - vendor/gems/activerecord_pg_stuff-0.0.1/.rspec
124
- - vendor/gems/activerecord_pg_stuff-0.0.1/.travis.yml
125
- - vendor/gems/activerecord_pg_stuff-0.0.1/Gemfile
126
- - vendor/gems/activerecord_pg_stuff-0.0.1/LICENSE.txt
127
- - vendor/gems/activerecord_pg_stuff-0.0.1/README.md
128
- - vendor/gems/activerecord_pg_stuff-0.0.1/Rakefile
129
- - vendor/gems/activerecord_pg_stuff-0.0.1/activerecord_pg_stuff.gemspec
130
- - vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff.rb
131
- - vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff/connection/temporary_table.rb
132
- - vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff/relation/pivot.rb
133
- - vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff/relation/temporary_table.rb
134
- - vendor/gems/activerecord_pg_stuff-0.0.1/lib/activerecord_pg_stuff/version.rb
135
- - vendor/gems/activerecord_pg_stuff-0.0.1/spec/lib/connection_temporary_table_spec.rb
136
- - vendor/gems/activerecord_pg_stuff-0.0.1/spec/lib/relation_pivot_spec.rb
137
- - vendor/gems/activerecord_pg_stuff-0.0.1/spec/lib/relation_temporary_table_spec.rb
138
- - vendor/gems/activerecord_pg_stuff-0.0.1/spec/spec_helper.rb
139
136
  homepage: https://github.com/envoy/directory_diff
140
137
  licenses:
141
138
  - MIT
@@ -156,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
153
  version: '0'
157
154
  requirements: []
158
155
  rubyforge_project:
159
- rubygems_version: 2.5.2
156
+ rubygems_version: 2.7.7
160
157
  signing_key:
161
158
  specification_version: 4
162
159
  summary: Envoy employee directory diffing.
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
@@ -1,3 +0,0 @@
1
- --color
2
- -fd
3
- --order=rand
@@ -1,9 +0,0 @@
1
- rvm:
2
- - 1.9.3
3
- - 2.0.0
4
-
5
- env:
6
- global:
7
- - DATABASE_URL=postgresql://postgres@localhost
8
-
9
- script: bundle exec rake
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in activerecord_pg_stuff.gemspec
4
- gemspec
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 Dmitry Galinsky
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,72 +0,0 @@
1
- # ActiveRecordPgStuff
2
-
3
- Adds support for working with temporary tables and pivot tables (PostgreSQL only).
4
-
5
- * [![Build Status](https://travis-ci.org/dima-exe/activerecord_pg_stuff.png?branch=master)](https://travis-ci.org/dima-exe/activerecord_pg_stuff)
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- gem 'activerecord_pg_stuff'
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install activerecord_pg_stuff
20
-
21
- ## Usage
22
-
23
- #### Temporary tables
24
-
25
- Example:
26
-
27
- User.select(:id, :email).temporary_table do |rel|
28
- rel.pluck(:id)
29
- end
30
-
31
- #### Pivot tables
32
-
33
- Before using, you need to create the extension:
34
-
35
- CREATE EXTENSION tablefunc
36
-
37
- Example:
38
-
39
- CREATE TABLE payments (id integer, amount integer, seller_id integer, created_at timestamp)
40
- INSERT INTO payments
41
- VALUES (1, 1, 1, '2012-10-12 10:00 UTC'),
42
- (2, 3, 1, '2012-11-12 10:00 UTC'),
43
- (3, 5, 2, '2012-09-12 10:00 UTC'),
44
- (4, 7, 2, '2012-10-12 10:00 UTC'),
45
- (5, 11, 2, '2012-11-12 10:00 UTC'),
46
- (6, 13, 2, '2012-11-12 10:00 UTC')
47
-
48
- Payment
49
- .select("SUM(amount) AS amount", :seller_id, "DATE_TRUNC('month', created_at) AS month")
50
- .group("seller_id, DATE_TRUNC('month', created_at)")
51
- .temporary_table do |rel|
52
- # :month - for row
53
- # :seller_id - for column
54
- # :amount - for value
55
- rel.pivot(:month, :seller_id, :amount)
56
- end
57
-
58
- expect(result.headers).to eq [nil, 1, 2]
59
-
60
- expect(result.rows).to eq [
61
- [ Time.utc(2012, 9, 1), nil, 5 ],
62
- [ Time.utc(2012, 10, 1), 1, 7 ],
63
- [ Time.utc(2012, 11, 1), 3, 24 ],
64
- ]
65
-
66
- ## Contributing
67
-
68
- 1. Fork it
69
- 2. Create your feature branch (`git checkout -b my-new-feature`)
70
- 3. Commit your changes (`git commit -am 'Add some feature'`)
71
- 4. Push to the branch (`git push origin my-new-feature`)
72
- 5. Create new Pull Request
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => [:spec]
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'activerecord_pg_stuff/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "activerecord_pg_stuff"
8
- spec.version = ActiveRecordPgStuff::VERSION
9
- spec.authors = ["Dmitry Galinsky"]
10
- spec.email = ["dima.exe@gmail.com"]
11
- spec.description = %q{ Adds support for working with temporary tables and pivot tables (PostgreSQL only) }
12
- spec.summary = %q{ Adds support for working with temporary tables and pivot tables (PostgreSQL only) }
13
- spec.homepage = ""
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_runtime_dependency "activerecord", ">= 4.0"
22
-
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec"
26
- spec.add_development_dependency "pg"
27
- end
@@ -1,12 +0,0 @@
1
- require 'active_record'
2
- require 'active_record/connection_adapters/postgresql_adapter'
3
-
4
- require File.expand_path("../activerecord_pg_stuff/version", __FILE__)
5
- require File.expand_path("../activerecord_pg_stuff/connection/temporary_table", __FILE__)
6
- require File.expand_path("../activerecord_pg_stuff/relation/temporary_table", __FILE__)
7
- require File.expand_path("../activerecord_pg_stuff/relation/pivot", __FILE__)
8
-
9
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send :include, ActiveRecordPgStuff::Connection::TemporaryTable
10
-
11
- ActiveRecord::Relation.send :include, ActiveRecordPgStuff::Relation::TemporaryTable
12
- ActiveRecord::Relation.send :include, ActiveRecordPgStuff::Relation::Pivot
@@ -1,22 +0,0 @@
1
- module ActiveRecordPgStuff
2
- module Connection
3
-
4
- module TemporaryTable
5
-
6
- def with_temporary_table(name, sql, &block)
7
- transaction do
8
- begin
9
- sql = sql.gsub(/\n/, ' ').gsub(/ +/, ' ').strip
10
- sql = "CREATE TEMPORARY TABLE #{name} ON COMMIT DROP AS #{sql}"
11
- execute sql
12
- yield name
13
- ensure
14
- execute("DROP TABLE IF EXISTS #{name}") rescue nil
15
- end
16
- end
17
- end
18
-
19
- end
20
-
21
- end
22
- end
@@ -1,54 +0,0 @@
1
- module ActiveRecordPgStuff
2
- module Relation
3
-
4
- class PivotResult
5
- attr_reader :headers, :rows
6
-
7
- def initialize(header_result, result)
8
- @headers = [nil] + result_to_array(header_result).map(&:first)
9
- @rows = result_to_array(result)
10
- end
11
-
12
- def each_row(&block)
13
- rows.each(&block)
14
- end
15
-
16
- private
17
- def result_to_array(result)
18
- result.to_hash.map do |h|
19
- result.columns.inject([]) do |a, col|
20
- a << result.column_types[col].type_cast(h[col])
21
- end
22
- end
23
- end
24
- end
25
-
26
- module Pivot
27
-
28
- def pivot(row_id, col_id, val_id)
29
-
30
- types_sql = %{ SELECT column_name, data_type FROM information_schema.columns WHERE table_name = #{connection.quote self.table_name} AND column_name IN (#{connection.quote row_id},#{connection.quote val_id}) }
31
- types = connection.select_all types_sql
32
- types = types.to_a.map(&:values).inject({}) do |a, v|
33
- a[v[0]] = v[1]
34
- a
35
- end
36
- row_type = types[row_id.to_s]
37
- val_type = types[val_id.to_s]
38
-
39
- cols = connection.select_all self.except(:select).select("DISTINCT #{col_id}").order(col_id).to_sql
40
- cols_list = cols.rows.map(&:first).map do |c|
41
- "#{col_id}_#{c} #{val_type}"
42
- end.join(", ")
43
-
44
- rel_1 = connection.quote self.select(row_id, col_id, val_id).order(row_id).to_sql
45
- rel_2 = connection.quote self.except(:select).select("DISTINCT #{col_id}").order(col_id).to_sql
46
- sql = %{ SELECT * FROM crosstab(#{rel_1}, #{rel_2}) AS (row_id #{row_type}, #{cols_list}) }
47
- PivotResult.new cols, connection.select_all(sql)
48
- end
49
-
50
- end
51
-
52
- end
53
- end
54
-
@@ -1,38 +0,0 @@
1
- module ActiveRecordPgStuff
2
- module Relation
3
-
4
- module TemporaryTable
5
-
6
- class Decorator
7
- attr_reader :table_name, :arel_table, :quoted_table_name
8
-
9
- def initialize(object, table_name)
10
- @table_name = table_name
11
- @object = object
12
- @arel_table = Arel::Table.new(table_name)
13
- @quoted_table_name = @object.connection.quote_table_name(table_name)
14
- end
15
-
16
- def method_missing(name, *args, &block)
17
- @object.send(name, *args, &block)
18
- end
19
-
20
- def respond_to?(name, *args)
21
- @object.respond_to?(name, *args)
22
- end
23
- end
24
-
25
- def temporary_table
26
- tname = "temporary_#{self.table_name}_#{self.object_id}"
27
- self.klass.connection.with_temporary_table tname, self.to_sql do |name|
28
- dec = Decorator.new self.klass, name
29
- rel = ActiveRecord::Relation.new dec, table: dec.arel_table
30
- rel.readonly!
31
- yield rel
32
- end
33
- end
34
-
35
- end
36
-
37
- end
38
- end
@@ -1,3 +0,0 @@
1
- module ActiveRecordPgStuff
2
- VERSION = "0.0.1"
3
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveRecordPgStuff::Connection::TemporaryTable do
4
-
5
- context "with_temporary_table" do
6
- let(:sql) { "SELECT * FROM sellers WHERE id IN(1,2)" }
7
-
8
- it "should create temporary table with 'name' and 'sql' and drop it after block executed" do
9
- rs = conn.with_temporary_table 'sellers_tmp', sql do |name|
10
- conn.select_all("SELECT * FROM #{name}").to_a.map(&:values)
11
- end
12
- expect(rs).to eq [%w{1 foo}, %w{2 bar}]
13
- expect {
14
- conn.execute 'SELECT * FROM sellers_tmp'
15
- }.to raise_error(ActiveRecord::StatementInvalid, /PG::UndefinedTable/)
16
- end
17
-
18
- it "should create nested temporary tables" do
19
- rs = conn.with_temporary_table 'sellers_tmp', sql do |name|
20
- sql = "SELECT * FROM #{name} WHERE id = 1"
21
- conn.with_temporary_table 'sellers_tmp_nested', sql do |name_nested|
22
- conn.select_all("SELECT * FROM #{name_nested}").to_a.map(&:values)
23
- end
24
- end
25
- expect(rs).to eq [%w{1 foo}]
26
- expect {
27
- conn.execute 'SELECT * FROM sellers_tmp'
28
- }.to raise_error(ActiveRecord::StatementInvalid, /PG::UndefinedTable/)
29
- expect {
30
- conn.execute 'SELECT * FROM sellers_tmp_nested'
31
- }.to raise_error(ActiveRecord::StatementInvalid, /PG::UndefinedTable/)
32
- end
33
-
34
- end
35
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveRecordPgStuff::Relation::TemporaryTable do
4
-
5
- context "pivot" do
6
-
7
- let(:rel) { Payment }
8
-
9
- it "should create pivot table from relation" do
10
- rs = rel.select(:seller_id, "SUM(amount) AS amount", "DATE_TRUNC('month', created_at) AS created_at")
11
- .group("seller_id, DATE_TRUNC('month', created_at)").temporary_table do |tmp|
12
- tmp.pivot :created_at, :seller_id, :amount
13
- end
14
-
15
- expect(rs.headers).to eq [nil,1,2]
16
- expect(rs.rows).to eq [
17
- [ Time.utc(2012, 9, 1), nil, 5 ],
18
- [ Time.utc(2012, 10, 1), 1, 7 ],
19
- [ Time.utc(2012, 11, 1), 3, 24 ],
20
- ]
21
- end
22
-
23
- end
24
-
25
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveRecordPgStuff::Relation::TemporaryTable do
4
-
5
- context "temporary_table" do
6
-
7
- let(:rel) { Seller.where(id: [1,2]) }
8
-
9
- it "should create temporary table from relation" do
10
- rs = rel.temporary_table do |tmp|
11
- tmp.where(id: [1,2]).load
12
- end
13
- expect(rs.map(&:class)).to eq [Seller, Seller]
14
- expect(rs.map(&:class).map(&:table_name)).to eq %w{ sellers sellers }
15
- expect(rs.map(&:id)).to eq [1,2]
16
- expect(rs.map(&:readonly?)).to eq [true, true]
17
- end
18
-
19
- it "should create nested temporary tables from relation" do
20
- rs = rel.select("id * 10 AS id").temporary_table do |tmp|
21
- tmp.where(id: [10]).temporary_table do |nested_tmp|
22
- nested_tmp.where(id: [10,20]).load
23
- end
24
- end
25
- expect(rs.map(&:id)).to eq [10]
26
- end
27
-
28
- end
29
-
30
- end
@@ -1,42 +0,0 @@
1
- Bundler.require(:test)
2
- require 'rspec/autorun'
3
- require 'logger'
4
- require File.expand_path("../../lib/activerecord_pg_stuff", __FILE__)
5
-
6
- ActiveRecord::Base.logger = Logger.new(STDOUT)
7
-
8
- RSpec.configure do |c|
9
- c.before(:suite) do
10
- ActiveRecord::Base.establish_connection
11
- end
12
-
13
- c.before(:all) do
14
- conn.execute 'CREATE EXTENSION IF NOT EXISTS tablefunc'
15
- conn.execute "CREATE TABLE sellers (id integer, name varchar)"
16
- conn.execute "INSERT INTO sellers VALUES(1, 'foo'), (2, 'bar'), (3, 'baz')"
17
-
18
- conn.execute "CREATE TABLE payments (id integer, amount integer, seller_id integer, created_at timestamp)"
19
- conn.execute "INSERT INTO payments VALUES(1, 1, 1, '2012-10-12 10:00 UTC')"
20
- conn.execute "INSERT INTO payments VALUES(2, 3, 1, '2012-11-12 10:00 UTC')"
21
- conn.execute "INSERT INTO payments VALUES(3, 5, 2, '2012-09-12 10:00 UTC')"
22
- conn.execute "INSERT INTO payments VALUES(4, 7, 2, '2012-10-12 10:00 UTC')"
23
- conn.execute "INSERT INTO payments VALUES(5, 11, 2, '2012-11-12 10:00 UTC')"
24
- conn.execute "INSERT INTO payments VALUES(6, 13, 2, '2012-11-12 10:00 UTC')"
25
- end
26
-
27
- c.after(:all) do
28
- conn.execute("DROP TABLE sellers")
29
- conn.execute("DROP TABLE payments")
30
- end
31
- end
32
-
33
- def conn
34
- ActiveRecord::Base.connection
35
- end
36
-
37
- class Seller < ActiveRecord::Base
38
- end
39
-
40
- class Payment < ActiveRecord::Base
41
- end
42
-