brick 1.0.221 → 1.0.222
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brick/config.rb +8 -0
- data/lib/brick/extensions.rb +3 -3
- data/lib/brick/rails/form_tags.rb +1 -1
- data/lib/brick/version_number.rb +1 -1
- data/lib/brick.rb +1 -1
- data/lib/generators/brick/install_generator.rb +20 -4
- data/lib/generators/brick/migration_builder.rb +3 -2
- data/lib/generators/brick/seeds_generator.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3e0a0e804ed376999842c2f8f31ba5b2db0ca019bce0e94b6b85b5869256667
|
4
|
+
data.tar.gz: 27cea38b19cec28e95515256aafd2e4a7fb1a220d3147d1123edd2ac74aa45b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4de80d5d689bb00369190f4b02093f56320309e6de856ed1e69ca570996e73987d6c27bbe3cfd124fae9ec274a19411d3935900c16e1d81e19cd40542f3714da
|
7
|
+
data.tar.gz: 453ac262c8314586ec6b1f68051871288659d4efffdbc442880efdae06ab435637508f7667e7dea93d543bbe82b291523d36fc2bfd67f801852c5416db8acdf6
|
data/lib/brick/config.rb
CHANGED
@@ -482,6 +482,14 @@ module Brick
|
|
482
482
|
@mutex.synchronize { @ignore_migration_fks = relations }
|
483
483
|
end
|
484
484
|
|
485
|
+
def salesforce_mode
|
486
|
+
@mutex.synchronize { @salesforce_mode }
|
487
|
+
end
|
488
|
+
|
489
|
+
def salesforce_mode=(true_or_false)
|
490
|
+
@mutex.synchronize { @salesforce_mode = true_or_false }
|
491
|
+
end
|
492
|
+
|
485
493
|
# Add search page for general Elasticsearch / Opensearch querying
|
486
494
|
def add_search
|
487
495
|
true
|
data/lib/brick/extensions.rb
CHANGED
@@ -192,7 +192,7 @@ module ActiveRecord
|
|
192
192
|
# If there's no DSL yet specified, just try to find the first usable column on this model
|
193
193
|
unless (dsl = ::Brick.config.model_descrips[name])
|
194
194
|
skip_columns = _brick_get_fks + (::Brick.config.metadata_columns || []) + [primary_key]
|
195
|
-
dsl = if (descrip_col = columns.find { |c| [:boolean, :binary, :xml].exclude?(c.type) && skip_columns.exclude?(c.name) })
|
195
|
+
dsl = if table_exists? && (descrip_col = columns.find { |c| [:boolean, :binary, :xml].exclude?(c.type) && skip_columns.exclude?(c.name) })
|
196
196
|
"[#{descrip_col.name}]"
|
197
197
|
else
|
198
198
|
"#{name} ##{_pk_as_array.map { |pk_part| "[#{pk_part}]" }.join(', ')}"
|
@@ -383,7 +383,7 @@ module ActiveRecord
|
|
383
383
|
|
384
384
|
# Providing a relation object allows auto-modules built from table name prefixes to work
|
385
385
|
def self._brick_index(mode = nil, separator = nil, relation = nil, not_path = nil)
|
386
|
-
return if abstract_class?
|
386
|
+
return if abstract_class? || !table_exists?
|
387
387
|
|
388
388
|
::Brick._brick_index(table_name, mode, separator, relation, not_path)
|
389
389
|
end
|
@@ -467,7 +467,7 @@ module ActiveRecord
|
|
467
467
|
end
|
468
468
|
skip_klass_hms = ::Brick.config.skip_index_hms[self.name] || {}
|
469
469
|
hms.each do |k, hm|
|
470
|
-
next if skip_klass_hms.key?(k)
|
470
|
+
next if skip_klass_hms.key?(k) || !hm.klass.table_exists?
|
471
471
|
|
472
472
|
if hm.macro == :has_one
|
473
473
|
# For our purposes a :has_one is similar enough to a :belongs_to that we can just join forces
|
@@ -69,7 +69,7 @@ module Brick::Rails::FormTags
|
|
69
69
|
options[col[1].inheritance_column] = col[1].name unless col[1] == col[1].base_class
|
70
70
|
x_order = " x-order=\"#{col_name}\"" if true
|
71
71
|
s << "#{x_order}>#{col[2]} "
|
72
|
-
s << (col.first ? col[3].to_s : "#{link_to(col[3], send("#{col[1]._brick_index}_path", options))}")
|
72
|
+
s << ((col.first || !col[1].table_exists?) ? col[3].to_s : "#{link_to(col[3], send("#{col[1]._brick_index}_path", options))}")
|
73
73
|
elsif cust_cols.key?(col_name) # Custom column
|
74
74
|
x_order = " x-order=\"#{col_name}\"" if true
|
75
75
|
s << "#{x_order}>#{col_name}"
|
data/lib/brick/version_number.rb
CHANGED
data/lib/brick.rb
CHANGED
@@ -299,7 +299,7 @@ module Brick
|
|
299
299
|
end
|
300
300
|
else
|
301
301
|
this_fks = (this_fk = a.foreign_key).is_a?(Array) ? this_fk.uniq : [this_fk.to_s]
|
302
|
-
if !a.options.key?(:as) && (this_fks - a.klass.column_names).length.positive?
|
302
|
+
if !a.options.key?(:as) && a.klass.table_exists? && (this_fks - a.klass.column_names).length.positive?
|
303
303
|
options = ", #{a.options.map { |k, v| "#{k.inspect} => #{v.inspect}" }.join(', ')}" if a.options.present?
|
304
304
|
puts "WARNING: Model #{model.name} has this association:
|
305
305
|
has_many :#{a.name}#{options}
|
@@ -119,15 +119,18 @@ module Brick
|
|
119
119
|
end
|
120
120
|
resembles_fks = resembles_fks.values.flatten
|
121
121
|
|
122
|
+
# Brick additional references
|
123
|
+
# Used to have: ActiveRecord::Base.connection.current_database -- but this doesn't work with SQLite3Adapter
|
124
|
+
current_db = ActiveRecord::Base.connection&.instance_variable_get(:@config)&.fetch(:database, nil)
|
122
125
|
bar = case (possible_additional_references = possible_additional_references.values.flatten).length
|
123
126
|
when 0
|
124
127
|
+" # Brick.additional_references = [['orders', 'customer_id', 'customer'],
|
125
128
|
# ['customer', 'region_id', 'regions']]"
|
126
129
|
when 1
|
127
|
-
+" # # Here is a possible additional reference that has been auto-identified for the #{
|
130
|
+
+" # # Here is a possible additional reference that has been auto-identified for the #{current_db} database:
|
128
131
|
# Brick.additional_references = [#{possible_additional_references.first}]"
|
129
132
|
else
|
130
|
-
+" # # Here are possible additional references that have been auto-identified for the #{
|
133
|
+
+" # # Here are possible additional references that have been auto-identified for the #{current_db} database:
|
131
134
|
# Brick.additional_references = [
|
132
135
|
# #{possible_additional_references.join(",\n # ")}
|
133
136
|
# ]"
|
@@ -146,12 +149,12 @@ module Brick
|
|
146
149
|
# }"
|
147
150
|
when 1
|
148
151
|
".
|
149
|
-
# # Here is a possible polymorphic association that has been auto-identified for the #{
|
152
|
+
# # Here is a possible polymorphic association that has been auto-identified for the #{current_db} database:
|
150
153
|
# Brick.polymorphics = { #{possible_additional_references.first} }"
|
151
154
|
|
152
155
|
else
|
153
156
|
".
|
154
|
-
# # Here are possible polymorphic associations that have been auto-identified for the #{
|
157
|
+
# # Here are possible polymorphic associations that have been auto-identified for the #{current_db} database:
|
155
158
|
# Brick.polymorphics = {
|
156
159
|
# #{possible_polymorphics.join(",\n # ")}
|
157
160
|
# }"
|
@@ -395,6 +398,19 @@ if ActiveRecord::Base.respond_to?(:brick_select) && !::Brick.initializer_loaded
|
|
395
398
|
# Brick.default_route_fallback = 'customers'
|
396
399
|
# Brick.default_route_fallback = 'orders#outstanding' # Example of a non-RESTful route
|
397
400
|
# Brick.default_route_fallback = '' # Omits setting a default route in the absence of any other
|
401
|
+
|
402
|
+
# # GENERATORS
|
403
|
+
# # ==========
|
404
|
+
|
405
|
+
# # MIGRATIONS
|
406
|
+
|
407
|
+
# # Salesforce has table names which use multiple underscores in a row, more than two at a time. This can greatly
|
408
|
+
# # confuse some of the other underscore support put into place for Oracle table names which can have up to two
|
409
|
+
# # underscores at a time.
|
410
|
+
# #
|
411
|
+
# # Setting this +true+ turns on \"salesforce mode\" which means that auto-created migrations will convert
|
412
|
+
# # underscores in filenames and class names to the letter 'x' in order to keep the peace.
|
413
|
+
# Brick.config.salesforce_mode = true
|
398
414
|
end
|
399
415
|
")
|
400
416
|
end
|
@@ -109,6 +109,7 @@ module Brick
|
|
109
109
|
s[v_parts.first] = nil unless [::Brick.default_schema, 'public'].include?(v_parts.first)
|
110
110
|
end
|
111
111
|
end
|
112
|
+
separator = ::Brick.config.salesforce_mode ? 'x' : nil
|
112
113
|
# Start the timestamps back the same number of minutes from now as expected number of migrations to create
|
113
114
|
current_mig_time = [Time.now - (schemas.length + chosen.length).minutes]
|
114
115
|
done = []
|
@@ -146,7 +147,7 @@ module Brick
|
|
146
147
|
key_type, is_4x_rails, ar_version, do_fks_last, versions_to_create)
|
147
148
|
after_fks.concat(add_fks) if do_fks_last
|
148
149
|
current_mig_time[0] += 1.minute
|
149
|
-
versions_to_create << migration_file_write(mig_path, "create_#{::Brick._brick_index(tbl, nil,
|
150
|
+
versions_to_create << migration_file_write(mig_path, "create_#{::Brick._brick_index(tbl, nil, separator)}", current_mig_time, ar_version, mig)
|
150
151
|
end
|
151
152
|
done.concat(fringe)
|
152
153
|
chosen -= done
|
@@ -159,7 +160,7 @@ module Brick
|
|
159
160
|
key_type, is_4x_rails, ar_version, do_fks_last, versions_to_create)
|
160
161
|
after_fks.concat(add_fks)
|
161
162
|
current_mig_time[0] += 1.minute
|
162
|
-
versions_to_create << migration_file_write(mig_path, "create_#{::Brick._brick_index(tbl, :migration,
|
163
|
+
versions_to_create << migration_file_write(mig_path, "create_#{::Brick._brick_index(tbl, :migration, separator)}", current_mig_time, ar_version, mig)
|
163
164
|
end
|
164
165
|
done.concat(chosen)
|
165
166
|
chosen.clear
|
@@ -199,7 +199,7 @@ end\n"
|
|
199
199
|
ensure_has_atrts(updates)
|
200
200
|
updates << "atrt_ids[[#{obj.id}, '#{klass.name}']] = #{var_name}.id\n"
|
201
201
|
end
|
202
|
-
end
|
202
|
+
end if klass.respond_to?(:attachment_reflections)
|
203
203
|
end
|
204
204
|
updates.each { |update| seeds << update } # Anything that needs patching up after-the-fact
|
205
205
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.222
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorin Thwaits
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
257
|
- !ruby/object:Gem::Version
|
258
258
|
version: 1.3.6
|
259
259
|
requirements: []
|
260
|
-
rubygems_version: 3.
|
260
|
+
rubygems_version: 3.4.19
|
261
261
|
signing_key:
|
262
262
|
specification_version: 4
|
263
263
|
summary: Create a Rails app from data alone
|