brick 1.0.32 → 1.0.33

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: 8483d9a50013e440cce28f648d09d5322985702f952520cb83c69ad0e5742ce4
4
- data.tar.gz: 40072d0504f4d2b1cc9a59e62fef305b939dd977da0e794445adf003dbfb8b7e
3
+ metadata.gz: 7bd78c8878b1ce8e8e58fb4d8463322269d2ac065c5ed12079dcc64360dc30d5
4
+ data.tar.gz: e6926fdc0ec59ad609be39361dbfe0ccea24c1b08a01ccf0a4ae8eb1aa9e2ba2
5
5
  SHA512:
6
- metadata.gz: 9740778159acb464652322ef36eff763a55b38c6579fe0a7550a5797db44928ad6832a8bccc0d924a4d4c5a14dc02658e61bf4220cecff08fc348d540b67e41c
7
- data.tar.gz: 1b09db07a284512821b604f1d82f64c4be0c11db7f8a8973f36ab3f78b21804a7fec1eb641bcf1ac5c2ec118cb477c8086c124017c66550753ec4f9beddbd413
6
+ metadata.gz: 5b6ac439519209c3097c2b2651ed66f319b9c04072d2cee7262aad6c4d9907d61b5b45ee1812c1f6cea1e5e1eed2082eb15953e4e3097c9c12b4f35a1f3af703
7
+ data.tar.gz: 5bb559ada7035abb062b0441578d5406e64f87b9f11fde1d5b3b880179098bafe9507a1a6cdd8e1af1cd1fb4defc1d339e0054896ca0e9c507ea831f24a0cb96
@@ -86,7 +86,11 @@ module ActiveRecord
86
86
  descrip_col = (columns.map(&:name) - _brick_get_fks -
87
87
  (::Brick.config.metadata_columns || []) -
88
88
  [primary_key]).first
89
- dsl = ::Brick.config.model_descrips[name] = "[#{descrip_col}]" if descrip_col
89
+ dsl = ::Brick.config.model_descrips[name] = if descrip_col
90
+ "[#{descrip_col}]"
91
+ elsif (pk_parts = self.primary_key.is_a?(Array) ? self.primary_key : [self.primary_key])
92
+ "#{name} ##{pk_parts.map { |pk_part| "[#{pk_part}]" }.join(', ')}"
93
+ end
90
94
  end
91
95
  dsl
92
96
  end
@@ -129,7 +133,7 @@ module ActiveRecord
129
133
  end
130
134
  else # With no DSL available, still put this prefix into the JoinArray so we can get primary key (ID) info from this table
131
135
  x = prefix.each_with_object(build_array) { |v, s| s[v.to_sym] }
132
- x[prefix[-1]] = nil unless prefix.empty? # Using []= will "hydrate" any missing part(s) in our whole series
136
+ x[prefix.last] = nil unless prefix.empty? # Using []= will "hydrate" any missing part(s) in our whole series
133
137
  end
134
138
  members
135
139
  end
@@ -252,13 +256,12 @@ module ActiveRecord
252
256
  names << [piece.right._arel_table_type, (piece.right.table_alias || piece.right.name)]
253
257
  else # "Normal" setup, fed from a JoinSource which has an array of JOINs
254
258
  # The left side is the "JOIN" table
255
- names += _recurse_arel(piece.left)
259
+ names += _recurse_arel(table = piece.left)
256
260
  # The expression on the right side is the "ON" clause
257
261
  # on = piece.right.expr
258
262
  # # Find the table which is not ourselves, and thus must be the "path" that led us here
259
263
  # parent = piece.left == on.left.relation ? on.right.relation : on.left.relation
260
264
  # binding.pry if piece.left.is_a?(Arel::Nodes::TableAlias)
261
- table = piece.left
262
265
  if table.is_a?(Arel::Nodes::TableAlias)
263
266
  alias_name = table.right
264
267
  table = table.left
@@ -277,7 +280,8 @@ module ActiveRecord
277
280
  @_brick_chains = {}
278
281
  # The left side is the "FROM" table
279
282
  # names += _recurse_arel(piece.left)
280
- names << [piece.left._arel_table_type, (piece.left.table_alias || piece.left.name)]
283
+ names << (this_name = [piece.left._arel_table_type, (piece.left.table_alias || piece.left.name)])
284
+ (_brick_chains[this_name.first] ||= []) << this_name.last
281
285
  # The right side is an array of all JOINs
282
286
  piece.right.each { |join| names << _recurse_arel(join) }
283
287
  end
@@ -399,6 +403,7 @@ module ActiveRecord
399
403
  hm_counts.each do |k, hm|
400
404
  associative = nil
401
405
  count_column = if hm.options[:through]
406
+ # binding.pry if associatives[hm.name].nil?
402
407
  fk_col = (associative = associatives[hm.name]).foreign_key
403
408
  hm.foreign_key
404
409
  else
@@ -548,7 +553,7 @@ Module.class_exec do
548
553
  full_class_name = +''
549
554
  full_class_name << "::#{self.name}" unless self == Object
550
555
  full_class_name << "::#{plural_class_name.underscore.singularize.camelize}"
551
- if (model = self.const_get(full_class_name))
556
+ if (plural_class_name == 'BrickSwagger' || model = self.const_get(full_class_name))
552
557
  # if it's a controller and no match or a model doesn't really use the same table name, eager load all models and try to find a model class of the right name.
553
558
  Object.send(:build_controller, self, class_name, plural_class_name, model, relations)
554
559
  end
@@ -592,7 +597,10 @@ Module.class_exec do
592
597
  else
593
598
  ActiveSupport::Inflector.pluralize(singular_table_name)
594
599
  end
595
-
600
+ if ::Brick.config.schema_behavior[:multitenant] && Object.const_defined?('Apartment') &&
601
+ Apartment.excluded_models.include?(table_name.singularize.camelize)
602
+ schema_name = Apartment.default_schema
603
+ end
596
604
  # Maybe, just maybe there's a database table that will satisfy this need
597
605
  if (matching = [table_name, singular_table_name, plural_class_name, model_name].find { |m| relations.key?(schema_name ? "#{schema_name}.#{m}" : m) })
598
606
  Object.send(:build_model, schema_name, model_name, singular_table_name, table_name, relations, matching)
@@ -624,7 +632,10 @@ class Object
624
632
  private
625
633
 
626
634
  def build_model(schema_name, model_name, singular_table_name, table_name, relations, matching)
627
- full_name = if schema_name.blank?
635
+ full_name = if (::Brick.config.schema_behavior[:multitenant] && Object.const_defined?('Apartment') && schema_name == Apartment.default_schema)
636
+ relation = relations["#{schema_name}.#{matching}"]
637
+ model_name
638
+ elsif schema_name.blank?
628
639
  model_name
629
640
  else # Prefix the schema to the table name + prefix the schema namespace to the class name
630
641
  schema_module = if schema_name.instance_of?(Module) # from an auto-STI namespace?
@@ -636,7 +647,7 @@ class Object
636
647
  "#{schema_module&.name}::#{model_name}"
637
648
  end
638
649
 
639
- return if ((is_view = (relation = relations[matching]).key?(:isView)) && ::Brick.config.skip_database_views) ||
650
+ return if ((is_view = (relation ||= relations[matching]).key?(:isView)) && ::Brick.config.skip_database_views) ||
640
651
  ::Brick.config.exclude_tables.include?(matching)
641
652
 
642
653
  # Are they trying to use a pluralised class name such as "Employees" instead of "Employee"?
@@ -685,6 +696,9 @@ class Object
685
696
  code << " self.primary_key = #{pk_sym.inspect}\n"
686
697
  end
687
698
  _brick_primary_key(relation) # Set the newly-found PK in the instance variable
699
+ elsif (possible_pk = ActiveRecord::Base.get_primary_key(base_class.name)) && relation[:cols][possible_pk]
700
+ new_model_class.primary_key = (possible_pk = possible_pk.to_sym)
701
+ code << " self.primary_key = #{possible_pk.inspect}\n"
688
702
  else
689
703
  code << " # Could not identify any column(s) to use as a primary key\n" unless is_view
690
704
  end
@@ -725,7 +739,8 @@ class Object
725
739
  hmts&.each do |hmt_fk, fks|
726
740
  hmt_fk = hmt_fk.tr('.', '_')
727
741
  fks.each do |fk|
728
- through = fk.first[:assoc_name]
742
+ # %%% Will not work with custom has_many name
743
+ through = ::Brick.config.schema_behavior[:multitenant] ? fk.first[:assoc_name] : fk.first[:inverse_table].tr('.', '_').pluralize
729
744
  hmt_name = if fks.length > 1
730
745
  if fks[0].first[:inverse][:assoc_name] == fks[1].first[:inverse][:assoc_name] # Same BT names pointing back to us? (Most common scenario)
731
746
  "#{hmt_fk}_through_#{fk.first[:assoc_name]}"
@@ -740,6 +755,7 @@ class Object
740
755
  options = { through: through.to_sym }
741
756
  if relation[:fks].any? { |k, v| v[:assoc_name] == hmt_name }
742
757
  hmt_name = "#{hmt_name.singularize}_#{fk.first[:assoc_name]}"
758
+ # binding.pry if relation[:fks].any? { |k, v| v[:assoc_name] == hmt_name }
743
759
  options[:class_name] = fk.first[:inverse_table].singularize.camelize
744
760
  options[:foreign_key] = fk.first[:fk].to_sym
745
761
  end
@@ -843,19 +859,70 @@ class Object
843
859
  def build_controller(namespace, class_name, plural_class_name, model, relations)
844
860
  table_name = ActiveSupport::Inflector.underscore(plural_class_name)
845
861
  singular_table_name = ActiveSupport::Inflector.singularize(table_name)
846
- pk = model._brick_primary_key(relations.fetch(table_name, nil))
862
+ pk = model&._brick_primary_key(relations.fetch(table_name, nil))
847
863
 
848
864
  namespace_name = "#{namespace.name}::" if namespace
849
865
  code = +"class #{namespace_name}#{class_name} < ApplicationController\n"
850
866
  built_controller = Class.new(ActionController::Base) do |new_controller_class|
851
867
  (namespace || Object).const_set(class_name.to_sym, new_controller_class)
852
868
 
853
- code << " def index\n"
854
- code << " @#{table_name} = #{model.name}#{pk&.present? ? ".order(#{pk.inspect})" : '.all'}\n"
855
- code << " @#{table_name}.brick_select(params)\n"
856
- code << " end\n"
869
+ unless (is_swagger = plural_class_name == 'BrickSwagger') # && request.format == :json)
870
+ code << " def index\n"
871
+ code << " @#{table_name} = #{model.name}#{pk&.present? ? ".order(#{pk.inspect})" : '.all'}\n"
872
+ code << " @#{table_name}.brick_select(params)\n"
873
+ code << " end\n"
874
+ end
857
875
  self.protect_from_forgery unless: -> { self.request.format.js? }
858
876
  self.define_method :index do
877
+ if is_swagger
878
+ json = { 'openapi': '3.0.1', 'info': { 'title': 'API V1', 'version': 'v1' },
879
+ 'servers': [
880
+ { 'url': 'https://{defaultHost}', 'variables': { 'defaultHost': { 'default': 'www.example.com' } } }
881
+ ]
882
+ }
883
+ json['paths'] = relations.each_with_object({}) do |v, s|
884
+ # next if v.last[:is_view]
885
+
886
+ s["/api/v1/#{v.first}"] = {
887
+ 'get': {
888
+ 'summary': 'list #{v.first}',
889
+ 'parameters': v.last[:cols].map { |k, v| { 'name' => k, 'schema': { 'type': v.first } } },
890
+ 'responses': { '200': { 'description': 'successful' } }
891
+ }
892
+ }
893
+ s["/api/v1/#{v.first}/{id}"] = {
894
+ 'patch': {
895
+ 'summary': 'update a #{v.first.singularize}',
896
+ 'parameters': v.last[:cols].reject { |k, v| Brick.config.metadata_columns.include?(k) }.map do |k, v|
897
+ { 'name' => k, 'schema': { 'type': v.first } }
898
+ end,
899
+ 'responses': { '200': { 'description': 'successful' } }
900
+ }
901
+ # "/api/v1/books/{id}": {
902
+ # "parameters": [
903
+ # {
904
+ # "name": "id",
905
+ # "in": "path",
906
+ # "description": "id",
907
+ # "required": true,
908
+ # "schema": {
909
+ # "type": "string"
910
+ # }
911
+ # },
912
+ # {
913
+ # "name": "Authorization",
914
+ # "in": "header",
915
+ # "schema": {
916
+ # "type": "string"
917
+ # }
918
+ # }
919
+ # ],
920
+ }
921
+ end
922
+ # binding.pry
923
+ render inline: json.to_json, content_type: request.format
924
+ return
925
+ end
859
926
  ::Brick.set_db_schema(params)
860
927
  if request.format == :csv # Asking for a template?
861
928
  require 'csv'
@@ -884,7 +951,7 @@ class Object
884
951
  @_brick_join_array = join_array
885
952
  end
886
953
 
887
- if model.primary_key
954
+ if model&.primary_key
888
955
  code << " def show\n"
889
956
  code << (find_by_id = " id = params[:id]&.split(/[\\/,_]/)
890
957
  id = id.first if id.is_a?(Array) && id.length == 1
@@ -899,7 +966,7 @@ class Object
899
966
  end
900
967
 
901
968
  # By default, views get marked as read-only
902
- unless false # model.readonly # (relation = relations[model.table_name]).key?(:isView)
969
+ unless is_swagger # model.readonly # (relation = relations[model.table_name]).key?(:isView)
903
970
  code << " # (Define :new, :create)\n"
904
971
 
905
972
  if model.primary_key
@@ -958,10 +1025,23 @@ class Object
958
1025
 
959
1026
  def _brick_get_hm_assoc_name(relation, hm_assoc)
960
1027
  if relation[:hm_counts][hm_assoc[:assoc_name]]&.> 1
1028
+ # binding.pry if (same_name = relation[:fks].find { |x| x.last[:assoc_name] == hm_assoc[:assoc_name] && x.last != hm_assoc }) #&&
1029
+ # x.last[:alternate_name] == hm_assoc[:alternate_name] })
1030
+ # relation[:fks].any? { |k, v| v[:assoc_name] == new_alt_name }
961
1031
  plural = ActiveSupport::Inflector.pluralize(hm_assoc[:alternate_name])
962
- [hm_assoc[:alternate_name] == name.underscore ? "#{hm_assoc[:assoc_name].singularize}_#{plural}" : plural, true]
1032
+ # binding.pry if hm_assoc[:assoc_name] == 'issue_issue_duplicates'
1033
+ new_alt_name = (hm_assoc[:alternate_name] == name.underscore) ? "#{hm_assoc[:assoc_name].singularize}_#{plural}" : plural
1034
+ # uniq = 1
1035
+ # while same_name = relation[:fks].find { |x| x.last[:assoc_name] == hm_assoc[:assoc_name] && x.last != hm_assoc }
1036
+ # hm_assoc[:assoc_name] = "#{hm_assoc_name}_#{uniq += 1}"
1037
+ # end
1038
+ # puts new_alt_name
1039
+ # binding.pry if new_alt_name == 'issue_duplicates'
1040
+ # hm_assoc[:assoc_name] = new_alt_name
1041
+ [new_alt_name, true]
963
1042
  else
964
1043
  assoc_name = hm_assoc[:inverse_table].pluralize
1044
+ # hm_assoc[:assoc_name] = assoc_name
965
1045
  [assoc_name, assoc_name.include?('.')]
966
1046
  end
967
1047
  end
@@ -989,6 +1069,12 @@ module ActiveRecord::ConnectionHandling
989
1069
  if File.exist?(brick_initializer = Rails.root.join('config/initializers/brick.rb'))
990
1070
  initializer_loaded = load brick_initializer
991
1071
  end
1072
+ # Load the initializer for the Apartment gem a little early so that if .excluded_models and
1073
+ # .default_schema are specified then we can work with non-tenanted models more appropriately
1074
+ if Object.const_defined?('Apartment') && File.exist?(apartment_initializer = Rails.root.join('config/initializers/apartment.rb'))
1075
+ load apartment_initializer
1076
+ apartment_excluded = Apartment.excluded_models
1077
+ end
992
1078
  # Only for Postgres? (Doesn't work in sqlite3)
993
1079
  # puts ActiveRecord::Base.execute_sql("SELECT current_setting('SEARCH_PATH')").to_a.inspect
994
1080
 
@@ -1065,11 +1151,14 @@ module ActiveRecord::ConnectionHandling
1065
1151
  when 'PostgreSQL', 'SQLite' # These bring back a hash for each row because the query uses column aliases
1066
1152
  # schema ||= 'public' if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
1067
1153
  ActiveRecord::Base.execute_sql(sql).each do |r|
1068
- relation_name = if ![schema, 'public'].include?(r['schema']) && !::Brick.config.schema_behavior[:multitenant]
1069
- "#{schema_name = r['schema']}.#{r['relation_name']}"
1070
- else
1071
- r['relation_name']
1072
- end
1154
+ # If Apartment gem lists the table as being associated with a non-tenanted model then use whatever it thinks
1155
+ # is the default schema, usually 'public'.
1156
+ schema_name = if ::Brick.config.schema_behavior[:multitenant]
1157
+ Apartment.default_schema if apartment_excluded&.include?(r['relation_name'].singularize.camelize)
1158
+ elsif ![schema, 'public'].include?(r['schema'])
1159
+ r['schema']
1160
+ end
1161
+ relation_name = schema_name ? "#{schema_name}.#{r['relation_name']}" : r['relation_name']
1073
1162
  relation = relations[relation_name]
1074
1163
  relation[:isView] = true if r['table_type'] == 'VIEW'
1075
1164
  col_name = r['column_name']
@@ -1154,9 +1243,17 @@ module ActiveRecord::ConnectionHandling
1154
1243
  # ::Brick.default_schema ||= schema ||= 'public' if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
1155
1244
  ActiveRecord::Base.execute_sql(sql).each do |fk|
1156
1245
  fk = fk.values unless fk.is_a?(Array)
1157
- # Multitenancy makes things a little more general overall
1158
- fk[0] = nil if fk[0] == 'public' || (is_multitenant && fk[0] == schema)
1159
- fk[3] = nil if fk[3] == 'public' || (is_multitenant && fk[3] == schema)
1246
+ # Multitenancy makes things a little more general overall, except for non-tenanted tables
1247
+ if apartment_excluded&.include?(fk[1].singularize.camelize)
1248
+ fk[0] = Apartment.default_schema
1249
+ elsif fk[0] == 'public' || (is_multitenant && fk[0] == schema)
1250
+ fk[0] = nil
1251
+ end
1252
+ if apartment_excluded&.include?(fk[4].singularize.camelize)
1253
+ fk[3] = Apartment.default_schema
1254
+ elsif fk[3] == 'public' || (is_multitenant && fk[3] == schema)
1255
+ fk[3] = nil
1256
+ end
1160
1257
  ::Brick._add_bt_and_hm(fk, relations)
1161
1258
  end
1162
1259
  end
@@ -1209,16 +1306,30 @@ module Brick
1209
1306
  end
1210
1307
  # %%% Temporary schema patch
1211
1308
  for_tbl = fk[1]
1309
+ fk[0] = Apartment.default_schema if Object.const_defined?('Apartment') && Apartment.excluded_models.include?(for_tbl.singularize.camelize)
1212
1310
  fk[1] = "#{fk[0]}.#{fk[1]}" if fk[0] # && fk[0] != ::Brick.default_schema
1213
1311
  bts = (relation = relations.fetch(fk[1], nil))&.fetch(:fks) { relation[:fks] = {} }
1312
+
1214
1313
  # %%% Do we miss out on has_many :through or even HM based on constantizing this model early?
1215
1314
  # Maybe it's already gotten this info because we got as far as to say there was a unique class
1216
1315
  primary_table = if (is_class = fk[4].is_a?(Hash) && fk[4].key?(:class))
1217
1316
  pri_tbl = (primary_class = fk[4][:class].constantize).table_name
1317
+ if (pri_tbl_parts = pri_tbl.split('.')).length > 1
1318
+ fk[3] = pri_tbl_parts.first
1319
+ end
1218
1320
  else
1219
- is_schema = fk[3] != ::Brick.default_schema && (::Brick.config.schema_behavior[:multitenant] || fk[3] != 'public')
1321
+ is_schema = if ::Brick.config.schema_behavior[:multitenant]
1322
+ # If Apartment gem lists the primary table as being associated with a non-tenanted model
1323
+ # then use 'public' schema for the primary table
1324
+ if Object.const_defined?('Apartment') && Apartment.excluded_models.include?(fk[4].singularize.camelize)
1325
+ fk[3] = Apartment.default_schema
1326
+ true
1327
+ end
1328
+ else
1329
+ fk[3] && fk[3] != ::Brick.default_schema && fk[3] != 'public'
1330
+ end
1220
1331
  pri_tbl = fk[4]
1221
- fk[3] && is_schema ? "#{fk[3]}.#{pri_tbl}" : pri_tbl
1332
+ is_schema ? "#{fk[3]}.#{pri_tbl}" : pri_tbl
1222
1333
  end
1223
1334
  hms = (relation = relations.fetch(primary_table, nil))&.fetch(:fks) { relation[:fks] = {} } unless is_class
1224
1335
 
@@ -1287,7 +1398,14 @@ module Brick
1287
1398
  assoc_hm[:alternate_name] = "#{assoc_hm[:alternate_name]}_#{bt_assoc_name}" unless assoc_hm[:alternate_name] == bt_assoc_name
1288
1399
  assoc_hm[:inverse] = assoc_bt
1289
1400
  else
1290
- assoc_hm = hms[hm_cnstr_name] = { is_bt: false, fk: fk[2], assoc_name: for_tbl.pluralize, alternate_name: bt_assoc_name, inverse_table: fk[1], inverse: assoc_bt }
1401
+ inv_tbl = if ::Brick.config.schema_behavior[:multitenant] && Object.const_defined?('Apartment') && fk[0] == Apartment.default_schema
1402
+ for_tbl
1403
+ else
1404
+ fk[1]
1405
+ end
1406
+ # binding.pry if inv_tbl == 'issue_issue_duplicates' # inverse_table goofed?
1407
+ assoc_hm = hms[hm_cnstr_name] = { is_bt: false, fk: fk[2], assoc_name: for_tbl.pluralize, alternate_name: bt_assoc_name,
1408
+ inverse_table: inv_tbl, inverse: assoc_bt }
1291
1409
  assoc_hm[:polymorphic] = true if is_polymorphic
1292
1410
  hm_counts = relation.fetch(:hm_counts) { relation[:hm_counts] = {} }
1293
1411
  hm_counts[fk[1]] = hm_counts.fetch(fk[1]) { 0 } + 1
@@ -407,7 +407,7 @@ function changeout(href, param, value) {
407
407
  origin = (key_parts = k.split('.')).length == 1 ? #{model_name} : #{model_name}.reflect_on_association(key_parts.first).klass
408
408
  # binding.pry
409
409
  if (destination_fk = Brick.relations[origin.table_name][:fks].values.find { |fk| puts fk.inspect; fk[:fk] == key_parts.last }) &&
410
- (obj = (destination = origin.reflect_on_association(destination_fk[:assoc_name])&.klass)&.find(id)) %>
410
+ (obj = (destination = origin.reflect_on_association(destination_fk[:assoc_name])&.klass)&.find(id)) %>
411
411
  <h3>for <%= link_to \"#{"#\{obj.brick_descrip\} (#\{destination.name\})\""}, send(\"#\{destination.name.underscore.tr('/', '_')\}_path\".to_sym, id) %></h3><%
412
412
  end
413
413
  end %>
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 32
8
+ TINY = 33
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
data/lib/brick.rb CHANGED
@@ -132,6 +132,7 @@ module Brick
132
132
  associatives = hms.each_with_object({}) do |hmt, s|
133
133
  if (through = hmt.last.options[:through])
134
134
  skip_hms[through] = nil
135
+ # binding.pry if hmt.first == :issue_issues
135
136
  s[hmt.first] = hms[through] # End up with a hash of HMT names pointing to join-table associations
136
137
  elsif hmt.last.inverse_of.nil?
137
138
  puts "SKIPPING #{hmt.last.name.inspect}"
@@ -409,6 +410,7 @@ In config/initializers/brick.rb appropriate entries would look something like:
409
410
  ::Brick.relations.each do |rel_name, v|
410
411
  rel_name = rel_name.split('.').map(&:underscore)
411
412
  schema_names = rel_name[0..-2]
413
+ schema_names.shift if ::Brick.config.schema_behavior[:multitenant] && Object.const_defined?('Apartment') && schema_names.first == Apartment.default_schema
412
414
  k = rel_name.last
413
415
  unless existing_controllers.key?(controller_name = k.pluralize)
414
416
  options = {}
@@ -422,6 +424,7 @@ In config/initializers/brick.rb appropriate entries would look something like:
422
424
  end
423
425
  end
424
426
  end
427
+ send(:get, '/api-docs/v1/swagger.json', { to: 'brick_swagger#index' }) if Object.const_defined?('Rswag::Ui')
425
428
  end
426
429
  super
427
430
  end
@@ -28,7 +28,7 @@ module Brick
28
28
  col_down = col.downcase
29
29
 
30
30
  if (is_possible_poly = ['character varying', 'text'].include?(type.first))
31
- if col_down.end_with?('_type') &&
31
+ if col_down.end_with?('_type')
32
32
  poly_type_cut_length = -6
33
33
  col_down = col_down[0..-6]
34
34
  elsif col_down.end_with?('type')
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.32
4
+ version: 1.0.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord