forest_admin_datasource_active_record 1.0.0.pre.beta.60 → 1.0.0.pre.beta.61
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c9ce7a6a32ae3e985c64e2c9458165de5d24e8d7a532ca6a405aac048ef5ede8
|
|
4
|
+
data.tar.gz: 65ba39d8d70775cbb98e4b0f0d85888a5946fda8e34bd88bb8e7e3b52004fe2c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a1fcf17fd734b4275c86f82ac5afb4ff03bb4ac5a52b556b2df3ef1407f38076b37c94d650923711e0fe56fb63455e80ad1713c403592a93501b54e088b595b
|
|
7
|
+
data.tar.gz: 112af29e8fab7793768607f64e5f51c97183623cf461f8fcd24f332267d40d5bb62b04e2cc73115e2c0b7f10f239a1d97cc82023cf09646d78de40c5c0cfaff2
|
|
@@ -30,7 +30,7 @@ module ForestAdminDatasourceActiveRecord
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def create(_caller, data)
|
|
33
|
-
Utils::ActiveRecordSerializer.new(@model.create(data)).to_hash
|
|
33
|
+
Utils::ActiveRecordSerializer.new(@model.create(data)).to_hash(ProjectionFactory.all(self))
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def update(_caller, filter, data)
|
|
@@ -63,49 +63,75 @@ module ForestAdminDatasourceActiveRecord
|
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
def association_primary_key?(association)
|
|
67
|
+
!association.association_primary_key.empty?
|
|
68
|
+
rescue StandardError
|
|
69
|
+
false
|
|
70
|
+
end
|
|
71
|
+
|
|
66
72
|
def fetch_associations
|
|
67
73
|
associations(@model).each do |association|
|
|
68
74
|
case association.macro
|
|
69
75
|
when :has_one
|
|
70
|
-
|
|
71
|
-
association.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
if association_primary_key?(association)
|
|
77
|
+
if association.through_reflection?
|
|
78
|
+
add_field(
|
|
79
|
+
association.name.to_s,
|
|
80
|
+
ForestAdminDatasourceToolkit::Schema::Relations::ManyToManySchema.new(
|
|
81
|
+
foreign_collection: association.class_name.demodulize.underscore,
|
|
82
|
+
origin_key: association.through_reflection.foreign_key,
|
|
83
|
+
origin_key_target: association.through_reflection.join_foreign_key,
|
|
84
|
+
foreign_key: association.join_foreign_key,
|
|
85
|
+
foreign_key_target: association.association_primary_key,
|
|
86
|
+
through_collection: association.through_reflection.class_name.demodulize.underscore
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
else
|
|
90
|
+
add_field(
|
|
91
|
+
association.name.to_s,
|
|
92
|
+
ForestAdminDatasourceToolkit::Schema::Relations::OneToOneSchema.new(
|
|
93
|
+
foreign_collection: association.class_name.demodulize.underscore,
|
|
94
|
+
origin_key: association.foreign_key,
|
|
95
|
+
origin_key_target: association.association_primary_key
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
78
100
|
when :belongs_to
|
|
79
|
-
|
|
80
|
-
association.name.to_s,
|
|
81
|
-
ForestAdminDatasourceToolkit::Schema::Relations::ManyToOneSchema.new(
|
|
82
|
-
foreign_collection: association.class_name.demodulize.underscore,
|
|
83
|
-
foreign_key: association.foreign_key,
|
|
84
|
-
foreign_key_target: association.association_primary_key
|
|
85
|
-
)
|
|
86
|
-
)
|
|
87
|
-
when :has_many
|
|
88
|
-
if association.through_reflection?
|
|
101
|
+
if association_primary_key?(association)
|
|
89
102
|
add_field(
|
|
90
103
|
association.name.to_s,
|
|
91
|
-
ForestAdminDatasourceToolkit::Schema::Relations::
|
|
104
|
+
ForestAdminDatasourceToolkit::Schema::Relations::ManyToOneSchema.new(
|
|
92
105
|
foreign_collection: association.class_name.demodulize.underscore,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
foreign_key: association.join_foreign_key,
|
|
96
|
-
foreign_key_target: association.association_primary_key,
|
|
97
|
-
through_collection: association.through_reflection.class_name.demodulize.underscore
|
|
106
|
+
foreign_key: association.foreign_key,
|
|
107
|
+
foreign_key_target: association.association_primary_key
|
|
98
108
|
)
|
|
99
109
|
)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
end
|
|
111
|
+
when :has_many
|
|
112
|
+
if association_primary_key?(association)
|
|
113
|
+
if association.through_reflection?
|
|
114
|
+
add_field(
|
|
115
|
+
association.name.to_s,
|
|
116
|
+
ForestAdminDatasourceToolkit::Schema::Relations::ManyToManySchema.new(
|
|
117
|
+
foreign_collection: association.class_name.demodulize.underscore,
|
|
118
|
+
origin_key: association.through_reflection.foreign_key,
|
|
119
|
+
origin_key_target: association.through_reflection.join_foreign_key,
|
|
120
|
+
foreign_key: association.join_foreign_key,
|
|
121
|
+
foreign_key_target: association.association_primary_key,
|
|
122
|
+
through_collection: association.through_reflection.class_name.demodulize.underscore
|
|
123
|
+
)
|
|
107
124
|
)
|
|
108
|
-
|
|
125
|
+
else
|
|
126
|
+
add_field(
|
|
127
|
+
association.name.to_s,
|
|
128
|
+
ForestAdminDatasourceToolkit::Schema::Relations::OneToManySchema.new(
|
|
129
|
+
foreign_collection: association.class_name.demodulize.underscore,
|
|
130
|
+
origin_key: association.foreign_key,
|
|
131
|
+
origin_key_target: association.association_primary_key
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
end
|
|
109
135
|
end
|
|
110
136
|
end
|
|
111
137
|
end
|
|
@@ -19,11 +19,20 @@ module ForestAdminDatasourceActiveRecord
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def primary_key?(model)
|
|
23
|
+
!model.primary_key.empty?
|
|
24
|
+
rescue StandardError
|
|
25
|
+
false
|
|
26
|
+
end
|
|
27
|
+
|
|
22
28
|
def fetch_model(model)
|
|
23
29
|
if model.name.start_with?('HABTM_')
|
|
24
30
|
build_habtm(model)
|
|
25
31
|
else
|
|
26
|
-
@models << model unless model.abstract_class? ||
|
|
32
|
+
@models << model unless model.abstract_class? ||
|
|
33
|
+
@models.include?(model) ||
|
|
34
|
+
!model.table_exists? ||
|
|
35
|
+
!primary_key?(model)
|
|
27
36
|
end
|
|
28
37
|
end
|
|
29
38
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_admin_datasource_active_record
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.0.pre.beta.
|
|
4
|
+
version: 1.0.0.pre.beta.61
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthieu
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2024-07-
|
|
12
|
+
date: 2024-07-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activerecord
|