rails_db_views 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_db_views.rb +2 -1
- data/lib/rails_db_views/database_symbol.rb +18 -8
- data/lib/rails_db_views/exceptions.rb +7 -0
- data/lib/rails_db_views/factory.rb +1 -2
- data/lib/rails_db_views/version.rb +1 -1
- data/test/dummy/db/views/chats.sql +1 -1
- data/test/dummy/db/views/messages.sql +1 -1
- data/test/dummy/log/development.log +83 -598
- metadata +3 -10
- data/test/dummy/log/test.log +0 -2635
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7e969668533cd8b06db487903d6c8f98cdcef46
|
4
|
+
data.tar.gz: 8d14a8ff8d30f9d82a4a4f75854932776d9ce611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08f002d1eb0b886d94315875e02006e8d59d7b8d1cc9491be92429df638aee5f51c9beb35b35d9b51afb6c89ce4fce2cb8fdc46db83aff50ca876a2fc7b62547
|
7
|
+
data.tar.gz: 790a04c20ab6a88abb9f8b84102141fa8ea3fec7078f66a60a8db949efa7d113582897ee04e2964cc854d440f8992ab37a1a925ebc9413f86b8cf03d7b85abc0
|
data/lib/rails_db_views.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module RailsDbViews
|
2
2
|
unless defined?(Rails)
|
3
|
-
raise "
|
3
|
+
raise LoadError, "rails_db_views gem is made for Ruby on Rails !"
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
|
+
require 'rails_db_views/exceptions'
|
7
8
|
require 'rails_db_views/railtie'
|
8
9
|
require 'rails_db_views/database_symbol'
|
9
10
|
require 'rails_db_views/view'
|
@@ -1,10 +1,9 @@
|
|
1
1
|
class RailsDbViews::DatabaseSymbol
|
2
|
-
class CircularReferenceError < RuntimeError; end
|
3
|
-
class SymbolNotFound < RuntimeError; end
|
4
|
-
|
5
2
|
attr_accessor :path, :sql_content, :status, :required, :inverse_of_required, :marked_as_deleted, :name
|
6
3
|
alias :marked_as_deleted? :marked_as_deleted
|
7
4
|
|
5
|
+
STRING_INTERPOLATION = /((.?)\#\{([^\}]*)\})/
|
6
|
+
|
8
7
|
module Status
|
9
8
|
LOADED = :loaded
|
10
9
|
IN_PROGRESS = :in_progress
|
@@ -48,8 +47,19 @@ class RailsDbViews::DatabaseSymbol
|
|
48
47
|
status == Status::UNLOADED
|
49
48
|
end
|
50
49
|
|
50
|
+
|
51
|
+
def process_string_interpolation str
|
52
|
+
str.gsub(STRING_INTERPOLATION) do |x|
|
53
|
+
if $2 == '\\'
|
54
|
+
$1[1..-1] #Rendering the whole expression because of escape char.
|
55
|
+
else
|
56
|
+
$2 + (TOPLEVEL_BINDING.eval($3)).to_s
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
51
61
|
def uncommented_sql_content
|
52
|
-
sql_content.split("\n").reject{|x| x=~ COMMENTS }.join("\n")
|
62
|
+
process_string_interpolation(sql_content.split("\n").reject{|x| x=~ COMMENTS }.join("\n"))
|
53
63
|
end
|
54
64
|
|
55
65
|
def create!
|
@@ -117,11 +127,11 @@ protected
|
|
117
127
|
COMMENTS = /#{COMMENTS_TWO_DASH}|#{COMMENTS_SHARP}/
|
118
128
|
|
119
129
|
def circular_reference_error
|
120
|
-
raise CircularReferenceError, "Circular file reference! (file: #{path})"
|
130
|
+
raise RailsDbViews::CircularReferenceError, "Circular file reference! (file: #{path})"
|
121
131
|
end
|
122
132
|
|
123
133
|
def not_found_error(symbol_name)
|
124
|
-
raise SymbolNotFound, "#{self.class.name} `#{symbol_name}` referenced in file #{path} cannot be found..."
|
134
|
+
raise RailsDbViews::SymbolNotFound, "#{self.class.name} `#{symbol_name}` referenced in file #{path} cannot be found..."
|
125
135
|
end
|
126
136
|
|
127
137
|
def load_directives
|
@@ -135,10 +145,10 @@ protected
|
|
135
145
|
case d
|
136
146
|
when /^require /
|
137
147
|
self.required += d.split(/[ \t]+/)[1..-1]
|
138
|
-
when /^delete(d?)
|
148
|
+
when /^delete(d?)/
|
139
149
|
self.mark_as_delete!
|
140
150
|
else
|
141
|
-
raise IllegalDirective, "I don't know what to do with `#{d}` (in #{path})"
|
151
|
+
raise RailsDbViews::IllegalDirective, "I don't know what to do with `#{d}` (in #{path})"
|
142
152
|
end
|
143
153
|
end
|
144
154
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
|
2
2
|
class RailsDbViews::Factory
|
3
|
-
class AmbigousNameError < RuntimeError; end
|
4
3
|
|
5
4
|
@symbols = {}
|
6
5
|
|
@@ -14,7 +13,7 @@ class RailsDbViews::Factory
|
|
14
13
|
symbol = symbol_class.new(file)
|
15
14
|
|
16
15
|
if s=@symbols[symbol_class.to_s][symbol.name]
|
17
|
-
raise AmbigousNameError, "between #{file} and #{s.path}"
|
16
|
+
raise RailsDbViews::AmbigousNameError, "between #{file} and #{s.path}"
|
18
17
|
end
|
19
18
|
|
20
19
|
@symbols[symbol_class.to_s][symbol.name] = symbol
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# This is the request for virtual chat object.
|
2
2
|
# !require messages
|
3
|
-
SELECT tuple_sort(ARRAY[sender_id, receiver_id]) AS ids,
|
3
|
+
SELECT #{"tuple_sort"}(ARRAY[sender_id, receiver_id]) AS ids,
|
4
4
|
MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
|
5
5
|
FROM messages
|
6
6
|
GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])
|
@@ -2,7 +2,7 @@
|
|
2
2
|
-- output:
|
3
3
|
-- receiver_name, receiver_id, sender_name, sender_id, content, updated_at, created_at
|
4
4
|
SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
|
5
|
-
FROM
|
5
|
+
FROM #{puts "This is evaluated in Ruby."; ""}
|
6
6
|
(SELECT u2.name as receiver_name, u2.id as receiver_id,
|
7
7
|
u1.name as sender_name, u1.id as sender_id,
|
8
8
|
um.content as content, um.updated_at as updated_at, um.created_at as created_at
|
@@ -1,533 +1,29 @@
|
|
1
|
-
[1m[36m (
|
2
|
-
[1m[36m (0.2ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld'[0m
|
3
|
-
SQLite3::SQLException: table hello_world already exists: CREATE VIEW hello_world AS SELECT 'HelloWorld'
|
4
|
-
[1m[36m (0.3ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld'[0m
|
5
|
-
SQLite3::SQLException: table hello_world already exists: CREATE VIEW hello_world AS SELECT 'HelloWorld'
|
6
|
-
[1m[36m (1.6ms)[0m [1mDROP VIEW hello_world[0m
|
7
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
8
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
9
|
-
[1m[36m (0.9ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
10
|
-
[1m[35m (0.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
11
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
12
|
-
[1m[35m (1.0ms)[0m CREATE VIEW hello_world AS SELECT 'HelloWorld'
|
13
|
-
[1m[36m (0.8ms)[0m [1mCREATE VIEW required AS SELECT 1[0m
|
14
|
-
[1m[36m (2.0ms)[0m [1mDROP VIEW hello_world[0m
|
15
|
-
[1m[35m (1.0ms)[0m DROP VIEW required
|
16
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
17
|
-
[1m[35m (0.1ms)[0m CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT * AS required ) = 1
|
18
|
-
SQLite3::SQLException: near "AS": syntax error: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT * AS required ) = 1
|
19
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW hello_world[0m
|
20
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
21
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
22
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
23
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
24
|
-
[1m[35m (0.1ms)[0m CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id AS required ) IN (1)
|
25
|
-
SQLite3::SQLException: no such column: id: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id AS required ) IN (1)
|
26
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW hello_world[0m
|
27
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
28
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
29
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
30
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
31
|
-
[1m[35m (0.1ms)[0m CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
32
|
-
SQLite3::SQLException: no such table: main.required: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
33
|
-
[1m[36m (0.4ms)[0m [1mDROP VIEW hello_world[0m
|
34
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
35
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
36
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
37
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
38
|
-
[1m[35m (0.2ms)[0m CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
39
|
-
SQLite3::SQLException: no such table: main.required: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
40
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW hello_world[0m
|
41
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
42
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
43
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
44
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
45
|
-
[1m[35m (0.1ms)[0m CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
46
|
-
SQLite3::SQLException: no such table: main.required: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
47
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW hello_world[0m
|
48
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
49
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
50
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
51
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
52
|
-
[1m[35m (0.2ms)[0m CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
53
|
-
SQLite3::SQLException: no such table: main.required: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
54
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW hello_world[0m
|
55
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
56
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
57
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
58
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
59
|
-
[1m[35m (1.3ms)[0m CREATE VIEW hello_world AS SELECT 1 as id
|
60
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
61
|
-
SQLite3::SQLException: table hello_world already exists: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
62
|
-
[1m[36m (1.9ms)[0m [1mDROP VIEW hello_world[0m
|
63
|
-
[1m[35m (0.2ms)[0m DROP VIEW required
|
64
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
65
|
-
[1m[36m (0.5ms)[0m [1mDROP VIEW hello_world[0m
|
66
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
67
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
68
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
69
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
70
|
-
[1m[35m (0.9ms)[0m CREATE VIEW hello_world AS SELECT 1 as id
|
71
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
72
|
-
SQLite3::SQLException: table hello_world already exists: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
73
|
-
[1m[36m (1.6ms)[0m [1mDROP VIEW hello_world[0m
|
74
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
75
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
76
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
77
|
-
[1m[35m (1.0ms)[0m CREATE VIEW hello_world AS SELECT 1 as id
|
78
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
79
|
-
SQLite3::SQLException: table hello_world already exists: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
80
|
-
[1m[36m (2.1ms)[0m [1mDROP VIEW hello_world[0m
|
81
|
-
[1m[35m (0.2ms)[0m DROP VIEW required
|
82
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
83
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
84
|
-
[1m[35m (1.0ms)[0m CREATE VIEW hello_world AS SELECT 1 as id
|
85
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
86
|
-
SQLite3::SQLException: table hello_world already exists: CREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
87
|
-
[1m[36m (1.2ms)[0m [1mDROP VIEW hello_world[0m
|
88
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
89
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
90
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
91
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW hello_world[0m
|
92
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
93
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
94
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
95
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
96
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW hello_world[0m
|
97
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
98
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
99
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
100
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
101
|
-
[1m[35m (0.1ms)[0m SELECT 1 as id
|
102
|
-
[1m[36m (0.1ms)[0m [1mSELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
103
|
-
SQLite3::SQLException: no such table: required: SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
104
|
-
[1m[36m (0.4ms)[0m [1mDROP VIEW hello_world[0m
|
105
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
106
|
-
[1m[35m (0.1ms)[0m DROP VIEW required
|
107
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
108
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
109
|
-
[1m[35m (0.1ms)[0m SELECT 1 as id
|
110
|
-
[1m[36m (0.1ms)[0m [1mSELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
111
|
-
SQLite3::SQLException: no such table: required: SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
112
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW required[0m
|
113
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
114
|
-
[1m[35m (0.2ms)[0m DROP VIEW hello_world
|
115
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
116
|
-
[1m[36m (0.1ms)[0m [1mDROP VIEW required[0m
|
117
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
118
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
119
|
-
[1m[36m (0.1ms)[0m [1mSELECT 1 as id[0m
|
120
|
-
[1m[35m (0.1ms)[0m SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
121
|
-
SQLite3::SQLException: no such table: required: SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
122
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW required[0m
|
123
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
124
|
-
[1m[35m (0.1ms)[0m DROP VIEW hello_world
|
125
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
126
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
127
|
-
[1m[35m (0.1ms)[0m SELECT 1 as id
|
128
|
-
[1m[36m (0.1ms)[0m [1mSELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
129
|
-
SQLite3::SQLException: no such table: required: SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
130
|
-
[1m[36m (0.1ms)[0m [1mDROP VIEW DROP VIEW required[0m
|
131
|
-
SQLite3::SQLException: near "DROP": syntax error: DROP VIEW DROP VIEW required
|
132
|
-
[1m[35m (0.1ms)[0m DROP VIEW DROP VIEW hello_world
|
133
|
-
SQLite3::SQLException: near "DROP": syntax error: DROP VIEW DROP VIEW hello_world
|
134
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
135
|
-
[1m[35m (1.1ms)[0m CREATE VIEW required AS SELECT 1 as id
|
136
|
-
[1m[36m (1.1ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
137
|
-
[1m[36m (0.1ms)[0m [1mDROP VIEW DROP VIEW required[0m
|
138
|
-
SQLite3::SQLException: near "DROP": syntax error: DROP VIEW DROP VIEW required
|
139
|
-
[1m[35m (0.1ms)[0m DROP VIEW DROP VIEW hello_world
|
140
|
-
SQLite3::SQLException: near "DROP": syntax error: DROP VIEW DROP VIEW hello_world
|
141
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
142
|
-
[1m[35m (0.1ms)[0m CREATE VIEW required AS SELECT 1 as id
|
143
|
-
SQLite3::SQLException: table required already exists: CREATE VIEW required AS SELECT 1 as id
|
144
|
-
[1m[36m (2.2ms)[0m [1mDROP VIEW required[0m
|
145
|
-
[1m[35m (0.9ms)[0m DROP VIEW hello_world
|
146
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
147
|
-
[1m[35m (1.0ms)[0m CREATE VIEW required AS SELECT 1 as id
|
148
|
-
[1m[36m (0.9ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
149
|
-
[1m[36m (2.1ms)[0m [1mDROP VIEW required[0m
|
150
|
-
[1m[35m (1.1ms)[0m DROP VIEW hello_world
|
151
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
152
|
-
[1m[35m (1.1ms)[0m CREATE VIEW required AS SELECT 1 as id
|
153
|
-
[1m[36m (0.9ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
154
|
-
[1m[36m (1.8ms)[0m [1mDROP VIEW required[0m
|
155
|
-
[1m[35m (0.8ms)[0m DROP VIEW hello_world
|
156
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
157
|
-
[1m[35m (0.8ms)[0m CREATE VIEW required AS SELECT 1 as id
|
158
|
-
[1m[36m (0.9ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
159
|
-
[1m[36m (1.8ms)[0m [1mDROP VIEW required[0m
|
160
|
-
[1m[35m (0.9ms)[0m DROP VIEW hello_world
|
161
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
162
|
-
[1m[35m (0.8ms)[0m CREATE VIEW required AS SELECT 1 as id
|
163
|
-
[1m[36m (0.8ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
164
|
-
[1m[36m (1.6ms)[0m [1mDROP VIEW required[0m
|
165
|
-
[1m[35m (1.0ms)[0m DROP VIEW hello_world
|
166
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
167
|
-
[1m[35m (0.9ms)[0m CREATE VIEW required AS SELECT 1 as id
|
168
|
-
[1m[36m (1.1ms)[0m [1mCREATE VIEW hello_world AS SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
169
|
-
[1m[36m (0.2ms)[0m [1mCREATE OR REPLACE FUNCTION (x integer, y integer) RETURNS integer AS $$
|
170
|
-
BEGIN
|
171
|
-
RETURN x + y;
|
172
|
-
END;
|
173
|
-
$$ LANGUAGE plpgsql; add.sql[0m
|
174
|
-
SQLite3::SQLException: near "OR": syntax error: CREATE OR REPLACE FUNCTION (x integer, y integer) RETURNS integer AS $$
|
175
|
-
BEGIN
|
176
|
-
RETURN x + y;
|
177
|
-
END;
|
178
|
-
$$ LANGUAGE plpgsql; add.sql
|
179
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add.sql[0m
|
180
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
181
|
-
[1m[36m (0.1ms)[0m [1mDROP FUNCTION add.sql[0m
|
182
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
183
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add.sql[0m
|
184
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
185
|
-
[1m[36m (0.1ms)[0m [1mDROP FUNCTION add.sql[0m
|
186
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
187
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add.sql[0m
|
188
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
189
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add.sql[0m
|
190
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
191
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add.sql[0m
|
192
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
193
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add.sql[0m
|
194
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
195
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add.sql[0m
|
196
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
197
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add.sql[0m
|
198
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
199
|
-
[1m[36m (0.1ms)[0m [1mDROP FUNCTION add.sql[0m
|
200
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
201
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add.sql[0m
|
202
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add.sql
|
203
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add[0m
|
204
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add
|
205
|
-
[1m[35m (0.2ms)[0m CREATE VIEW required
|
206
|
-
SQLite3::SQLException: near "required": syntax error: CREATE VIEW required
|
207
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world[0m
|
208
|
-
SQLite3::SQLException: near "hello_world": syntax error: CREATE VIEW hello_world
|
209
|
-
[1m[35m (1.0ms)[0m CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
|
210
|
-
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
211
|
-
[1m[35m (0.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
212
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
213
|
-
[1m[35m (0.1ms)[0m CREATE VIEW SELECT 1 as id
|
214
|
-
SQLite3::SQLException: near "SELECT": syntax error: CREATE VIEW SELECT 1 as id
|
215
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add[0m
|
216
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add
|
217
|
-
[1m[35m (0.2ms)[0m CREATE VIEW required
|
218
|
-
SQLite3::SQLException: near "required": syntax error: CREATE VIEW required
|
219
|
-
[1m[36m (0.2ms)[0m [1mCREATE VIEW hello_world[0m
|
220
|
-
SQLite3::SQLException: near "hello_world": syntax error: CREATE VIEW hello_world
|
221
|
-
[1m[35m (1.2ms)[0m CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
|
222
|
-
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
223
|
-
[1m[35m (0.9ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
224
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
225
|
-
[1m[35m (0.1ms)[0m CREATE VIEW SELECT 1 as id
|
226
|
-
SQLite3::SQLException: near "SELECT": syntax error: CREATE VIEW SELECT 1 as id
|
227
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add[0m
|
228
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add
|
229
|
-
[1m[35m (0.1ms)[0m CREATE VIEW required
|
230
|
-
SQLite3::SQLException: near "required": syntax error: CREATE VIEW required
|
231
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world[0m
|
232
|
-
SQLite3::SQLException: near "hello_world": syntax error: CREATE VIEW hello_world
|
233
|
-
[1m[35m (1.9ms)[0m CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
|
234
|
-
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
235
|
-
[1m[35m (1.2ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
236
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
237
|
-
[1m[35m (1.0ms)[0m CREATE VIEW required AS SELECT 1 as id
|
238
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add[0m
|
239
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add
|
240
|
-
[1m[35m (0.1ms)[0m CREATE VIEW required
|
241
|
-
SQLite3::SQLException: near "required": syntax error: CREATE VIEW required
|
242
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world[0m
|
243
|
-
SQLite3::SQLException: near "hello_world": syntax error: CREATE VIEW hello_world
|
244
|
-
[1m[35m (1.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
|
245
|
-
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
246
|
-
[1m[35m (0.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
247
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
248
|
-
[1m[35m (0.7ms)[0m CREATE VIEW required AS SELECT 1 as id
|
249
|
-
[1m[36m (0.9ms)[0m [1mCREATE VIEW hello_world AS --!require required
|
250
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
251
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add[0m
|
252
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add
|
253
|
-
[1m[35m (0.1ms)[0m CREATE VIEW required
|
254
|
-
SQLite3::SQLException: near "required": syntax error: CREATE VIEW required
|
255
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world[0m
|
256
|
-
SQLite3::SQLException: near "hello_world": syntax error: CREATE VIEW hello_world
|
257
|
-
[1m[35m (1.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
|
258
|
-
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
259
|
-
[1m[35m (0.9ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
260
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
261
|
-
[1m[35m (0.8ms)[0m CREATE VIEW required AS SELECT 1 as id
|
262
|
-
[1m[36m (0.9ms)[0m [1mCREATE VIEW hello_world AS --!require required
|
263
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
264
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add[0m
|
265
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add
|
266
|
-
[1m[35m (0.1ms)[0m CREATE VIEW required
|
267
|
-
SQLite3::SQLException: near "required": syntax error: CREATE VIEW required
|
268
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world[0m
|
269
|
-
SQLite3::SQLException: near "hello_world": syntax error: CREATE VIEW hello_world
|
270
|
-
[1m[35m (1.0ms)[0m CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
|
271
|
-
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
272
|
-
[1m[35m (1.0ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
273
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
274
|
-
[1m[35m (0.9ms)[0m CREATE VIEW required AS SELECT 1 as id
|
275
|
-
[1m[36m (0.8ms)[0m [1mCREATE VIEW hello_world AS --!require required
|
276
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
277
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add[0m
|
278
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add
|
279
|
-
[1m[35m (0.1ms)[0m CREATE VIEW required
|
280
|
-
SQLite3::SQLException: near "required": syntax error: CREATE VIEW required
|
281
|
-
[1m[36m (0.1ms)[0m [1mCREATE VIEW hello_world[0m
|
282
|
-
SQLite3::SQLException: near "hello_world": syntax error: CREATE VIEW hello_world
|
283
|
-
[1m[35m (1.2ms)[0m CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
|
284
|
-
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
285
|
-
[1m[35m (0.9ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
286
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
287
|
-
[1m[35m (0.8ms)[0m CREATE VIEW required AS SELECT 1 as id
|
288
|
-
[1m[36m (1.1ms)[0m [1mCREATE VIEW hello_world AS --!require required
|
289
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)[0m
|
290
|
-
[1m[36m (0.2ms)[0m [1mCREATE VIEW required[0m
|
291
|
-
SQLite3::SQLException: near "required": syntax error: CREATE VIEW required
|
292
|
-
[1m[35m (0.1ms)[0m CREATE VIEW hello_world
|
293
|
-
SQLite3::SQLException: near "hello_world": syntax error: CREATE VIEW hello_world
|
294
|
-
[1m[36m (1.1ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
295
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
296
|
-
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
297
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
298
|
-
[1m[36m (3.9ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
299
|
-
[1m[35m (0.9ms)[0m CREATE VIEW hello_world AS --!require required
|
300
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
301
|
-
[1m[36m (0.2ms)[0m [1mDROP FUNCTION add[0m
|
302
|
-
SQLite3::SQLException: near "FUNCTION": syntax error: DROP FUNCTION add
|
303
|
-
[1m[36m (0.2ms)[0m [1mCREATE VIEW required[0m
|
304
|
-
SQLite3::SQLException: near "required": syntax error: CREATE VIEW required
|
305
|
-
[1m[36m (0.4ms)[0m [1mDROP VIEW required[0m
|
306
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
307
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW required[0m
|
308
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
309
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW required[0m
|
310
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
311
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW required[0m
|
312
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
313
|
-
[1m[35m (0.1ms)[0m DROP VIEW hello_world
|
314
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
315
|
-
[1m[36m (1.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
316
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
317
|
-
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
318
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
319
|
-
[1m[36m (0.7ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
320
|
-
[1m[35m (0.7ms)[0m CREATE VIEW hello_world AS --!require required
|
321
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
322
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW required[0m
|
323
|
-
SQLite3::SQLException: no such view: required: DROP VIEW required
|
324
|
-
[1m[35m (0.2ms)[0m DROP VIEW hello_world
|
325
|
-
SQLite3::SQLException: no such view: hello_world: DROP VIEW hello_world
|
326
|
-
[1m[36m (1.0ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar NOT NULL) [0m
|
327
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
328
|
-
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
329
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
330
|
-
[1m[36m (4.8ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
331
|
-
[1m[35m (1.3ms)[0m CREATE VIEW hello_world AS --!require required
|
332
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
333
|
-
[1m[36m (0.9ms)[0m [1mCREATE OR REPLACE FUNCTION (x integer, y integer) RETURNS integer AS $$
|
334
|
-
BEGIN
|
335
|
-
RETURN x + y;
|
336
|
-
END;
|
337
|
-
$$ LANGUAGE plpgsql; add[0m
|
338
|
-
PG::SyntaxError: ERROR: syntax error at or near "("
|
339
|
-
LINE 1: CREATE OR REPLACE FUNCTION (x integer, y integer) RETURNS in...
|
340
|
-
^
|
341
|
-
: CREATE OR REPLACE FUNCTION (x integer, y integer) RETURNS integer AS $$
|
342
|
-
BEGIN
|
343
|
-
RETURN x + y;
|
344
|
-
END;
|
345
|
-
$$ LANGUAGE plpgsql; add
|
346
|
-
[1m[36m (0.3ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
347
|
-
BEGIN
|
348
|
-
RETURN x + y;
|
349
|
-
END;
|
350
|
-
$$ LANGUAGE plpgsql; add[0m
|
351
|
-
PG::SyntaxError: ERROR: syntax error at or near "add"
|
352
|
-
LINE 5: $$ LANGUAGE plpgsql; add
|
353
|
-
^
|
354
|
-
: CREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
355
|
-
BEGIN
|
356
|
-
RETURN x + y;
|
357
|
-
END;
|
358
|
-
$$ LANGUAGE plpgsql; add
|
359
|
-
[1m[36m (8.7ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
360
|
-
BEGIN
|
361
|
-
RETURN x + y;
|
362
|
-
END;
|
363
|
-
$$ LANGUAGE plpgsql;[0m
|
364
|
-
[1m[35m (17.7ms)[0m DROP VIEW required
|
365
|
-
PG::UndefinedTable: ERROR: view "required" does not exist
|
366
|
-
: DROP VIEW required
|
367
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW hello_world[0m
|
368
|
-
PG::UndefinedTable: ERROR: view "hello_world" does not exist
|
369
|
-
: DROP VIEW hello_world
|
370
|
-
[1m[35m (24.1ms)[0m CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
|
371
|
-
[1m[36m (1.0ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
372
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.3ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
373
|
-
[1m[36m (23.3ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
374
|
-
[1m[35m (5.5ms)[0m CREATE VIEW hello_world AS --!require required
|
375
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
376
|
-
[1m[36m (12.3ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
377
|
-
BEGIN
|
378
|
-
RETURN x + y;
|
379
|
-
END;
|
380
|
-
$$ LANGUAGE plpgsql;[0m
|
381
|
-
[1m[35m (10.6ms)[0m DROP VIEW required
|
382
|
-
PG::DependentObjectsStillExist: ERROR: cannot drop view required because other objects depend on it
|
383
|
-
DETAIL: view hello_world depends on view required
|
384
|
-
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
385
|
-
: DROP VIEW required
|
386
|
-
[1m[36m (18.0ms)[0m [1mDROP VIEW hello_world[0m
|
387
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
388
|
-
[1m[36m (0.2ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
389
|
-
PG::DuplicateTable: ERROR: relation "required" already exists
|
390
|
-
: CREATE VIEW required AS SELECT 1 as id
|
391
|
-
[1m[36m (2.5ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
392
|
-
BEGIN
|
393
|
-
RETURN x + y;
|
394
|
-
END;
|
395
|
-
$$ LANGUAGE plpgsql;[0m
|
396
|
-
[1m[35m (1.0ms)[0m DROP VIEW required
|
397
|
-
[1m[36m (0.4ms)[0m [1mDROP VIEW hello_world[0m
|
398
|
-
PG::UndefinedTable: ERROR: view "hello_world" does not exist
|
399
|
-
: DROP VIEW hello_world
|
400
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.4ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
401
|
-
[1m[36m (8.1ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
402
|
-
[1m[35m (6.6ms)[0m CREATE VIEW hello_world AS --!require required
|
403
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
404
|
-
[1m[36m (2.0ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
405
|
-
BEGIN
|
406
|
-
RETURN x + y;
|
407
|
-
END;
|
408
|
-
$$ LANGUAGE plpgsql;[0m
|
409
|
-
[1m[35m (0.6ms)[0m DROP VIEW required
|
410
|
-
PG::DependentObjectsStillExist: ERROR: cannot drop view required because other objects depend on it
|
411
|
-
DETAIL: view hello_world depends on view required
|
412
|
-
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
413
|
-
: DROP VIEW required
|
414
|
-
[1m[36m (0.9ms)[0m [1mDROP VIEW hello_world[0m
|
415
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.5ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
416
|
-
[1m[36m (0.3ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
417
|
-
PG::DuplicateTable: ERROR: relation "required" already exists
|
418
|
-
: CREATE VIEW required AS SELECT 1 as id
|
419
|
-
[1m[36m (2.1ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
420
|
-
BEGIN
|
421
|
-
RETURN x + y;
|
422
|
-
END;
|
423
|
-
$$ LANGUAGE plpgsql;[0m
|
424
|
-
[1m[35m (0.9ms)[0m DROP VIEW required
|
425
|
-
[1m[36m (0.3ms)[0m [1mDROP VIEW hello_world[0m
|
426
|
-
PG::UndefinedTable: ERROR: view "hello_world" does not exist
|
427
|
-
: DROP VIEW hello_world
|
428
|
-
[1m[36m (2.0ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
429
|
-
BEGIN
|
430
|
-
RETURN x + y;
|
431
|
-
END;
|
432
|
-
$$ LANGUAGE plpgsql;[0m
|
433
|
-
[1m[35m (0.3ms)[0m DROP VIEW required
|
434
|
-
PG::UndefinedTable: ERROR: view "required" does not exist
|
435
|
-
: DROP VIEW required
|
436
|
-
[1m[36m (2.1ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
1
|
+
[1m[36m (32.7ms)[0m [1mCREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
|
437
2
|
BEGIN
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
[1m[35m (0.3ms)[0m DROP VIEW required
|
442
|
-
PG::UndefinedTable: ERROR: view "required" does not exist
|
443
|
-
: DROP VIEW required
|
444
|
-
[1m[36m (2.0ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
445
|
-
BEGIN
|
446
|
-
RETURN x + y;
|
447
|
-
END;
|
448
|
-
$$ LANGUAGE plpgsql;[0m
|
449
|
-
[1m[35m (0.3ms)[0m DROP VIEW required
|
450
|
-
PG::UndefinedTable: ERROR: view "required" does not exist
|
451
|
-
: DROP VIEW required
|
452
|
-
[1m[36m (0.2ms)[0m [1mDROP VIEW hello_world[0m
|
453
|
-
PG::UndefinedTable: ERROR: view "hello_world" does not exist
|
454
|
-
: DROP VIEW hello_world
|
455
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.3ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
456
|
-
[1m[36m (6.7ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
457
|
-
[1m[35m (6.6ms)[0m CREATE VIEW hello_world AS --!require required
|
458
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
459
|
-
[1m[36m (2.3ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
460
|
-
BEGIN
|
461
|
-
RETURN x + y;
|
462
|
-
END;
|
463
|
-
$$ LANGUAGE plpgsql;[0m
|
464
|
-
[1m[35m (0.7ms)[0m DROP VIEW required
|
465
|
-
PG::DependentObjectsStillExist: ERROR: cannot drop view required because other objects depend on it
|
466
|
-
DETAIL: view hello_world depends on view required
|
467
|
-
HINT: Use DROP ... CASCADE to drop the dependent objects too.
|
468
|
-
: DROP VIEW required
|
469
|
-
[1m[36m (3.0ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
470
|
-
BEGIN
|
471
|
-
RETURN x + y;
|
472
|
-
END;
|
473
|
-
$$ LANGUAGE plpgsql;[0m
|
474
|
-
[1m[36m (1.4ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
475
|
-
BEGIN
|
476
|
-
RETURN x + y;
|
477
|
-
END;
|
478
|
-
$$ LANGUAGE plpgsql;[0m
|
479
|
-
[1m[35m (1.2ms)[0m DROP VIEW hello_world
|
480
|
-
[1m[36m (0.6ms)[0m [1mDROP VIEW required[0m
|
481
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.3ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
482
|
-
[1m[36m (12.4ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
483
|
-
[1m[35m (12.6ms)[0m CREATE VIEW hello_world AS --!require required
|
484
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
485
|
-
[1m[36m (2.3ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
486
|
-
BEGIN
|
487
|
-
RETURN x + y;
|
488
|
-
END;
|
489
|
-
$$ LANGUAGE plpgsql;[0m
|
490
|
-
[1m[35m (7.2ms)[0m DROP VIEW hello_world
|
491
|
-
[1m[36m (6.7ms)[0m [1mDROP VIEW required[0m
|
492
|
-
[1m[35mActiveRecord::SchemaMigration Load (0.7ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
493
|
-
[1m[36m (13.2ms)[0m [1mCREATE VIEW required AS SELECT 1 as id[0m
|
494
|
-
[1m[35m (7.1ms)[0m CREATE VIEW hello_world AS --!require required
|
495
|
-
SELECT 'HelloWorld' WHERE ( SELECT id FROM required ) IN (1)
|
496
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
497
|
-
[1m[36m (2.0ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
498
|
-
BEGIN
|
499
|
-
RETURN x + y;
|
500
|
-
END;
|
501
|
-
$$ LANGUAGE plpgsql;[0m
|
502
|
-
[1m[35m (6.1ms)[0m CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
|
503
|
-
BEGIN
|
504
|
-
IF x[0] > x[1] THEN
|
505
|
-
RETURN ARRAY[x[1], x[0]];
|
3
|
+
-- Note to myself: selection in array start at 1, not at zero !
|
4
|
+
IF x[1]::int > x[2]::int THEN
|
5
|
+
RETURN ARRAY[x[2], x[1]];
|
506
6
|
ELSE
|
507
7
|
RETURN x;
|
508
8
|
END IF;
|
509
9
|
END;
|
510
|
-
$$ LANGUAGE plpgsql
|
511
|
-
[1m[
|
512
|
-
|
513
|
-
|
514
|
-
[1m[
|
515
|
-
|
516
|
-
: DROP VIEW messages
|
517
|
-
[1m[36m (7.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL) [0m
|
518
|
-
[1m[35m (0.9ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
519
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
10
|
+
$$ LANGUAGE plpgsql;[0m
|
11
|
+
[1m[35m (28.1ms)[0m DROP VIEW chats
|
12
|
+
[1m[36m (0.2ms)[0m [1mDROP VIEW messages[0m
|
13
|
+
[1m[35m (25.0ms)[0m CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
|
14
|
+
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
15
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
520
16
|
Migrating to CreateTestTables (20160208084226)
|
521
|
-
[1m[
|
522
|
-
[1m[
|
523
|
-
[1m[
|
524
|
-
[1m[
|
525
|
-
[1m[
|
526
|
-
[1m[
|
527
|
-
[1m[
|
528
|
-
[1m[
|
529
|
-
[1m[
|
530
|
-
[1m[
|
17
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
18
|
+
[1m[35m (25.7ms)[0m CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
19
|
+
[1m[36m (0.8ms)[0m [1mCREATE INDEX "index_users_on_name" ON "users" ("name")[0m
|
20
|
+
[1m[35m (2.4ms)[0m CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
21
|
+
[1m[36m (0.6ms)[0m [1mCREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")[0m
|
22
|
+
[1m[35m (1.1ms)[0m CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
|
23
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ($1)[0m [["version", "20160208084226"]]
|
24
|
+
[1m[35m (5.9ms)[0m COMMIT
|
25
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
26
|
+
[1m[35m (1.9ms)[0m SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
531
27
|
FROM pg_constraint c
|
532
28
|
JOIN pg_class t1 ON c.conrelid = t1.oid
|
533
29
|
JOIN pg_class t2 ON c.confrelid = t2.oid
|
@@ -538,8 +34,8 @@ WHERE c.contype = 'f'
|
|
538
34
|
AND t1.relname = 'user_messages'
|
539
35
|
AND t3.nspname = ANY (current_schemas(false))
|
540
36
|
ORDER BY c.conname
|
541
|
-
|
542
|
-
[1m[
|
37
|
+
|
38
|
+
[1m[36m (1.5ms)[0m [1mSELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
543
39
|
FROM pg_constraint c
|
544
40
|
JOIN pg_class t1 ON c.conrelid = t1.oid
|
545
41
|
JOIN pg_class t2 ON c.confrelid = t2.oid
|
@@ -550,8 +46,8 @@ WHERE c.contype = 'f'
|
|
550
46
|
AND t1.relname = 'users'
|
551
47
|
AND t3.nspname = ANY (current_schemas(false))
|
552
48
|
ORDER BY c.conname
|
553
|
-
|
554
|
-
[1m[
|
49
|
+
[0m
|
50
|
+
[1m[35m (7.5ms)[0m CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
|
555
51
|
FROM
|
556
52
|
(SELECT u2.name as receiver_name, u2.id as receiver_id,
|
557
53
|
u1.name as sender_name, u1.id as sender_id,
|
@@ -567,30 +63,37 @@ FROM
|
|
567
63
|
INNER JOIN user_messages um ON ( u1.id = um.to_id )
|
568
64
|
INNER JOIN users u2 ON ( u2.id = um.from_id )
|
569
65
|
ORDER BY created_at ASC
|
570
|
-
) AS _
|
571
|
-
[1m[
|
66
|
+
) AS _
|
67
|
+
[1m[36m (12.1ms)[0m [1mCREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id]) AS ids,
|
572
68
|
MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
|
573
69
|
FROM messages
|
574
|
-
GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])
|
575
|
-
[1m[36m (
|
576
|
-
BEGIN
|
577
|
-
RETURN x + y;
|
578
|
-
END;
|
579
|
-
$$ LANGUAGE plpgsql;[0m
|
580
|
-
[1m[35m (0.7ms)[0m CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
|
70
|
+
GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])[0m
|
71
|
+
[1m[36m (20.7ms)[0m [1mCREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
|
581
72
|
BEGIN
|
582
|
-
|
583
|
-
|
73
|
+
-- Note to myself: selection in array start at 1, not at zero !
|
74
|
+
IF x[1]::int > x[2]::int THEN
|
75
|
+
RETURN ARRAY[x[2], x[1]];
|
584
76
|
ELSE
|
585
77
|
RETURN x;
|
586
78
|
END IF;
|
587
79
|
END;
|
588
|
-
$$ LANGUAGE plpgsql
|
589
|
-
[1m[
|
590
|
-
[1m[
|
591
|
-
[1m[
|
592
|
-
[1m[
|
593
|
-
[1m[
|
80
|
+
$$ LANGUAGE plpgsql;[0m
|
81
|
+
[1m[35m (6.0ms)[0m DROP VIEW chats
|
82
|
+
[1m[36m (0.2ms)[0m [1mDROP VIEW messages[0m
|
83
|
+
[1m[35m (17.9ms)[0m CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
|
84
|
+
[1m[36m (5.4ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
85
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
86
|
+
Migrating to CreateTestTables (20160208084226)
|
87
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
88
|
+
[1m[35m (18.4ms)[0m CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
89
|
+
[1m[36m (5.2ms)[0m [1mCREATE INDEX "index_users_on_name" ON "users" ("name")[0m
|
90
|
+
[1m[35m (2.0ms)[0m CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
91
|
+
[1m[36m (0.6ms)[0m [1mCREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")[0m
|
92
|
+
[1m[35m (0.5ms)[0m CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
|
93
|
+
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ($1)[0m [["version", "20160208084226"]]
|
94
|
+
[1m[35m (11.9ms)[0m COMMIT
|
95
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
96
|
+
[1m[35m (1.9ms)[0m SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
594
97
|
FROM pg_constraint c
|
595
98
|
JOIN pg_class t1 ON c.conrelid = t1.oid
|
596
99
|
JOIN pg_class t2 ON c.confrelid = t2.oid
|
@@ -601,8 +104,8 @@ WHERE c.contype = 'f'
|
|
601
104
|
AND t1.relname = 'user_messages'
|
602
105
|
AND t3.nspname = ANY (current_schemas(false))
|
603
106
|
ORDER BY c.conname
|
604
|
-
|
605
|
-
[1m[
|
107
|
+
|
108
|
+
[1m[36m (1.4ms)[0m [1mSELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
606
109
|
FROM pg_constraint c
|
607
110
|
JOIN pg_class t1 ON c.conrelid = t1.oid
|
608
111
|
JOIN pg_class t2 ON c.confrelid = t2.oid
|
@@ -613,8 +116,8 @@ WHERE c.contype = 'f'
|
|
613
116
|
AND t1.relname = 'users'
|
614
117
|
AND t3.nspname = ANY (current_schemas(false))
|
615
118
|
ORDER BY c.conname
|
616
|
-
|
617
|
-
[1m[
|
119
|
+
[0m
|
120
|
+
[1m[35m (13.8ms)[0m CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
|
618
121
|
FROM
|
619
122
|
(SELECT u2.name as receiver_name, u2.id as receiver_id,
|
620
123
|
u1.name as sender_name, u1.id as sender_id,
|
@@ -630,53 +133,37 @@ FROM
|
|
630
133
|
INNER JOIN user_messages um ON ( u1.id = um.to_id )
|
631
134
|
INNER JOIN users u2 ON ( u2.id = um.from_id )
|
632
135
|
ORDER BY created_at ASC
|
633
|
-
) AS _
|
634
|
-
[1m[
|
136
|
+
) AS _
|
137
|
+
[1m[36m (6.7ms)[0m [1mCREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id]) AS ids,
|
635
138
|
MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
|
636
139
|
FROM messages
|
637
|
-
GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])
|
638
|
-
[1m[36m (
|
639
|
-
[1m[35m (0.3ms)[0m SELECT 1;
|
640
|
-
[1m[36m (0.3ms)[0m [1mSELECT 2;[0m
|
641
|
-
[1m[35m (0.2ms)[0m SELECT 2;
|
642
|
-
[1m[36m (0.3ms)[0m [1mSELECT 2[0m
|
643
|
-
[1m[35m (8.3ms)[0m SELECT tuple_sort(ARRAY[1,3])
|
644
|
-
[1m[36m (0.9ms)[0m [1mSELECT tuple_sort(ARRAY[3,1])[0m
|
645
|
-
[1m[35m (0.9ms)[0m SELECT tuple_sort(ARRAY[3,1])
|
646
|
-
[1m[36m (2.4ms)[0m [1mCREATE OR REPLACE FUNCTION add (x integer, y integer) RETURNS integer AS $$
|
140
|
+
GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])[0m
|
141
|
+
[1m[36m (8.3ms)[0m [1mCREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
|
647
142
|
BEGIN
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
[1m[35m (0.6ms)[0m CREATE OR REPLACE FUNCTION tuple_sort (x int[]) RETURNS int[] AS $$
|
652
|
-
BEGIN
|
653
|
-
IF x[0]::int > x[1]::int THEN
|
654
|
-
RETURN ARRAY[x[1], x[0]];
|
143
|
+
-- Note to myself: selection in array start at 1, not at zero !
|
144
|
+
IF x[1]::int > x[2]::int THEN
|
145
|
+
RETURN ARRAY[x[2], x[1]];
|
655
146
|
ELSE
|
656
147
|
RETURN x;
|
657
148
|
END IF;
|
658
149
|
END;
|
659
|
-
$$ LANGUAGE plpgsql
|
660
|
-
[1m[
|
661
|
-
|
662
|
-
|
663
|
-
[1m[
|
664
|
-
|
665
|
-
: DROP VIEW messages
|
666
|
-
[1m[36m (2.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL) [0m
|
667
|
-
[1m[35m (1.2ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
668
|
-
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
150
|
+
$$ LANGUAGE plpgsql;[0m
|
151
|
+
[1m[35m (5.5ms)[0m DROP VIEW chats
|
152
|
+
[1m[36m (0.2ms)[0m [1mDROP VIEW messages[0m
|
153
|
+
[1m[35m (17.5ms)[0m CREATE TABLE "schema_migrations" ("version" character varying NOT NULL)
|
154
|
+
[1m[36m (5.2ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
155
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
669
156
|
Migrating to CreateTestTables (20160208084226)
|
670
|
-
[1m[
|
671
|
-
[1m[
|
672
|
-
[1m[
|
673
|
-
[1m[
|
674
|
-
[1m[
|
675
|
-
[1m[
|
676
|
-
[1m[
|
677
|
-
[1m[
|
678
|
-
[1m[
|
679
|
-
[1m[
|
157
|
+
[1m[36m (0.1ms)[0m [1mBEGIN[0m
|
158
|
+
[1m[35m (18.8ms)[0m CREATE TABLE "users" ("id" serial primary key, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
159
|
+
[1m[36m (4.1ms)[0m [1mCREATE INDEX "index_users_on_name" ON "users" ("name")[0m
|
160
|
+
[1m[35m (2.1ms)[0m CREATE TABLE "user_messages" ("id" serial primary key, "from_id" integer, "to_id" integer, "content" text, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
|
161
|
+
[1m[36m (0.5ms)[0m [1mCREATE INDEX "index_user_messages_on_from_id" ON "user_messages" ("from_id")[0m
|
162
|
+
[1m[35m (0.6ms)[0m CREATE INDEX "index_user_messages_on_to_id" ON "user_messages" ("to_id")
|
163
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ($1)[0m [["version", "20160208084226"]]
|
164
|
+
[1m[35m (11.0ms)[0m COMMIT
|
165
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
166
|
+
[1m[35m (2.0ms)[0m SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
680
167
|
FROM pg_constraint c
|
681
168
|
JOIN pg_class t1 ON c.conrelid = t1.oid
|
682
169
|
JOIN pg_class t2 ON c.confrelid = t2.oid
|
@@ -687,8 +174,8 @@ WHERE c.contype = 'f'
|
|
687
174
|
AND t1.relname = 'user_messages'
|
688
175
|
AND t3.nspname = ANY (current_schemas(false))
|
689
176
|
ORDER BY c.conname
|
690
|
-
|
691
|
-
[1m[
|
177
|
+
|
178
|
+
[1m[36m (1.4ms)[0m [1mSELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
|
692
179
|
FROM pg_constraint c
|
693
180
|
JOIN pg_class t1 ON c.conrelid = t1.oid
|
694
181
|
JOIN pg_class t2 ON c.confrelid = t2.oid
|
@@ -699,9 +186,9 @@ WHERE c.contype = 'f'
|
|
699
186
|
AND t1.relname = 'users'
|
700
187
|
AND t3.nspname = ANY (current_schemas(false))
|
701
188
|
ORDER BY c.conname
|
702
|
-
|
703
|
-
[1m[
|
704
|
-
FROM
|
189
|
+
[0m
|
190
|
+
[1m[35m (7.3ms)[0m CREATE VIEW messages AS SELECT DISTINCT _.receiver_name, _.receiver_id, _.sender_name, _.sender_id, _.content, _.updated_at, _.created_at
|
191
|
+
FROM
|
705
192
|
(SELECT u2.name as receiver_name, u2.id as receiver_id,
|
706
193
|
u1.name as sender_name, u1.id as sender_id,
|
707
194
|
um.content as content, um.updated_at as updated_at, um.created_at as created_at
|
@@ -716,10 +203,8 @@ FROM
|
|
716
203
|
INNER JOIN user_messages um ON ( u1.id = um.to_id )
|
717
204
|
INNER JOIN users u2 ON ( u2.id = um.from_id )
|
718
205
|
ORDER BY created_at ASC
|
719
|
-
) AS _
|
720
|
-
[1m[
|
206
|
+
) AS _
|
207
|
+
[1m[36m (6.3ms)[0m [1mCREATE VIEW chats AS SELECT tuple_sort(ARRAY[sender_id, receiver_id]) AS ids,
|
721
208
|
MIN(created_at) as created_at, MAX(updated_at) as updated_at, COUNT(*) as number_of_messages
|
722
209
|
FROM messages
|
723
|
-
GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])
|
724
|
-
[1m[36m (1.0ms)[0m [1mSELECT tuple_sort(ARRAY[3,1])[0m
|
725
|
-
[1m[35m (2.1ms)[0m SELECT tuple_sort(ARRAY[1,3])
|
210
|
+
GROUP BY tuple_sort(ARRAY[sender_id, receiver_id])[0m
|