scenic-oracle_adapter 1.2.2 → 1.3.1

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: f01bd1470b251d8a09ce793abe0fe5cd65d8c0009b77e91d24ea90cca4e9b0e0
4
- data.tar.gz: 3b20468c050212c306d41b2b3a5d87c503e9d21227d0fcef1f438ee8a6ad2cd1
3
+ metadata.gz: 1d9bb94f1cec86d7abe41786c15d0bac531eef9b082099f8d4d498f0dee898a8
4
+ data.tar.gz: 3e2131ed37270bb8f39f8e7bdb67d82561461f266a59fa9387824282620f31d0
5
5
  SHA512:
6
- metadata.gz: 65d6dbd15912e620c490e6b42e84082178a4a5fa915c77b09d4bd3eef986427799b5d55d9f8e40ddeca15ff178a4743cd82e9beb2acf013ec94727a0a2ad9d8c
7
- data.tar.gz: a94d451afef4a0abb8570c25690fbe06565015f2b2f33d465649e30dbf45c128ca5265e8ebd8edcdd56f71e95d2286806beedaf20f1aac86e956c553b850dfc2
6
+ metadata.gz: a44e897ba0001c0e8f293c13648bf6062ac06d3980211515058ef80e1a4651a583434560d00420fcb4021d6953216ba0cda670378c0787bb4d6a259c46846b3a
7
+ data.tar.gz: 31c7ed943ce55a201b589da0c08cfa04cb6a27ee05dce313a7d5f229949973c997e4ee88e17f58ef936509ca9edca97b23754d722472db6361bb589b44ee98d7
@@ -12,10 +12,5 @@ jobs:
12
12
 
13
13
  steps:
14
14
  - uses: actions/checkout@v2
15
- - name: Login to Docker Hub
16
- uses: docker/login-action@v1
17
- with:
18
- username: ${{ secrets.DOCKER_HUB_USERNAME }}
19
- password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
20
15
  - name: Run tests
21
16
  run: docker-compose run gem rspec
data/Dockerfile CHANGED
@@ -1,16 +1,4 @@
1
- FROM --platform=linux/amd64 ruby:latest
2
-
3
- RUN curl -sLO 'https://download.oracle.com/otn_software/linux/instantclient/19600/instantclient-basic-linux.x64-19.6.0.0.0dbru.zip' && \
4
- curl -sLO 'https://download.oracle.com/otn_software/linux/instantclient/19600/instantclient-sdk-linux.x64-19.6.0.0.0dbru.zip' && \
5
- unzip instantclient-basic-linux.x64-19.6.0.0.0dbru.zip && \
6
- unzip instantclient-sdk-linux.x64-19.6.0.0.0dbru.zip && \
7
- rm instantclient-basic-linux.x64-19.6.0.0.0dbru.zip && \
8
- rm instantclient-sdk-linux.x64-19.6.0.0.0dbru.zip
9
-
10
- RUN apt update && \
11
- apt-get install libaio1
12
-
13
- ENV LD_LIBRARY_PATH /instantclient_19_6:$LD_LIBRARY_PATH
1
+ FROM ghcr.io/cdinger/oracle-ruby:3.3
14
2
 
15
3
  RUN mkdir /app
16
4
  WORKDIR /app
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # scenic-oracle_adapter [![Build Status](https://github.com/cdinger/scenic-oracle_adapter/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/cdinger/scenic-oracle_adapter/actions/workflows/ci.yml?query=branch%3Amaster)
1
+ # scenic-oracle_adapter
2
2
 
3
3
  An Oracle adapter for the [scenic](https://github.com/scenic-views/scenic) rubygem.
4
4
 
@@ -26,12 +26,12 @@ end
26
26
 
27
27
  ## Development
28
28
 
29
- While you can use any Oracle instance for development, it's easiest to use Docker and docker-compose.
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
- - Run specs: `docker-compose exec gem bin/test`
34
- - Open a console: `docker-compose exec gem bin/console`
33
+ - Run specs: `docker compose exec gem bin/test`
34
+ - Open a console: `docker compose exec gem bin/console`
35
35
 
36
36
  ## Tests
37
37
 
data/docker-compose.yml CHANGED
@@ -1,20 +1,16 @@
1
- version: '3'
2
1
  services:
3
2
  db:
4
- image: container-registry.oracle.com/database/express:latest
3
+ image: ghcr.io/cdinger/oracle:19.3.0-ee
5
4
  volumes:
6
5
  - db:/opt/oracle/oradata
7
6
  environment:
8
7
  - ORACLE_PWD=thisisonlyusedlocally
9
8
  ports:
10
9
  - "127.0.0.1:1521:1521"
11
- - "127.0.0.1:5500:5500"
12
10
  gem:
13
11
  build: .
14
12
  volumes:
15
13
  - .:/app
16
- environment:
17
- - TERM=dumb
18
14
  stdin_open: true
19
15
  tty: true
20
16
  depends_on:
@@ -3,6 +3,7 @@
3
3
  require_relative "oracle/index_reapplication"
4
4
  require_relative "oracle/indexes"
5
5
  require_relative "oracle/refresh_dependencies"
6
+ require "tsortable_hash"
6
7
 
7
8
  module Scenic
8
9
  module Adapters
@@ -12,7 +13,9 @@ module Scenic
12
13
  end
13
14
 
14
15
  def views
15
- all_views + all_mviews
16
+ all_view_objects.sort_by do |view_object|
17
+ dependency_order.index(view_object.name)
18
+ end
16
19
  end
17
20
 
18
21
  def create_view(name, definition)
@@ -58,11 +61,36 @@ module Scenic
58
61
  EOSQL
59
62
  end
60
63
 
64
+ def populated?(name)
65
+ !select_value("select last_refresh_date from user_mviews where mview_name = '#{name.upcase}'").nil?
66
+ end
67
+
61
68
  delegate :connection, to: :@connectable
62
- delegate :select_all, :execute, :quote_table_name, to: :connection
69
+ delegate :select_all, :select_value, :execute, :quote_table_name, to: :connection
63
70
 
64
71
  private
65
72
 
73
+ def view_dependencies
74
+ select_all(<<~EOSQL)
75
+ select lower(uo.object_name) as name, lower(ud.referenced_name) as dependency
76
+ 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')
79
+ where uo.object_type in ('VIEW', 'MATERIALIZED VIEW')
80
+ EOSQL
81
+ end
82
+
83
+ def dependency_order
84
+ views_hash = TSortableHash.new
85
+
86
+ view_dependencies.each do |view_data|
87
+ views_hash[view_data["name"]] ||= []
88
+ views_hash[view_data["name"]] << view_data["dependency"] unless view_data["dependency"].nil?
89
+ end
90
+
91
+ views_hash.tsort
92
+ end
93
+
66
94
  def all_views
67
95
  select_all("select lower(view_name) name, text definition from user_views").map do |view|
68
96
  Scenic::View.new(name: view["name"], definition: view["definition"], materialized: false)
@@ -75,6 +103,10 @@ module Scenic
75
103
  end
76
104
  end
77
105
 
106
+ def all_view_objects
107
+ all_views + all_mviews
108
+ end
109
+
78
110
  def refresh_dependencies_for(name)
79
111
  Scenic::Adapters::Oracle::RefreshDependencies.call(name, self, connection)
80
112
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Scenic
4
4
  module OracleAdapter
5
- VERSION = "1.2.2"
5
+ VERSION = "1.3.1"
6
6
  end
7
7
  end
@@ -0,0 +1,10 @@
1
+ require "tsort"
2
+
3
+ class TSortableHash < Hash
4
+ include TSort
5
+
6
+ alias_method :tsort_each_node, :each_key
7
+ def tsort_each_child(node, &)
8
+ fetch(node).each(&)
9
+ end
10
+ end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency "scenic", "~> 1.7.0"
25
+ spec.add_dependency "scenic", "= 1.8.0"
26
26
  spec.add_dependency "activerecord-oracle_enhanced-adapter", ">= 1.5.0"
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 2.0"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scenic-oracle_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Dinger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-27 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scenic
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.7.0
19
+ version: 1.8.0
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: 1.7.0
26
+ version: 1.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord-oracle_enhanced-adapter
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +137,7 @@ files:
137
137
  - lib/scenic/adapters/oracle/refresh_dependencies.rb
138
138
  - lib/scenic/oracle_adapter.rb
139
139
  - lib/scenic/oracle_adapter/version.rb
140
+ - lib/tsortable_hash.rb
140
141
  - scenic-oracle_adapter.gemspec
141
142
  homepage: https://github.com/cdinger/scenic-oracle_adapter
142
143
  licenses:
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  - !ruby/object:Gem::Version
158
159
  version: '0'
159
160
  requirements: []
160
- rubygems_version: 3.3.7
161
+ rubygems_version: 3.5.9
161
162
  signing_key:
162
163
  specification_version: 4
163
164
  summary: Oracle adapter for thoughtbot/scenic