rails_sql_views4 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,6 +13,9 @@
13
13
 
14
14
  ActiveRecord::Schema.define(version: 20141228200440) do
15
15
 
16
+ # These are extensions that must be enabled in order to support this database
17
+ enable_extension "plpgsql"
18
+
16
19
  create_table "items", force: true do |t|
17
20
  t.integer "person_id"
18
21
  t.datetime "created_at"
@@ -27,42 +30,34 @@ ActiveRecord::Schema.define(version: 20141228200440) do
27
30
  end
28
31
 
29
32
  create_table "people", force: true do |t|
30
- t.string "first_name", limit: 255
31
- t.string "last_name", limit: 255
32
- t.string "ssn", limit: 255
33
+ t.string "first_name"
34
+ t.string "last_name"
35
+ t.string "ssn"
33
36
  t.integer "address_id"
34
37
  end
35
38
 
36
39
  create_table "people2", force: true do |t|
37
- t.string "first_name", limit: 255
38
- t.string "last_name", limit: 255
39
- t.string "ssn", limit: 255
40
+ t.string "first_name"
41
+ t.string "last_name"
42
+ t.string "ssn"
40
43
  t.datetime "created_at"
41
44
  t.datetime "updated_at"
42
45
  end
43
46
 
44
47
  create_table "places", force: true do |t|
45
48
  t.text "address"
46
- t.string "city", limit: 255
47
- t.string "cstate", limit: 255
48
- t.string "country", limit: 255
49
+ t.string "city"
50
+ t.string "cstate"
51
+ t.string "country"
49
52
  t.datetime "created_at"
50
53
  t.datetime "updated_at"
51
54
  end
52
55
 
53
- create_view :v_people , "select id, first_name, last_name, ssn, address_id from people", :force => true do |v|
54
- v.column :id
55
- v.column :first_name
56
- v.column :last_name
57
- v.column :ssn
58
- v.column :address_id
59
- end
60
-
61
- create_view "v_people" , "select id, first_name, last_name, ssn, address_id from people", :force => true do |v|
56
+ create_view "v_people" , " SELECT people.id,\n people.first_name AS f_name,\n people.last_name AS l_name,\n people.ssn AS social_security,\n people.address_id\n FROM people;", :force => true do |v|
62
57
  v.column :id
63
- v.column :first_name
64
- v.column :last_name
65
- v.column :ssn
58
+ v.column :f_name
59
+ v.column :l_name
60
+ v.column :social_security
66
61
  v.column :address_id
67
62
  end
68
63
 
data/test/test_helper.rb CHANGED
@@ -29,7 +29,9 @@ end
29
29
  class ActiveSupport::TestCase
30
30
  def create_people_view
31
31
  ActiveRecord::Base.connection.create_view(:v_people,
32
- 'select id, first_name, last_name, ssn, address_id from people', :force => true) do |v|
32
+ # 'select id, first_name, last_name, ssn, address_id from people', :force => true) do |v|
33
+ # no force option... Error in postgres
34
+ 'select id, first_name, last_name, ssn, address_id from people' ) do |v|
33
35
  v.column :id
34
36
  v.column :f_name
35
37
  v.column :l_name
@@ -37,5 +39,14 @@ class ActiveSupport::TestCase
37
39
  v.column :address_id
38
40
  end
39
41
  end
42
+
43
+
44
+
45
+ # create view v_people as SELECT people.id,\ people.first_name AS f_name,\n people.last_name AS l_name,\n people.ssn AS social_security,\n people.address_id\n FROM people;", {:force=>true})
46
+
47
+ # "CREATE VIEW \"v_people\" (\"id\", \"f_name\", \"l_name\", \"social_security\", \"address_id\") AS select id, first_name, last_name, ssn, address_id from people"
48
+ # CREATE VIEW "v_people" ("id", "f_name", "l_name", "social_security", "address_id") AS select id, first_name, last_name, ssn, address_id from people;
49
+
50
+
40
51
  end
41
52
 
@@ -6,6 +6,7 @@ require 'test_helper'
6
6
  class ViewModelTest < ActiveSupport::TestCase
7
7
 
8
8
  def setup
9
+ debugger
9
10
  create_people_view
10
11
  VPerson.send(:based_on, Person)
11
12
 
@@ -26,6 +27,7 @@ class ViewModelTest < ActiveSupport::TestCase
26
27
  end
27
28
 
28
29
  def test_same_person
30
+ debugger
29
31
  assert_equal @person.id, @vperson.id
30
32
  end
31
33
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_sql_views4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Buffat, adapted from rails_sql_view, by Anthony Eden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-04 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,8 +24,8 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.2.O.rc3
27
- description: 'RailsSqlView4 : uptated version of RailsSqlView : Adds support for using
28
- SQL views within ActiveRecord'
27
+ description: 'IN DEVELOPPEMENT. NOT FOR USE. RailsSqlView4 : uptated version of RailsSqlView
28
+ : Adds support for using SQL views within ActiveRecord'
29
29
  email:
30
30
  - laurent.buffat@altrabio.com
31
31
  executables: []
@@ -101,7 +101,6 @@ files:
101
101
  - test/dummy/config/locales/en.yml
102
102
  - test/dummy/config/routes.rb
103
103
  - test/dummy/config/secrets.yml
104
- - test/dummy/db/development.sqlite3
105
104
  - test/dummy/db/migrate/20141228200436_create_people.rb
106
105
  - test/dummy/db/migrate/20141228200437_create_people2.rb
107
106
  - test/dummy/db/migrate/20141228200438_create_places.rb
@@ -150,7 +149,8 @@ rubyforge_project:
150
149
  rubygems_version: 2.4.4
151
150
  signing_key:
152
151
  specification_version: 4
153
- summary: 'Summary of RailsSqlViews4 : A DRAFT for RailsSqlView adapted for Rails 4'
152
+ summary: 'IN DEVELOPPEMENT. NOT FOR USE. Summary of RailsSqlViews4 : A DRAFT for RailsSqlView
153
+ adapted for Rails 4'
154
154
  test_files:
155
155
  - test/adapter_test.rb
156
156
  - test/connection/native_mysql/connection.rb
@@ -194,7 +194,6 @@ test_files:
194
194
  - test/dummy/config/routes.rb
195
195
  - test/dummy/config/secrets.yml
196
196
  - test/dummy/config.ru
197
- - test/dummy/db/development.sqlite3
198
197
  - test/dummy/db/migrate/20141228200436_create_people.rb
199
198
  - test/dummy/db/migrate/20141228200437_create_people2.rb
200
199
  - test/dummy/db/migrate/20141228200438_create_places.rb
Binary file