dynamic-records-meritfront 3.1.3 → 3.1.29

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd63ab9cfaf15d4472c125505260f76db354e11856a8e17aefdb2aac197fd675
4
- data.tar.gz: f15916d4f9301319c8fbbcd2355cc04406dcaebe4855bfad8395629d652d182d
3
+ metadata.gz: 0e329f6fa51f14843549a6d3681870a99a5e1b9ff78af32281ca8a5433122922
4
+ data.tar.gz: 5c14dc25ee35ea526f220d5b727032dcaf1be0f1bb744c080c9a12c4a70b15bb
5
5
  SHA512:
6
- metadata.gz: e5af425ecff409a85dd1bdc04b3fd3bc7e7a0ecbb974e51912d66013ad57351099d6004ecd014ee08edb74830948c0ffa0cfc6e71b9b3020151c10ea3195d9ac
7
- data.tar.gz: d3ac6b00f58cdd803714742eb37653a57bea2523851058a174273f15329d0da3b8577d439f7f7e878246681c60fe6e979166401a954ee400ce0b678831d490c6
6
+ metadata.gz: 19070cbac3c6442ba5ba82c28d370efe9a3cc6cfd0e6a05e5a74175982000484baa804baceb187b00badb865ba57e6f9059bf878670c518830c97ea904157779
7
+ data.tar.gz: 85892bfa3f8708bbb683297513ffb0f10650ad389084a219203241918e52208041c29a477e478027e3f841e0235b983fd1948f1ff65389b34efcbe18c531b805
data/Gemfile.lock CHANGED
@@ -1,31 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamic-records-meritfront (3.1.3)
4
+ dynamic-records-meritfront (3.1.29)
5
5
  hashid-rails
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (7.0.4.3)
11
- activesupport (= 7.0.4.3)
12
- activerecord (7.0.4.3)
13
- activemodel (= 7.0.4.3)
14
- activesupport (= 7.0.4.3)
15
- activesupport (7.0.4.3)
10
+ activemodel (7.1.1)
11
+ activesupport (= 7.1.1)
12
+ activerecord (7.1.1)
13
+ activemodel (= 7.1.1)
14
+ activesupport (= 7.1.1)
15
+ timeout (>= 0.4.0)
16
+ activesupport (7.1.1)
17
+ base64
18
+ bigdecimal
16
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
+ connection_pool (>= 2.2.5)
21
+ drb
17
22
  i18n (>= 1.6, < 2)
18
23
  minitest (>= 5.1)
24
+ mutex_m
19
25
  tzinfo (~> 2.0)
26
+ base64 (0.1.1)
27
+ bigdecimal (3.1.4)
20
28
  concurrent-ruby (1.2.2)
29
+ connection_pool (2.4.1)
30
+ drb (2.1.1)
31
+ ruby2_keywords
21
32
  hashid-rails (1.4.1)
22
33
  activerecord (>= 4.0)
23
34
  hashids (~> 1.0)
24
35
  hashids (1.0.6)
25
- i18n (1.12.0)
36
+ i18n (1.14.1)
26
37
  concurrent-ruby (~> 1.0)
27
- minitest (5.18.0)
38
+ minitest (5.20.0)
39
+ mutex_m (0.1.2)
28
40
  rake (12.3.3)
41
+ ruby2_keywords (0.0.5)
42
+ timeout (0.4.0)
29
43
  tzinfo (2.0.6)
30
44
  concurrent-ruby (~> 1.0)
31
45
 
data/README.md CHANGED
@@ -532,6 +532,12 @@ v3.0.6
532
532
  ....
533
533
  - took out undocumented quick_safe_increment and safe_increment as they were not relevant to the gem - and fairly basic.
534
534
 
535
+ 3.1.28
536
+ - warning messages for dynamic_attach. to_s'd any provided table_names for ease-of-use.
537
+ - logging info for dynamic_attach outside of instaload.
538
+ - fixed an error where instaload only worked with ApplicationRecord abstract_class. Now works on anything thats a subclass of ActiveRecord::Base
539
+ - wow
540
+
535
541
 
536
542
  ## Questions
537
543
  - Q: does the name of a sql operation have anything to do with prepared statements?
data/bin/update CHANGED
@@ -51,5 +51,8 @@ puts `git commit -m 'minor changes to version #{version_new}'`
51
51
  puts "_______________________________________________"
52
52
  puts "INSTALL GEM LOCALLY"
53
53
  puts `bundle exec rake install`
54
+ puts "note if you cant install in your project u prob have different ruby versions for the project and this folder."
55
+ puts "if in that case and using rbenv, change your global ruby version under ~/.rbenv/version or your local by adding"
56
+ puts "somthing similar in a .ruby_version file. Not using .rbenv? Add ur instructions here"
54
57
  puts "_______________________________________________"
55
58
  puts "info: write 'bundle exec rake release' to release the current version to the interwebz"
@@ -1,5 +1,5 @@
1
1
 
2
2
  module DynamicRecordsMeritfront
3
- VERSION = '3.1.3'
3
+ VERSION = '3.1.29'
4
4
  end
5
5
  #this file gets overwritten automatically on minor updates, major ones need to be manually changed
@@ -105,7 +105,7 @@ module DynamicRecordsMeritfront
105
105
 
106
106
  type = DB_TYPE_MAPS[v.class]
107
107
  if type.nil?
108
- raise StandardError.new("#{name} (of value: #{v}, class: #{v.class}) unsupported class for ApplicationRecord#headache_sql")
108
+ raise StandardError.new("#{name} (of value: #{v}, class: #{v.class}) unsupported class for DynamicRecordsMeritfront#headache_sql")
109
109
  elsif type.class == Proc
110
110
  a = v[0]
111
111
  # if a.nil?
@@ -400,9 +400,14 @@ module DynamicRecordsMeritfront
400
400
  if returns_nil
401
401
  return nil
402
402
  else
403
- raise StandardError.new("non-string class passed to ApplicationRecord#locate_hgid as the hgid_string variable")
403
+ raise StandardError.new("non-string class passed to DynamicRecordsMeritfront#locate_hgid as the hgid_string variable")
404
404
  end
405
405
  end
406
+ if PROJECT_NAME == 'midflip'
407
+ #should be fine to take out in a month or so, just got lazy and pretty sure I am the only one using this gem.
408
+ #dont want to kill me jobs.
409
+ hgid_string = hgid_string.gsub('ApplicationRecord', 'Record')
410
+ end
406
411
  if hgid_string.include?('@')
407
412
  hgid_string = hgid_string.split('@')
408
413
  hgid_string.pop
@@ -438,7 +443,7 @@ module DynamicRecordsMeritfront
438
443
  nil
439
444
  else
440
445
  #stops execution as default
441
- raise StandardError.new 'Not the expected class, or a subclass of ApplicationRecord if called on that.'
446
+ raise StandardError.new 'Not the expected class or subclass.'
442
447
  end
443
448
  end
444
449
  def get_hgid_tag(hgid_string)
@@ -654,37 +659,31 @@ module DynamicRecordsMeritfront
654
659
  insta_array = insta_array.select{|ar| not ar[:dont_return]}
655
660
  ret_hash = insta_array.map{|ar| [ar[:table_name].to_s, []]}.to_h
656
661
  opts[:raw] = true
657
- ApplicationRecord.headache_sql(name, sql, opts).rows.each{|row|
662
+
663
+ #annoying bug
664
+ s = self
665
+ unless s.abstract_class?
666
+ s = s.superclass
667
+ end
668
+
669
+ s.dynamic_sql(name, sql, opts).rows.each{|row|
658
670
  #need to pre-parsed as it has a non-normal output.
659
671
  table_name = row[2]
660
672
  klass = row[1].constantize
661
673
  json = row[0]
662
674
  parsed = JSON.parse(json)
663
-
664
675
  ret_hash[table_name].push dynamic_init(klass, parsed)
665
676
  }
666
677
 
667
- insta_array = insta_array.map{|a|a.delete(:sql); next a} #better for debuggin and we dont need it anymore
678
+ insta_array.each{|a| a.delete(:sql)}
668
679
 
669
680
  #formatting options
670
681
  for insta in insta_array
671
682
  if insta[:base_name]
672
683
  #in this case, 'as' is meant as to what pseudonym to dynamicly attach it as
673
- n_attached = dynamic_attach(ret_hash, insta[:base_name], insta[:table_name], base_on: insta[:base_on], attach_on: insta[:attach_on],
684
+ #we are attaching to the base table. Variable could of been less confusing. My bad.
685
+ dynamic_attach(ret_hash, insta[:base_name], insta[:table_name], base_on: insta[:base_on], attach_on: insta[:attach_on],
674
686
  one_to_one: insta[:one_to_one], as: insta[:as])
675
-
676
- if Rails.logger.level <= 1
677
- tn = insta[:table_name]
678
- bn = insta[:base_name]
679
- tc = ret_hash[tn].count
680
- btc = ret_hash[bn].count
681
-
682
- if insta[:as]
683
- Rails.logger.debug "#{n_attached} attached from #{tn}(#{tc}) as #{insta[:as]} -> #{bn}(#{btc})"
684
- else
685
- Rails.logger.debug "#{n_attached} attached from #{tn}(#{tc}) -> #{bn}(#{btc})"
686
- end
687
- end
688
687
  elsif insta[:as]
689
688
  Rails.logger.debug "#{insta[:table_name]} as #{insta[:as]}"
690
689
  #in this case, the idea is more polymorphic in nature. unless they are confused and just want to rename the table (this can be done with
@@ -708,7 +707,7 @@ module DynamicRecordsMeritfront
708
707
  m = model_with_an_id_column_and_timestamps
709
708
  ar = m.superclass
710
709
  mtname = m.table_name
711
- ApplicationRecord.transaction do
710
+ transaction do
712
711
  puts 'test recieving columns not normally in the record.'
713
712
  rec = m.dynamic_sql(%Q{
714
713
  SELECT id, 5 AS random_column from #{mtname} LIMIT 10
@@ -800,12 +799,23 @@ module DynamicRecordsMeritfront
800
799
  def dynamic_attach(instaload_sql_output, base_name, attach_name, base_on: nil, attach_on: nil, one_to_one: false, as: nil)
801
800
  #as just lets it attach us anywhere on the base class, and not just as the attach_name.
802
801
  #Can be useful in polymorphic situations, otherwise may lead to confusion.
802
+
803
+ #oh the errors
804
+ base_name = base_name.to_s
805
+ attach_name = attach_name.to_s
806
+
803
807
  as ||= attach_name
804
808
 
805
809
  base_arr = instaload_sql_output[base_name]
806
810
 
807
811
  #return if there is nothing for us to attach to.
808
- return 0 if base_arr.nil? or not base_arr.any?
812
+ if base_arr.nil?
813
+ Rails.logger.error("base table " + base_name + " was not set")
814
+ return 0
815
+ elsif not base_arr.any?
816
+ Rails.logger.debug("no items in base table " + base_name)
817
+ return 0
818
+ end
809
819
 
810
820
  #set variables for neatness and so we dont compute each time
811
821
  # base class information
@@ -830,7 +840,14 @@ module DynamicRecordsMeritfront
830
840
 
831
841
  #make sure the attach class has something going on. We do this after the default stage
832
842
  attach_arr = instaload_sql_output[attach_name]
833
- return 0 if attach_arr.nil? or not attach_arr.any?
843
+
844
+ if attach_arr.nil?
845
+ Rails.logger.error("attaching table " + attach_name + " was not set")
846
+ return 0
847
+ elsif not attach_arr.any?
848
+ Rails.logger.debug("no items in attach table " + attach_name)
849
+ return 0
850
+ end
834
851
 
835
852
  # attach class information
836
853
  attach_class = attach_arr.first.class
@@ -934,6 +951,14 @@ module DynamicRecordsMeritfront
934
951
  end
935
952
  }
936
953
 
954
+ if Rails.logger.level <= 1
955
+ if as
956
+ Rails.logger.debug "#{x}/#{attach_arr.count} attached from #{attach_name} as #{as} -> #{base_name}(#{x}/#{base_arr.count})"
957
+ else
958
+ Rails.logger.debug "#{x}/#{attach_arr.count} attached from #{attach_name} -> #{base_name}(#{x}/#{base_arr.count})"
959
+ end
960
+ end
961
+
937
962
  return x
938
963
  end
939
964
  alias swiss_attach dynamic_attach
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic-records-meritfront
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Clancy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-10 00:00:00.000000000 Z
11
+ date: 2023-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashid-rails
@@ -54,7 +54,7 @@ metadata:
54
54
  homepage_uri: https://github.com/LukeClancy/dynamic-records-meritfront
55
55
  source_code_uri: https://github.com/LukeClancy/dynamic-records-meritfront
56
56
  changelog_uri: https://github.com/LukeClancy/dynamic-records-meritfront/blob/main/README.md
57
- post_install_message:
57
+ post_install_message:
58
58
  rdoc_options: []
59
59
  require_paths:
60
60
  - lib
@@ -69,8 +69,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.3.7
73
- signing_key:
72
+ rubygems_version: 3.4.10
73
+ signing_key:
74
74
  specification_version: 4
75
75
  summary: Helpers for active record that allow for more abstract and fine-grained code.
76
76
  test_files: []