dynamic-records-meritfront 3.1.29 → 3.1.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +15 -17
- data/README.md +4 -2
- data/lib/dynamic-records-meritfront/version.rb +1 -1
- data/lib/dynamic-records-meritfront.rb +11 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c89216cc9c88e455670f35269bc949eb5e0bc1ac6ce04e02a3b03eb5d00b654
|
4
|
+
data.tar.gz: 3a943f93bb7c7fbfdf3d469afa0d5577e795dde5761d1b63229c8aa94fb60cfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 698dc9dc2d4cf602cd54e2b7633062177e7773095b3e94b06188c4d06a82bdea83df074af16f0b95c060f461c8ef82f7a7c272d3fa8d738660e62472118a9733
|
7
|
+
data.tar.gz: b49b8029d106e0dd729520fc2985be6e562a1a1b8f80028e3c13d1efb15a68ff539abe7be0826a3871e9eed34a068ea516ede0e5634960889ff9437c6c876f87
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dynamic-records-meritfront (3.1.
|
4
|
+
dynamic-records-meritfront (3.1.34)
|
5
5
|
hashid-rails
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (7.1.
|
11
|
-
activesupport (= 7.1.
|
12
|
-
activerecord (7.1.
|
13
|
-
activemodel (= 7.1.
|
14
|
-
activesupport (= 7.1.
|
10
|
+
activemodel (7.1.3.2)
|
11
|
+
activesupport (= 7.1.3.2)
|
12
|
+
activerecord (7.1.3.2)
|
13
|
+
activemodel (= 7.1.3.2)
|
14
|
+
activesupport (= 7.1.3.2)
|
15
15
|
timeout (>= 0.4.0)
|
16
|
-
activesupport (7.1.
|
16
|
+
activesupport (7.1.3.2)
|
17
17
|
base64
|
18
18
|
bigdecimal
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -23,23 +23,21 @@ GEM
|
|
23
23
|
minitest (>= 5.1)
|
24
24
|
mutex_m
|
25
25
|
tzinfo (~> 2.0)
|
26
|
-
base64 (0.
|
27
|
-
bigdecimal (3.1.
|
28
|
-
concurrent-ruby (1.2.
|
26
|
+
base64 (0.2.0)
|
27
|
+
bigdecimal (3.1.8)
|
28
|
+
concurrent-ruby (1.2.3)
|
29
29
|
connection_pool (2.4.1)
|
30
|
-
drb (2.
|
31
|
-
ruby2_keywords
|
30
|
+
drb (2.2.1)
|
32
31
|
hashid-rails (1.4.1)
|
33
32
|
activerecord (>= 4.0)
|
34
33
|
hashids (~> 1.0)
|
35
34
|
hashids (1.0.6)
|
36
|
-
i18n (1.14.
|
35
|
+
i18n (1.14.5)
|
37
36
|
concurrent-ruby (~> 1.0)
|
38
|
-
minitest (5.
|
39
|
-
mutex_m (0.
|
37
|
+
minitest (5.22.3)
|
38
|
+
mutex_m (0.2.0)
|
40
39
|
rake (12.3.3)
|
41
|
-
|
42
|
-
timeout (0.4.0)
|
40
|
+
timeout (0.4.1)
|
43
41
|
tzinfo (2.0.6)
|
44
42
|
concurrent-ruby (~> 1.0)
|
45
43
|
|
data/README.md
CHANGED
@@ -536,7 +536,9 @@ v3.0.6
|
|
536
536
|
- warning messages for dynamic_attach. to_s'd any provided table_names for ease-of-use.
|
537
537
|
- logging info for dynamic_attach outside of instaload.
|
538
538
|
- fixed an error where instaload only worked with ApplicationRecord abstract_class. Now works on anything thats a subclass of ActiveRecord::Base
|
539
|
-
|
539
|
+
|
540
|
+
3.2
|
541
|
+
- Updates so the latest version of the pg gem and rails works with the latest version of postgresql
|
540
542
|
|
541
543
|
|
542
544
|
## Questions
|
@@ -545,7 +547,7 @@ v3.0.6
|
|
545
547
|
- Q: The default name of my sql statements looks like a stack trace? Whats going on?
|
546
548
|
- A: We set the location of where you called the function as the default name for easy debugging. Its not an error, we just take some info from the stacktrace. It also includes the method name which can provide some insite into what the query is doing. Makes logs alot nicer to look at.
|
547
549
|
- Q: Whats MeritFront?
|
548
|
-
- A: I am making a social media platform.
|
550
|
+
- A: I am making a social media platform. Its called midflip now. See midflip.io
|
549
551
|
- Q: Inspect on user records doesn't seem to work properly
|
550
552
|
- A: inspect is overwritten by many diffrent libraries, in terms of devise for example, they override our override of active record's inspect. The best way to deal with this is to look at the source location of these methods and bring them together (user.method(:inspect).source_location). In my case with devise, i ended up with this in the user record:
|
551
553
|
```ruby
|
@@ -477,7 +477,6 @@ module DynamicRecordsMeritfront
|
|
477
477
|
# - multi_query allows more than one query (you can seperate an insert and an update with ';' I dont know how else to say it.)
|
478
478
|
# this disables other options (except name_modifiers). Not sure how it effects prepared statements. Its a fairly useless
|
479
479
|
# command as you can do multiple queries anyway with 'WITH' statements and also gain the other options.
|
480
|
-
# - async does what it says but I haven't used it yet so. Probabably doesn't work
|
481
480
|
# - raw switches between using a Hash or a ActiveRecord::Response object when used on a abstract class
|
482
481
|
args << {} unless args[-1].kind_of? Hash
|
483
482
|
if args.length == 3
|
@@ -501,7 +500,6 @@ module DynamicRecordsMeritfront
|
|
501
500
|
name_modifiers ||= []
|
502
501
|
prepare = opts.delete(:prepare) != false
|
503
502
|
multi_query = opts.delete(:multi_query) == true
|
504
|
-
async = opts.delete(:async) == true
|
505
503
|
params = opts
|
506
504
|
|
507
505
|
#unique value hash cuts down on the number of repeated arguments like in an update or insert statement
|
@@ -557,7 +555,7 @@ module DynamicRecordsMeritfront
|
|
557
555
|
end
|
558
556
|
end
|
559
557
|
sql_vals = var_track.get_array_for_exec_query
|
560
|
-
ret = ActiveRecord::Base.connection.exec_query sql, name, sql_vals, prepare: prepare
|
558
|
+
ret = ActiveRecord::Base.connection.exec_query sql, name, sql_vals, prepare: prepare
|
561
559
|
else
|
562
560
|
ret = ActiveRecord::Base.connection.execute sql, name
|
563
561
|
end
|
@@ -567,14 +565,12 @@ module DynamicRecordsMeritfront
|
|
567
565
|
sql ||= ''
|
568
566
|
sql_vals ||= ''
|
569
567
|
prepare ||= ''
|
570
|
-
async ||= ''
|
571
568
|
Rails.logger.error(%Q{
|
572
569
|
DynamicRecords#dynamic_sql debug info.
|
573
570
|
name: #{name.to_s}
|
574
571
|
sql: #{sql.to_s}
|
575
572
|
sql_vals: #{sql_vals.to_s}
|
576
573
|
prepare: #{prepare.to_s}
|
577
|
-
async: #{async.to_s}
|
578
574
|
})
|
579
575
|
raise e
|
580
576
|
end
|
@@ -599,7 +595,11 @@ module DynamicRecordsMeritfront
|
|
599
595
|
def _dynamic_instaload_handle_with_statements(with_statements)
|
600
596
|
%Q{WITH #{
|
601
597
|
with_statements.map{|ws|
|
602
|
-
|
598
|
+
if(ws[:with])
|
599
|
+
"#{ws[:with]} AS (\n#{ws[:sql]}\n)"
|
600
|
+
else
|
601
|
+
"#{ws[:table_name]} AS (\n#{ws[:sql]}\n)"
|
602
|
+
end
|
603
603
|
}.join(", \n")
|
604
604
|
}}
|
605
605
|
end
|
@@ -619,13 +619,13 @@ module DynamicRecordsMeritfront
|
|
619
619
|
#{ other_statements.map{|os| "SELECT row_to_json(#{os[:table_name]}.*) AS row, '#{os[:klass]}' AS _klass FROM (\n#{os[:sql]}\n)) AS #{os[:table_name]}\n" }.join(' UNION ALL ')}
|
620
620
|
end
|
621
621
|
|
622
|
-
def instaload(sql, table_name: nil, relied_on: false, dont_return: false, base_name: nil, base_on: nil, attach_on: nil, one_to_one: false, as: nil)
|
622
|
+
def instaload(sql, table_name: nil, relied_on: false, dont_return: false, base_name: nil, base_on: nil, attach_on: nil, one_to_one: false, as: nil, with: nil)
|
623
623
|
#this function just makes everything a little easier to deal with by providing defaults, making it nicer to call, and converting potential symbols to strings.
|
624
624
|
#At the end of the day it just returns a hash with the settings in it though. So dont overthink it too much.
|
625
625
|
|
626
626
|
as = as.to_s if as
|
627
627
|
base_name = base_name.to_s if base_name
|
628
|
-
|
628
|
+
|
629
629
|
if table_name
|
630
630
|
table_name = table_name.to_s
|
631
631
|
else
|
@@ -637,7 +637,8 @@ module DynamicRecordsMeritfront
|
|
637
637
|
sql = "\t" + sql.strip
|
638
638
|
raise StandardError.new("base_on needs to be nil or a Proc") unless base_on.nil? or base_on.kind_of? Proc
|
639
639
|
raise StandardError.new("attach_on needs to be nil or a Proc") unless attach_on.nil? or attach_on.kind_of? Proc
|
640
|
-
return {table_name: table_name, klass: klass, sql: sql, relied_on: relied_on, dont_return: dont_return,
|
640
|
+
return { table_name: table_name, klass: klass, sql: sql, relied_on: relied_on, dont_return: dont_return,
|
641
|
+
base_name: base_name, base_on: base_on, attach_on: attach_on, one_to_one: one_to_one, as: as, with: with }
|
641
642
|
end
|
642
643
|
|
643
644
|
def instaload_sql(*args) #name, insta_array, opts = { })
|
@@ -651,7 +652,7 @@ module DynamicRecordsMeritfront
|
|
651
652
|
raise StandardError.new("bad input to DynamicRecordsMeritfront#instaload_sql method.")
|
652
653
|
end
|
653
654
|
|
654
|
-
with_statements = insta_array.select{|a| a[:relied_on]}
|
655
|
+
with_statements = insta_array.select{|a| a[:relied_on] or a[:with]}
|
655
656
|
sql = %Q{
|
656
657
|
#{ _dynamic_instaload_handle_with_statements(with_statements) if with_statements.any? }
|
657
658
|
#{ _dynamic_instaload_union(insta_array)}
|
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.
|
4
|
+
version: 3.1.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Clancy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashid-rails
|