dbviewer 0.5.7 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +33 -6
- data/app/assets/javascripts/dbviewer/connections.js +70 -0
- data/app/controllers/concerns/dbviewer/database_operations.rb +110 -6
- data/app/controllers/dbviewer/api/entity_relationship_diagrams_controller.rb +30 -60
- data/app/controllers/dbviewer/api/tables_controller.rb +20 -0
- data/app/controllers/dbviewer/connections_controller.rb +35 -0
- data/app/controllers/dbviewer/home_controller.rb +5 -0
- data/app/helpers/dbviewer/application_helper.rb +46 -8
- data/app/views/dbviewer/connections/index.html.erb +119 -0
- data/app/views/dbviewer/connections/new.html.erb +79 -0
- data/app/views/dbviewer/shared/_tables_sidebar.html.erb +49 -0
- data/app/views/dbviewer/tables/index.html.erb +0 -8
- data/app/views/dbviewer/tables/show.html.erb +132 -8
- data/app/views/layouts/dbviewer/application.html.erb +22 -1
- data/config/routes.rb +15 -0
- data/lib/dbviewer/configuration.rb +17 -0
- data/lib/dbviewer/database/dynamic_model_factory.rb +4 -12
- data/lib/dbviewer/database/manager.rb +19 -10
- data/lib/dbviewer/datatable/query_operations.rb +21 -1
- data/lib/dbviewer/version.rb +1 -1
- data/lib/dbviewer.rb +37 -4
- metadata +7 -2
@@ -273,9 +273,29 @@ module Dbviewer
|
|
273
273
|
# Apply remaining simple column filters
|
274
274
|
filters.each do |column, value|
|
275
275
|
next unless column_exists?(table_name, column)
|
276
|
-
|
276
|
+
|
277
|
+
# Check if this is a column operator field
|
278
|
+
if column.end_with?("_operator")
|
279
|
+
next # Skip operator fields - they're processed with their column
|
280
|
+
end
|
277
281
|
|
278
282
|
column_sym = column.to_sym
|
283
|
+
operator = filters["#{column}_operator"]
|
284
|
+
|
285
|
+
# Special handling for is_null and is_not_null operators that don't need a value
|
286
|
+
if operator == "is_null" || value == "is_null"
|
287
|
+
Rails.logger.debug("[DBViewer] Applying null filter: #{column} IS NULL")
|
288
|
+
query = query.where("#{column} IS NULL")
|
289
|
+
next
|
290
|
+
elsif operator == "is_not_null" || value == "is_not_null"
|
291
|
+
Rails.logger.debug("[DBViewer] Applying not null filter: #{column} IS NOT NULL")
|
292
|
+
query = query.where("#{column} IS NOT NULL")
|
293
|
+
next
|
294
|
+
end
|
295
|
+
|
296
|
+
# Skip if no value and we're not using a special operator
|
297
|
+
next if value.blank? || value == "is_null" || value == "is_not_null"
|
298
|
+
|
279
299
|
Rails.logger.debug("[DBViewer] Applying filter: #{column} = #{value}")
|
280
300
|
|
281
301
|
# Handle different types of filtering
|
data/lib/dbviewer/version.rb
CHANGED
data/lib/dbviewer.rb
CHANGED
@@ -57,10 +57,43 @@ module Dbviewer
|
|
57
57
|
query_logging_mode: configuration.query_logging_mode
|
58
58
|
)
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
# Check all configured connections
|
61
|
+
connection_errors = []
|
62
|
+
configuration.database_connections.each do |key, config|
|
63
|
+
begin
|
64
|
+
connection_class = nil
|
65
|
+
|
66
|
+
if config[:connection]
|
67
|
+
connection_class = config[:connection]
|
68
|
+
elsif config[:connection_class].is_a?(String)
|
69
|
+
# Try to load the class if it's defined as a string
|
70
|
+
begin
|
71
|
+
connection_class = config[:connection_class].constantize
|
72
|
+
rescue NameError => e
|
73
|
+
Rails.logger.warn "DBViewer could not load connection class #{config[:connection_class]}: #{e.message}"
|
74
|
+
next
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
if connection_class
|
79
|
+
connection = connection_class.connection
|
80
|
+
adapter_name = connection.adapter_name
|
81
|
+
Rails.logger.info "DBViewer successfully connected to #{config[:name] || key.to_s} database (#{adapter_name})"
|
82
|
+
|
83
|
+
# Store the resolved connection class back in the config
|
84
|
+
config[:connection] = connection_class
|
85
|
+
else
|
86
|
+
raise "No valid connection configuration found for #{key}"
|
87
|
+
end
|
88
|
+
rescue => e
|
89
|
+
connection_errors << { key: key, error: e.message }
|
90
|
+
Rails.logger.error "DBViewer could not connect to #{config[:name] || key.to_s} database: #{e.message}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
if connection_errors.length == configuration.database_connections.length
|
95
|
+
raise "DBViewer could not connect to any configured database"
|
96
|
+
end
|
64
97
|
end
|
65
98
|
|
66
99
|
# Initialize engine with default values or user-provided configuration
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbviewer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wailan Tirajoh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-05-
|
11
|
+
date: 2025-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- MIT-LICENSE
|
50
50
|
- README.md
|
51
51
|
- Rakefile
|
52
|
+
- app/assets/javascripts/dbviewer/connections.js
|
52
53
|
- app/assets/stylesheets/dbviewer/application.css
|
53
54
|
- app/assets/stylesheets/dbviewer/dbviewer.css
|
54
55
|
- app/assets/stylesheets/dbviewer/enhanced.css
|
@@ -61,6 +62,7 @@ files:
|
|
61
62
|
- app/controllers/dbviewer/api/queries_controller.rb
|
62
63
|
- app/controllers/dbviewer/api/tables_controller.rb
|
63
64
|
- app/controllers/dbviewer/application_controller.rb
|
65
|
+
- app/controllers/dbviewer/connections_controller.rb
|
64
66
|
- app/controllers/dbviewer/entity_relationship_diagrams_controller.rb
|
65
67
|
- app/controllers/dbviewer/home_controller.rb
|
66
68
|
- app/controllers/dbviewer/logs_controller.rb
|
@@ -69,9 +71,12 @@ files:
|
|
69
71
|
- app/jobs/dbviewer/application_job.rb
|
70
72
|
- app/mailers/dbviewer/application_mailer.rb
|
71
73
|
- app/models/dbviewer/application_record.rb
|
74
|
+
- app/views/dbviewer/connections/index.html.erb
|
75
|
+
- app/views/dbviewer/connections/new.html.erb
|
72
76
|
- app/views/dbviewer/entity_relationship_diagrams/index.html.erb
|
73
77
|
- app/views/dbviewer/home/index.html.erb
|
74
78
|
- app/views/dbviewer/logs/index.html.erb
|
79
|
+
- app/views/dbviewer/shared/_tables_sidebar.html.erb
|
75
80
|
- app/views/dbviewer/tables/_table_structure.html.erb
|
76
81
|
- app/views/dbviewer/tables/index.html.erb
|
77
82
|
- app/views/dbviewer/tables/mini_erd.html.erb
|