scenic-oracle_adapter 1.3.2 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6af72024c360af2c3e802a98dad25c65109fd6d79eda9b7a0d6e43c4829d92f
4
- data.tar.gz: 6c3c8e11b6676d69dc79893a2196f7e0a5f8babb04d20e714d2f63b1d5f00d67
3
+ metadata.gz: 453bc175d2fa922a314a781064fb63a6415dc3be36aa096baa9d52c77f1542ed
4
+ data.tar.gz: 3d5ed519bc3ce673c934bc32d310b298c8d525e12fd089abf8a1201674036d4e
5
5
  SHA512:
6
- metadata.gz: 2df4de941f6d6536a225811124efeb2423e186f4ea741b58d6144019c77252cf7b98c203e9dde881325b7892f75cae27b22764acf2f2170ca2262230d4671e34
7
- data.tar.gz: 2eb947aa0e7d850bcd9a6aceaa9abda6fad9eab0fd9d4b68a26c54683d1054132ce849a4f0a47c4f7d6a3e8c4563a89572096008396860ac0872b06cc059c36a
6
+ metadata.gz: cb0722b1989112a9b5f48c7fdbd7b303d4fd7baf5b577dc002bcd9d174e795b120715b725ffdd72cc562f7522b09a9eea13cc8e4984dccd53d929bdea2b1b0c4
7
+ data.tar.gz: df2366ae4965f197b205f7148ecef307f17695f3c05815b17ee681bf230b53c2bb1edfc7831b854d590022422fbfc42c3ce00e526ff7d14f719ecc8399ae5ce6
data/README.md CHANGED
@@ -28,14 +28,14 @@ end
28
28
 
29
29
  While you can use any Oracle instance for development, it's easiest to use Docker and docker compose.
30
30
 
31
- Note that the Oracle container takes up to two minutes to start and become available. If you're doing active development you probably want to start the containers in detached mode: `docker-compose up -d`. This starts everything in the background and allows you to use `docker compose exec` to run commands on the already running containers:
31
+ Note that the Oracle container takes up to two minutes to start and become available. If you're doing active development you probably want to start the containers in detached mode: `docker compose up -d`. This starts everything in the background and allows you to use `docker compose exec` to run commands on the already running containers:
32
32
 
33
33
  - Run specs: `docker compose exec gem bin/test`
34
34
  - Open a console: `docker compose exec gem bin/console`
35
35
 
36
36
  ## Tests
37
37
 
38
- If you just want to run the test suite you can use `docker-compose run --rm gem bin/test`. Again, because the Oracle container takes so long to start up, the first execution will take a while. The test suite will wait for the database container to become available. Subsequent executions will be faster.
38
+ If you just want to run the test suite you can use `docker compose run --rm gem bin/test`. Again, because the Oracle container takes so long to start up, the first execution will take a while. The test suite will wait for the database container to become available. Subsequent executions will be faster.
39
39
 
40
40
  By default, the test suite will attempt to connect to a local docker Oracle instance (see `spec/spec_helper.rb` for connection details).
41
41
  You can override the database URL by supplying a value to the `DATABASE_URL` environment variable.
data/docker-compose.yml CHANGED
@@ -11,8 +11,6 @@ services:
11
11
  build: .
12
12
  volumes:
13
13
  - .:/app
14
- environment:
15
- - TERM=dumb
16
14
  stdin_open: true
17
15
  tty: true
18
16
  depends_on:
@@ -13,13 +13,11 @@ module Scenic
13
13
  end
14
14
 
15
15
  def views
16
- all_view_objects.sort_by do |view_object|
17
- dependency_order.index(view_object.name)
18
- end
16
+ sorted_dependency_views + sorted_missing_dependency_views
19
17
  end
20
18
 
21
19
  def create_view(name, definition)
22
- execute("create view #{quote_table_name(name)} as #{definition}")
20
+ execute("create view #{quote_table_name(name)} as #{trimmed_definition(definition)}")
23
21
  end
24
22
 
25
23
  def drop_view(name)
@@ -27,7 +25,7 @@ module Scenic
27
25
  end
28
26
 
29
27
  def replace_view(name, definition)
30
- execute("create or replace view #{quote_table_name(name)} as #{definition}")
28
+ execute("create or replace view #{quote_table_name(name)} as #{trimmed_definition(definition)}")
31
29
  end
32
30
 
33
31
  def update_view(name, definition)
@@ -36,7 +34,7 @@ module Scenic
36
34
  end
37
35
 
38
36
  def create_materialized_view(name, definition, no_data: false)
39
- execute("create materialized view #{quote_table_name(name)} #{'build deferred' if no_data} as #{definition}")
37
+ execute("create materialized view #{quote_table_name(name)} #{'build deferred' if no_data} as #{trimmed_definition(definition)}")
40
38
  end
41
39
 
42
40
  def update_materialized_view(name, definition, no_data: false)
@@ -71,14 +69,24 @@ module Scenic
71
69
  private
72
70
 
73
71
  def view_dependencies
74
- select_all(<<~EOSQL)
72
+ @view_dependencies ||= select_all(<<~EOSQL)
75
73
  select lower(uo.object_name) as name, lower(ud.referenced_name) as dependency
76
74
  from user_objects uo
77
- left join user_dependencies ud on uo.object_name = ud.name
78
- and ud.referenced_type in ('VIEW', 'MATERIALIZED VIEW')
75
+ left join user_dependencies ud on
76
+ uo.object_name = ud.name
77
+ and (
78
+ (ud.referenced_type in ('VIEW', 'MATERIALIZED VIEW'))
79
+ OR
80
+ (
81
+ ud.referenced_type IN ('TABLE')
82
+ AND
83
+ ud.referenced_name in (select mview_name from user_mviews)
84
+ )
85
+ )
79
86
  and ud.referenced_name in (select object_name from user_objects)
80
87
  and ud.referenced_owner = user
81
88
  where uo.object_type in ('VIEW', 'MATERIALIZED VIEW')
89
+ order by lower(uo.object_name), lower(ud.referenced_name)
82
90
  EOSQL
83
91
  end
84
92
 
@@ -93,6 +101,22 @@ module Scenic
93
101
  views_hash.tsort
94
102
  end
95
103
 
104
+ def sorted_dependency_views
105
+ all_view_objects.filter do |view|
106
+ dependency_order.include?(view.name)
107
+ end.sort_by do |view|
108
+ dependency_order.index(view.name)
109
+ end
110
+ end
111
+
112
+ def sorted_missing_dependency_views
113
+ all_view_objects.filter do |view|
114
+ dependency_order.exclude?(view.name)
115
+ end.sort_by do |view|
116
+ view.name
117
+ end
118
+ end
119
+
96
120
  def all_views
97
121
  select_all("select lower(view_name) name, text definition from user_views").map do |view|
98
122
  Scenic::View.new(name: view["name"], definition: view["definition"], materialized: false)
@@ -112,6 +136,10 @@ module Scenic
112
136
  def refresh_dependencies_for(name)
113
137
  Scenic::Adapters::Oracle::RefreshDependencies.call(name, self, connection)
114
138
  end
139
+
140
+ def trimmed_definition(sql)
141
+ sql.strip.sub(/;$/, "").strip
142
+ end
115
143
  end
116
144
  end
117
145
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Scenic
4
4
  module OracleAdapter
5
- VERSION = "1.3.2"
5
+ VERSION = "1.3.4"
6
6
  end
7
7
  end
@@ -4,7 +4,7 @@ class TSortableHash < Hash
4
4
  include TSort
5
5
 
6
6
  alias_method :tsort_each_node, :each_key
7
- def tsort_each_child(node, &)
8
- fetch(node).each(&)
7
+ def tsort_each_child(node, &block)
8
+ fetch(node).each(&block)
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scenic-oracle_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Dinger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-04 00:00:00.000000000 Z
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scenic
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  requirements: []
161
- rubygems_version: 3.5.9
161
+ rubygems_version: 3.5.4
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: Oracle adapter for thoughtbot/scenic