rails_sql_views4 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_sql_views4/connection_adapters/abstract/schema_statements.rb +13 -2
- data/lib/rails_sql_views4/version.rb +1 -1
- data/test/adapter_test.rb +2 -2
- data/test/connection.yml +12 -0
- data/test/dummy/db/schema.rb +5 -5
- data/test/dummy/log/development.log +88 -0
- data/test/dummy/log/test.log +9438 -0
- data/test/schema.native_postgresql.expected.rb +37 -32
- data/test/schema.native_postgresql.out.rb +17 -9
- data/test/test_helper.rb +3 -0
- data/test/view_model_test.rb +0 -2
- data/test/view_operations_test.rb +30 -0
- metadata +21 -5
@@ -1,51 +1,56 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
5
|
#
|
5
|
-
# Note that this schema.rb definition is the authoritative source for your
|
6
|
-
# to create the application database on another
|
7
|
-
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
8
10
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
9
11
|
#
|
10
|
-
# It's strongly recommended
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
11
13
|
|
12
|
-
ActiveRecord::Schema.define(:
|
14
|
+
ActiveRecord::Schema.define(version: 20141228200440) do
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
# These are extensions that must be enabled in order to support this database
|
17
|
+
enable_extension "plpgsql"
|
18
|
+
|
19
|
+
create_table "items", force: :cascade do |t|
|
20
|
+
t.integer "person_id"
|
21
|
+
t.datetime "created_at"
|
22
|
+
t.datetime "updated_at"
|
16
23
|
end
|
17
24
|
|
18
|
-
create_table "items_people", :
|
19
|
-
t.integer
|
20
|
-
t.integer
|
25
|
+
create_table "items_people", force: :cascade do |t|
|
26
|
+
t.integer "person_id"
|
27
|
+
t.integer "item_id"
|
28
|
+
t.datetime "created_at"
|
29
|
+
t.datetime "updated_at"
|
21
30
|
end
|
22
31
|
|
23
|
-
create_table "people", :
|
32
|
+
create_table "people", force: :cascade do |t|
|
24
33
|
t.string "first_name"
|
25
34
|
t.string "last_name"
|
26
|
-
t.string "ssn"
|
35
|
+
t.string "ssn"
|
27
36
|
t.integer "address_id"
|
28
37
|
end
|
29
38
|
|
30
|
-
create_table "people2", :
|
31
|
-
t.string
|
32
|
-
t.string
|
33
|
-
t.string
|
34
|
-
|
35
|
-
|
36
|
-
create_table "places", :force => true do |t|
|
37
|
-
t.text "address"
|
38
|
-
t.string "city"
|
39
|
-
t.string "cstate"
|
40
|
-
t.string "country", :limit => 2
|
39
|
+
create_table "people2", force: :cascade do |t|
|
40
|
+
t.string "first_name"
|
41
|
+
t.string "last_name"
|
42
|
+
t.string "ssn"
|
43
|
+
t.datetime "created_at"
|
44
|
+
t.datetime "updated_at"
|
41
45
|
end
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
create_table "places", force: :cascade do |t|
|
48
|
+
t.text "address"
|
49
|
+
t.string "city"
|
50
|
+
t.string "cstate"
|
51
|
+
t.string "country"
|
52
|
+
t.datetime "created_at"
|
53
|
+
t.datetime "updated_at"
|
49
54
|
end
|
50
55
|
|
51
56
|
end
|
@@ -16,27 +16,27 @@ ActiveRecord::Schema.define(version: 20141228200440) do
|
|
16
16
|
# These are extensions that must be enabled in order to support this database
|
17
17
|
enable_extension "plpgsql"
|
18
18
|
|
19
|
-
create_table "items", force:
|
19
|
+
create_table "items", force: :cascade do |t|
|
20
20
|
t.integer "person_id"
|
21
21
|
t.datetime "created_at"
|
22
22
|
t.datetime "updated_at"
|
23
23
|
end
|
24
24
|
|
25
|
-
create_table "items_people", force:
|
25
|
+
create_table "items_people", force: :cascade do |t|
|
26
26
|
t.integer "person_id"
|
27
27
|
t.integer "item_id"
|
28
28
|
t.datetime "created_at"
|
29
29
|
t.datetime "updated_at"
|
30
30
|
end
|
31
31
|
|
32
|
-
create_table "people", force:
|
32
|
+
create_table "people", force: :cascade do |t|
|
33
33
|
t.string "first_name"
|
34
34
|
t.string "last_name"
|
35
35
|
t.string "ssn"
|
36
36
|
t.integer "address_id"
|
37
37
|
end
|
38
38
|
|
39
|
-
create_table "people2", force:
|
39
|
+
create_table "people2", force: :cascade do |t|
|
40
40
|
t.string "first_name"
|
41
41
|
t.string "last_name"
|
42
42
|
t.string "ssn"
|
@@ -44,7 +44,7 @@ ActiveRecord::Schema.define(version: 20141228200440) do
|
|
44
44
|
t.datetime "updated_at"
|
45
45
|
end
|
46
46
|
|
47
|
-
create_table "places", force:
|
47
|
+
create_table "places", force: :cascade do |t|
|
48
48
|
t.text "address"
|
49
49
|
t.string "city"
|
50
50
|
t.string "cstate"
|
@@ -53,11 +53,19 @@ ActiveRecord::Schema.define(version: 20141228200440) do
|
|
53
53
|
t.datetime "updated_at"
|
54
54
|
end
|
55
55
|
|
56
|
-
create_view
|
56
|
+
create_view :v_people , " SELECT people.id,\n people.first_name,\n people.last_name,\n people.ssn,\n people.address_id\n FROM people;", :force => true do |v|
|
57
57
|
v.column :id
|
58
|
-
v.column :
|
59
|
-
v.column :
|
60
|
-
v.column :
|
58
|
+
v.column :first_name
|
59
|
+
v.column :last_name
|
60
|
+
v.column :ssn
|
61
|
+
v.column :address_id
|
62
|
+
end
|
63
|
+
|
64
|
+
create_view "v_people" , " SELECT people.id,\n people.first_name,\n people.last_name,\n people.ssn,\n people.address_id\n FROM people;", :force => true do |v|
|
65
|
+
v.column :id
|
66
|
+
v.column :first_name
|
67
|
+
v.column :last_name
|
68
|
+
v.column :ssn
|
61
69
|
v.column :address_id
|
62
70
|
end
|
63
71
|
|
data/test/test_helper.rb
CHANGED
data/test/view_model_test.rb
CHANGED
@@ -6,7 +6,6 @@ require 'test_helper'
|
|
6
6
|
class ViewModelTest < ActiveSupport::TestCase
|
7
7
|
|
8
8
|
def setup
|
9
|
-
debugger
|
10
9
|
create_people_view
|
11
10
|
VPerson.send(:based_on, Person)
|
12
11
|
|
@@ -27,7 +26,6 @@ class ViewModelTest < ActiveSupport::TestCase
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def test_same_person
|
30
|
-
debugger
|
31
29
|
assert_equal @person.id, @vperson.id
|
32
30
|
end
|
33
31
|
|
@@ -43,6 +43,36 @@ class ViewOperationsTest < ActiveSupport::TestCase
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_create_or_replace_view
|
47
|
+
# Look at Dummy for app, Model, migration, etc ...
|
48
|
+
|
49
|
+
Person.create(:first_name => 'John', :last_name => 'Doe', :ssn => '123456789')
|
50
|
+
|
51
|
+
assert_nothing_raised do
|
52
|
+
ActiveRecord::Base.connection.create_view(:v_people,
|
53
|
+
# 'select first_name, last_name, ssn from people', :force => true) do |v|
|
54
|
+
'select id from people', :force => true) do |v|
|
55
|
+
v.column :id # ID est obligatoire ?
|
56
|
+
end
|
57
|
+
# I DONT UNDERSTANT the "do" : xxx.create_view() do ?
|
58
|
+
# create_view return a empty array
|
59
|
+
ActiveRecord::Base.connection.create_or_replace_view(:v_people,
|
60
|
+
# 'select first_name, last_name, ssn from people', :force => true) do |v|
|
61
|
+
'select id, first_name, last_name, ssn from people', :force => true) do |v|
|
62
|
+
v.column :id # ID est obligatoire ?
|
63
|
+
v.column :f_name
|
64
|
+
v.column :l_name
|
65
|
+
v.column :social_security
|
66
|
+
end
|
67
|
+
end
|
68
|
+
# p = Person.find(:first) # rails 3
|
69
|
+
p = Person.first
|
70
|
+
# vp = VPerson.find(:first)
|
71
|
+
vp = VPerson.first
|
72
|
+
# assert_equal p.first_name, vp.f_name
|
73
|
+
assert_equal p.first_name, vp.first_name
|
74
|
+
end
|
75
|
+
|
46
76
|
# TODO
|
47
77
|
def test_no_view_raises_error
|
48
78
|
assert_raises(RuntimeError) { ActiveRecord::Base.connection.view_select_statement('foo') }
|
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.
|
4
|
+
version: 0.0.3
|
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-
|
11
|
+
date: 2015-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.2.
|
19
|
+
version: 4.2.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.2.
|
26
|
+
version: 4.2.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: 'IN DEVELOPPEMENT. NOT FOR USE. RailsSqlView4 : uptated version of RailsSqlView
|
28
42
|
: Adds support for using SQL views within ActiveRecord'
|
29
43
|
email:
|
@@ -59,6 +73,7 @@ files:
|
|
59
73
|
- test/README.NOT_UP_TO_DATE
|
60
74
|
- test/adapter_test.rb
|
61
75
|
- test/connection.example.yml
|
76
|
+
- test/connection.yml
|
62
77
|
- test/connection/native_mysql/connection.rb
|
63
78
|
- test/connection/native_mysql/schema.sql
|
64
79
|
- test/connection/native_postgresql/connection.rb
|
@@ -146,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
161
|
version: '0'
|
147
162
|
requirements: []
|
148
163
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.4.
|
164
|
+
rubygems_version: 2.4.8
|
150
165
|
signing_key:
|
151
166
|
specification_version: 4
|
152
167
|
summary: 'IN DEVELOPPEMENT. NOT FOR USE. Summary of RailsSqlViews4 : A DRAFT for RailsSqlView
|
@@ -161,6 +176,7 @@ test_files:
|
|
161
176
|
- test/connection/oracle_enhanced/procedures.sql
|
162
177
|
- test/connection/oracle_enhanced/schema.sql
|
163
178
|
- test/connection.example.yml
|
179
|
+
- test/connection.yml
|
164
180
|
- test/dummy/app/assets/javascripts/application.js
|
165
181
|
- test/dummy/app/assets/stylesheets/application.css
|
166
182
|
- test/dummy/app/controllers/application_controller.rb
|